我想制作曲柄摇杆机构的动画,但一直没有合适的方法。我希望你能我。最好有脚本模板,帮助像附件。
非常感谢您
非常感谢您
(2021-09-24, 2:12)belle Wrote: 我想制作曲柄摇杆机构的动画,但一直没有合适的方法。我希望你能我。最好有脚本模板,帮助像附件。
非常感谢您
(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.
(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:Thank you for your information. I will study hard and get it done
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
(2021-09-29, 4:52)David Manley Wrote: Hmmm, something is not quite right
(2021-09-29, 18:10)Roland Melkert Wrote: Looks fun though
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.
(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?
(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).
(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!