Assembly 3 - loco coupled wheels motion (solved)

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
bambuko
Veteran
Posts: 2165
Joined: Thu Oct 24, 2019 12:53 pm
Location: UK, England, North Devon

Re: Assembly 3 - making progress (loco coupled wheels motion)

Post by bambuko »

LHC wrote: Sat Apr 10, 2021 7:40 pm ... But this often means I have to flip the element of the fastener on the x or y plane before making the attachment as it otherwise attaches itself upside down or with it's head buried in the part I am attaching it to...
Interesting nugget - I had the same problem where a link was attaching itself wrong way round whatever I did and it didn't occur to me that the answer is in the element :roll:

BTW I have also been heavily invested into Fusion 360 but from the beginning didn't like quite a few things about it.
Had problems with kinematics and animation of joints there as well (did some pretty complex models).

I like FreeCAD approach a lot more even if it is still very challenging - but that is really only as good as the operator :lol:
I am using Link branch and Assembly3
you can also download ... and try it here
excellent Assembly3 tutorials here
User avatar
jpg87
Posts: 809
Joined: Thu Mar 16, 2017 7:16 am
Location: Limoges - France
Contact:

Re: Assembly 3 - making progress (loco coupled wheels motion)

Post by jpg87 »

bambuko wrote: Sat Apr 10, 2021 7:52 pm I like FreeCAD approach ...
Me too !

The macro file :
AnimLoco.7z
(720 Bytes) Downloaded 36 times
To build the piloting file, click on the name of the pilot constraint in the General assembly constraints group :
The identifier of this constraint appears in the Python console (which must obviously be open !). The Lock Angle property of this constraint must be True.
Copy the macro file to the same folder as the file to animate (easier to find it).


View the windows of the two files in Cascade mode.
Check that the Macro toolbar is visible then click on the "Open a dialog ..." icon, select the folder containing the maco, then edit the macro.
Finally click on "Execute the macro ...".


The speed of the animation obviously depends on the capabilities of the computer, but as said @LHC, just record the video of the animation and then increase the playback speed to make the movement smoother.

Note: if the movement cycle is not complete or if you want to restart the animation after modifying the macro, do not forget to reset the Angle variable of the pilot constraint to its original value defined in the macro.
We can start from any original value, but if the difference between this value and the corresponding value in the constraint is too large, it is better to set the latter to the desired value before launching the macro.

Tip: to avoid excess stress problems, I did not force the left connecting rod to the rear wheel crank pin, but I imposed the horizontality of this connecting rod.

I am attaching another assembly file with the named mechanical links :
https://www.dropbox.com/s/0n6go3vpjvdi9 ... im.7z?dl=0

Addition: To modify or adapt the positioning of a part, select in the constraint the element relating to it then modify its Attachment properties.
My website : http://help-freecad-jpg87.fr updated 2023/11/06
User avatar
bambuko
Veteran
Posts: 2165
Joined: Thu Oct 24, 2019 12:53 pm
Location: UK, England, North Devon

Re: Assembly 3 - making progress (loco coupled wheels motion)

Post by bambuko »

jpg87 wrote: Sun Apr 11, 2021 8:36 am ...
Thank you :!:
downloaded everything and look forward to enjoyable Sunday (or a bit longer ... :lol: ) exploring what you did.
Will be back later with questions and comments.
I am using Link branch and Assembly3
you can also download ... and try it here
excellent Assembly3 tutorials here
User avatar
bambuko
Veteran
Posts: 2165
Joined: Thu Oct 24, 2019 12:53 pm
Location: UK, England, North Devon

Re: Assembly 3 - making progress (loco coupled wheels motion)

Post by bambuko »

Almost time to break for lunch :P but before that:

first let me say - use of "Same Orientation" constraint is great solution to the problem.
I have missed it altogether (tried using "MultiParallel Constraint" for this but it has failed).
So that's great :!:

I am following your instructions and playing with your macro to get the idea how it works.

1) how do you save modified macro? The only way I have found so far is to close it, at which time I am given an option to save it.

2) when I modify the value of "angle" in line 17, the only way for it to take effect I have found so far, was to close the macro, save it and execute it again, at which point it runs all the way round before settling in the new angular position - is this correct?
So I guess it is only possible to see the effect of changing this angle by running one cycle of animation?

3) you are saying:
# IF YOU WANT TO DO ANOTHER TEST, DON'T FORGET TO RESET THE CONSTRAINTS TO THE INITIAL VALUES
you are also saying, that:
Note: if the movement cycle is not complete or if you want to restart the animation after modifying the macro, do not forget to reset the Angle variable of the pilot constraint to its original value defined in the macro.
I guess it is me having another senior moment (sorry) but I am not sure that I follow...
Maybe it was because I was allowing the cycles to complete every time, but I had no problems changing the angle without "reseting"
and... how do you reset?

4) Why is the angle at Property set at -360deg when macro specifies 0deg ?
and... how is the direction of rotation defined?
and... can the direction be changed?
at the moment it is counterclockwise, but what if I wanted clockwise?

More to follow :lol:
but so far - Great work :!:
Thank you :!:
assy_3_animation.jpg
assy_3_animation.jpg (495.58 KiB) Viewed 873 times
I am using Link branch and Assembly3
you can also download ... and try it here
excellent Assembly3 tutorials here
User avatar
jpg87
Posts: 809
Joined: Thu Mar 16, 2017 7:16 am
Location: Limoges - France
Contact:

Re: Assembly 3 - making progress (loco coupled wheels motion)

Post by jpg87 »

bambuko wrote: Sun Apr 11, 2021 12:44 pm 1) how do you save modified macro? ...
To save the modified macro, the macro file must be active (just after a write), then the FreeCAD File / Save command applies to this file. If we are in the classic FreeCAD screen (tree, 3D view, etc.), the FreeCAD file (eg the assembly) is saved.
According to my tests, when you run the macro, it takes into account the last modifications made, even if it was not saved.
bambuko wrote: Sun Apr 11, 2021 12:44 pm 2) when I modify the value of "angle" in line 17 ...
In this example, the Angle variable has the value 0 in the macro, and in the properties of the constraint the value of the angle is also 0.
After running the macro, the angle has reached the value of -360 ° in the properties of the constraint, so one turn.
He therefore visually regained his starting position. If we run the macro again, visually there will be no difference.
bambuko wrote: Sun Apr 11, 2021 12:44 pm 3) you are saying: ...
If the amplitude of the displacement caused by the execution of the macro is not exactly equal to one revolution, when the macro is launched, you will see the system "jump" from the last position reached during the previous execution to the first. position caused by the new execution of the macro (... if there is no blocking or malfunction!).

Experiment by changing for example line 18 by
for i in range (46):

To reinitialize, at the end of the execution of the macro, it is necessary to click on the value reached by the angle in the properties of the pilot constraint to the initial value given line 17 in the macro.

Note, if the pilot constraint is selected in the tree at the time of the execution of the macro, you will see in the properties of this constraint the angle evolving from its starting position to its end position.
bambuko wrote: Sun Apr 11, 2021 12:44 pm 4) Why is the angle at Property set at -360deg when macro specifies 0deg ?
Line 21 of the macro:
angle - = 2
means an increment of 2 ° between two displayed images, negative direction.
To reverse the direction, you have to type instead
angle + = 2
You can change the numeric value of the increment.
The change of - = in + = reverses the direction well, but to foresee it in advance supposes to know exactly how the coordinate system is oriented for the pilot constraint. I just do a test to see in which direction the movement takes place (here I had chosen the forward movement of the loco).


Note: I am using Google translate to send you my remarks in English, maybe some translation details are escaping me !
My website : http://help-freecad-jpg87.fr updated 2023/11/06
User avatar
bambuko
Veteran
Posts: 2165
Joined: Thu Oct 24, 2019 12:53 pm
Location: UK, England, North Devon

Re: Assembly 3 - making progress (loco coupled wheels motion)

Post by bambuko »

jpg87 wrote: Sun Apr 11, 2021 6:05 pm ...Note: I am using Google translate to send you my remarks in English, maybe some translation details are escaping me !
Absolutely no problem at all ;)
English wasn't my mother tongue, although I have been using it as my main language for fourty years...
plus I've spent many years working with people from many countries/ continents , so I am quite used to interpreting :P
as long as you don't mind me sometimes asking more than once, for some clarification...
I appreciate how difficult it is for you and I am grateful for your effort :!:

Thank you for your replies - they make sense.

I am now going through all the assembly tree in the file - once again, it all makes sense and there are no surprises/questions there - all is clear so far.
An interesting thing I see in your file (and I didn't know before) is that you use in assemblies a mixture of original bodies and links.
I kept original bodies separate and only used links in the assemblies - another flexibility in FreeCAD Assembly 3 which makes things simpler.

I will need to experiment a lot more with the macro to understand all the details.
My main remaining concern is getting right the business of manually rotating the assembly using macro to the desired angle,
rather than just staring at nice animation :lol:

Another thing I need to get straight in my head is how to organise/structure my files to accomodate Assembly 3
but that's another story... ;)
I am using Link branch and Assembly3
you can also download ... and try it here
excellent Assembly3 tutorials here
LHC
Posts: 321
Joined: Thu Sep 17, 2020 4:21 pm
Location: Canadian Coffee Shop

Re: Assembly 3 - loco coupled wheels motion (solved)

Post by LHC »

I just checked in here and see you guys have made some serious progress. I mentioned it earlier but I plan to go back and try and catchup and hopefully learn from your efforts on this. Sounds like you are on the home stretch now.

As to organizing the structure of files I initially was keeping every body in a separate file but quickly ended up with a mess on my hands when I started shuffling files around on the computer. Then I switched to all bodies in the same file, then modified that approach to all unique bodies outside the assembly container and only links within it. My thought was if I make a mess of the assembly I could delete the assembly container and be back to just the unique bodies.

I did a test earlier by copying a file, then deleting the assembly container to see what happens. As usual - not exactly what I expected. The assembly disappeared but all the links to the bodies remained! Not s big deal I guess- I suppose I can easily identify the link objects in the tree and then delete them- or even reuse them.

Lots to learn and explore.

Cheers,
Lewis
Post Reply