Hi,
as you mentioned the *SetAlign *accepts an *AlignmentFrame *type.

In C++ it would have been quite easier to spot that his definition is 
encapsulated in *ChForce *itself, so it should have been :
*spring_force_2->SetAlign(chrono::ChForce::AlignmentFrame::BODY_DIR);*

However, the wrapping just discarded the "AlignmentFrame" enum type, thus 
flattening the enum options directly inside *ChForce*. In short, it became:
*spring_force_2.SetAlign(chrono.ChForce.BODY_DIR)*

However, as you can see, *SetAlign *does not allow a generic frame to be 
used nor a marker (that would have been the proper choice), but it offers 
only two options: *BODY_DIR *or *WORLD_DIR*.
This means that unfortunately you *cannot *tell a *ChForce* applied to *Body2 
*to follow *Body1 *with *SetAlign*.

Currently there is not a smooth way to use ChForce to achieve what you 
desire. It is probably easier to go directly to a *ChLoadBodyBody*.

Apart from that: I see that you named the variable *spring_force*... if you 
just need a spring I would recommend you to use ChLinkTSDA isntead!

Dario


Il giorno martedì 12 dicembre 2023 alle 01:52:57 UTC+1 Dash ha scritto:

> Dear Chrono Community,
> I have created two bodies and I added a ChForce to the second body. I 
> would like the force to align with the coordinate system of the first body. 
> I am using the .SetAlign function but I get a type error. I saw online that 
> .SetAlign takes an alignment frame, I have tried giving it a marker but it 
> doesn't work. 
>
> TypeError: in method 'ChForce_SetAlign', argument 2 of type 
> 'chrono::ChForce::AlignmentFrame'
>
> Here is a snippet that is causing the problem: 
>
>         self.spring_force_2 = chrono.ChForce()
>         self.spring_force_2.SetMode(chrono.ChForce.FORCE)
>         self.body_2.AddForce(self.spring_force_2)
>         self.spring_force_2.SetVpoint(self.marker_2.GetPos())
>         self.spring_force_2.SetAlign(chrono.ChFrameD(self.marker_1))
>
> Thanks in advance to anyone who can point me in the right direction!
>

-- 
You received this message because you are subscribed to the Google Groups 
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/projectchrono/e884313b-6799-4760-8251-a48ea2b6fe0en%40googlegroups.com.

Reply via email to