Seeking a ldcad animation script method


Seeking a ldcad animation script method
#1
我想制作曲柄摇杆机构的动画,但一直没有合适的方法。我希望你能我。最好有脚本模板,帮助像附件。

非常感谢您


Attached Files
.gif   src=http___5b0988e595225.cdn.sohucs.com_q_70,c_zoom,w_640_images_20180519_3bf6c937be7b4259b0a41269132c6f6a.gif&refer=http___5b0988e595225.cdn.sohucs.gif (Size: 244.54 KB / Downloads: 154)
.ldr   demo.ldr (Size: 1.03 KB / Downloads: 6)
Reply
RE: Seeking a ldcad animation script method
#2
(2021-09-24, 2:12)belle Wrote: 我想制作曲柄摇杆机构的动画,但一直没有合适的方法。我希望你能我。最好有脚本模板,帮助像附件。

非常感谢您

This is a closed triangle problem, there are examples of that in some of the sample model animations.

Assuming the red beam has a known angle for A you can calculate the others using the trianglePlacementAngles function from the genTools module.

For each frame this would give you the red/green and blue/yellow angles, which are needed to close the BCD triangle.


.png   angles.png (Size: 18.91 KB / Downloads: 137)


ps: I think most people would prefer English text even when using a translator.
Reply
RE: Seeking a ldcad animation script method
#3
(2021-09-24, 21:45)Roland Melkert Wrote: This is a closed triangle problem, there are examples of that in some of the sample model animations.

Assuming the red beam has a known angle for A you can calculate the others using the trianglePlacementAngles function from the genTools module.

For each frame this would give you the red/green and blue/yellow angles, which are needed to close the BCD triangle.




ps: I think most people would prefer English text even when using a translator.

Thank you for your answer. Could you please tell me where I can find similar script files for reference?
Reply
RE: Seeking a ldcad animation script method
#4
(2021-09-25, 7:33)belle Wrote: Thank you for your answer. Could you please tell me where I can find similar script files for reference?

The 8071, 8852 and 8860 samples included with LDCad use closed triangle math.
Reply
RE: Seeking a ldcad animation script method
#5
I've written a script to animate a four bar linkage. The script and accompanying examples can be downloaded in a zip file from bricksafe. There's a (quick-and-dirty) video illustrating how to use the script:



This is a preliminary release of the script. It should work with uncrossed bars (refer to https://link.springer.com/content/pdf/bb...-4%2F1.pdf) but does not yet handle crossed bars.

I will take a look at some point in the future for handling crossed bars.

Regards,

David
Reply
RE: Seeking a ldcad animation script method
#6
Hmmm, something is not quite right

[Image: bad_linkage.gif]
Reply
RE: Seeking a ldcad animation script method
#7
(2021-09-28, 23:13)David Manley Wrote: I've written a script to animate a four bar linkage. The script and accompanying examples can be downloaded in a zip file from bricksafe. There's a (quick-and-dirty) video illustrating how to use the script:



This is a preliminary release of the script. It should work with uncrossed bars (refer to https://link.springer.com/content/pdf/bb...-4%2F1.pdf) but does not yet handle crossed bars.

I will take a look at some point in the future for handling crossed bars.

Regards,

David
Thank you for your information. I will study hard and get it done
Reply
RE: Seeking a ldcad animation script method
#8
(2021-09-25, 19:05)Roland Melkert Wrote: The 8071, 8852 and 8860 samples included with LDCad use closed triangle math.

Thank you for your reply. I will continue to study it.
Reply
RE: Seeking a ldcad animation script method
#9
(2021-09-29, 4:52)David Manley Wrote: Hmmm, something is not quite right

Looks fun though Big Grin

There is also a problem when you play the animation fast or slow.

This is because you based your calculations on frame rate which isn't guaranteed to stay constant during playback.

Fast will skip frames, and slow will increase the number of frames (super slowmo).

Very promising project non the less.
Reply
RE: Seeking a ldcad animation script method
#10
(2021-09-29, 18:10)Roland Melkert Wrote: Looks fun though Big Grin

There is also a problem when you play the animation fast or slow.

This is because you based your calculations on frame rate which isn't guaranteed to stay constant during playback.

Fast will skip frames, and slow will increase the number of frames (super slowmo).

Very promising project non the less.

So presumably I should be using ani:getFrameTime() and ani:getLength() instead of ani:getFrameNr() and ani:getFrameCount()?

If so, is may be worth reflecting the same approach in your Scripting examples page? I used getFrameNr() and getFrameCount() on the basis of the sample examples page. Or is your suggestion something else altogether?

David
Reply
RE: Seeking a ldcad animation script method
#11
(2021-09-29, 4:52)David Manley Wrote: Hmmm, something is not quite right

Corrected with a little bit of coding kragle. I want to make the fix a bit less of a hack and also incorporate the ability to animate crossed 4 bar linkages. Once I've done that, I will release an update.

[Image: good_linkage.gif]
Reply
RE: Seeking a ldcad animation script method
#12
(2021-09-29, 22:45)David Manley Wrote: So presumably I should be using ani:getFrameTime() and ani:getLength() instead of ani:getFrameNr() and ani:getFrameCount()?

If so, is may be worth reflecting the same approach in your Scripting examples page? I used getFrameNr() and getFrameCount() on the basis of the sample examples page. Or is your suggestion something else altogether?

You are right I used the wrong method in the example too, I have corrected it.

Thanks for pointing it out.
Reply
RE: Seeking a ldcad animation script method
#13
I've updated the zip file. The Lua script in it should now deal with both uncrossed and crossed linkage configurations. The zip file also contains some sample LDR files used to test the script. If you encounter any issues when running the script, please post details in this thread.

Here is a sample "crossed" linkage:

[Image: linkage_crossed.png]

You need to explicitly identify whether the model being animated is an uncrossed or crossed configuration. This is done via the macro "scripts/linkages/Rotation Parameters". The macro will prompt for a series of different settings (see image below). The dialog circled in red is the one in which the linkage model configuration is identified (by default the scripts assume an uncrossed model).

[Image: rotation_parameters_prompt.png]

I'm sure that there should be a way for the script to calculate whether a model is uncrossed or crossed. Something based around atan2. I tried working it out but in the end I couldn't so I'm made it a value which the user needs to identify.

Regards,

David
Reply
RE: Seeking a ldcad animation script method
#14
(2021-10-03, 6:31)David Manley Wrote: Here is a sample "crossed" linkage:

With crossed you mean it's at the underside?

If so you could calculate the relative y coordinate and if it's a positive one it's crossed (y being neg up in LDraw).
Reply
RE: Seeking a ldcad animation script method
#15
(2021-10-03, 19:35)Roland Melkert Wrote: With crossed you mean it's at the underside?

If so you could calculate the relative y coordinate and if it's a positive one it's crossed (y being neg up in LDraw).

The term "crossed" comes from the original reference material I used as the basis for the animation script.

My interpretation of this term is that at any stage the driver bar (green beam) is under (i.e. the driver rotation angle is > 180 degrees and < 360 degrees) the invariant bar (white beam), if the driven bar's (red beam) unconstrained rotation point is also under the invariant bar then this is a "crossed" scenario.

Having just written the description in the prior paragraph, I think I have managed to answer my own question! So I'm now going to experiment with the code a bit more to try to remove the need to explicitly specify whether something is crossed or uncrossed.

That being said, I've a suspicion the animation aberration for "crossed" bars may be a consequence of the formula given in the reference material. The formula as originally written didn't seem to cope with obtuse scalene triangles so I ended up using an alternative calculation to derive the required angle.

David
Reply
RE: Seeking a ldcad animation script method
#16
I've updated the zip file with a newer Lua script. The primary visible differences are;
  • that it now works out whether the configuration is "crossed" or "uncrossed", so you no longer have to tell it
  • the dialog to select crossed/uncrossed was put into a separate menu option and an "automatic" option added (which is the default). The automatic option will work out if the configuration is crossed or uncrossed but just in case it miscalculates (always a possibility!), the crossed/uncrossed setting can be manually set to override the automatic option
  • the animation will now display properly when the start position is anywhere in the animation sequence

Other differences within the code are to (a) support a different approach for working out the between frame part rotation and (b) use a slightly differently nomenclature for the parts (e.g. "crank" as opposed to "bar 1").

This has been a useful exercise for me. I've learnt a useful amount more about LDCAD's Lua scripting plus I got to exercise my trigonometry brain, last used many years ago! My thanks to Roland for his helpful posts and guidance which helped me improve the script.

Regards,

David

P.S. I had not realised until earlier today that you could make the animation run more slowly/quickly by clicking the slow animation button/faster animation button multiple times. You live and learn!
Reply
RE: Seeking a ldcad animation script method
#17
(2021-10-08, 5:44)David Manley Wrote: I've updated the zip file with a newer Lua script. The primary visible differences are;
  • that it now works out whether the configuration is "crossed" or "uncrossed", so you no longer have to tell it
  • the dialog to select crossed/uncrossed was put into a separate menu option and an "automatic" option added (which is the default). The automatic option will work out if the configuration is crossed or uncrossed but just in case it miscalculates (always a possibility!), the crossed/uncrossed setting can be manually set to override the automatic option
  • the animation will now display properly when the start position is anywhere in the animation sequence

Other differences within the code are to (a) support a different approach for working out the between frame part rotation and (b) use a slightly differently nomenclature for the parts (e.g. "crank" as opposed to "bar 1").

This has been a useful exercise for me. I've learnt a useful amount more about LDCAD's Lua scripting plus I got to exercise my trigonometry brain, last used many years ago! My thanks to Roland for his helpful posts and guidance which helped me improve the script.

Regards,

David

P.S. I had not realised until earlier today that you could make the animation run more slowly/quickly by clicking the slow animation button/faster animation button multiple times. You live and learn!

Thank you very much 
Now the final aninamtion is perfect 
Thanks again


Here comes a new problem in a new assembly(i'm confussed at how to subfile the assembly,tried several times counld't make the right animation . at last , i find maybe it's not the matter about how to  subfile the assembly )

the left rocker should move follow the right rocker , but I tried , could't make it 


i'v upload  the files to googledrive click here[url=https://drive.google.com/drive/folders/1LM9CYmzlR9ljawToKsb7hOaOSYmktIkp?usp=sharing][/url]

Looking forward to your help
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 4 Guest(s)