Seeking a ldcad animation script method - Printable Version +- LDraw.org Discussion Forums (https://forums.ldraw.org) +-- Forum: LDraw Programs (https://forums.ldraw.org/forum-7.html) +--- Forum: Rendering Techniques (https://forums.ldraw.org/forum-20.html) +--- Thread: Seeking a ldcad animation script method (/thread-25300.html) |
Seeking a ldcad animation script method - belle - 2021-09-24 我想制作曲柄摇杆机构的动画,但一直没有合适的方法。我希望你能我。最好有脚本模板,帮助像附件。 非常感谢您 RE: Seeking a ldcad animation script method - Roland Melkert - 2021-09-24 (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. angles.png (Size: 18.91 KB / Downloads: 137) ps: I think most people would prefer English text even when using a translator. RE: Seeking a ldcad animation script method - belle - 2021-09-25 (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. Thank you for your answer. Could you please tell me where I can find similar script files for reference? RE: Seeking a ldcad animation script method - Roland Melkert - 2021-09-25 (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. RE: Seeking a ldcad animation script method - David Manley - 2021-09-28 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/bbm%3A978-3-319-31970-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 RE: Seeking a ldcad animation script method - David Manley - 2021-09-29 Hmmm, something is not quite right RE: Seeking a ldcad animation script method - belle - 2021-09-29 (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 RE: Seeking a ldcad animation script method - belle - 2021-09-29 (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. RE: Seeking a ldcad animation script method - Roland Melkert - 2021-09-29 (2021-09-29, 4:52)David Manley Wrote: Hmmm, something is not quite right 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. RE: Seeking a ldcad animation script method - David Manley - 2021-09-29 (2021-09-29, 18:10)Roland Melkert Wrote: Looks fun though 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 RE: Seeking a ldcad animation script method - David Manley - 2021-09-29 (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. RE: Seeking a ldcad animation script method - Roland Melkert - 2021-09-30 (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()? You are right I used the wrong method in the example too, I have corrected it. Thanks for pointing it out. RE: Seeking a ldcad animation script method - David Manley - 2021-10-03 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: 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). 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 RE: Seeking a ldcad animation script method - Roland Melkert - 2021-10-03 (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). RE: Seeking a ldcad animation script method - David Manley - 2021-10-03 (2021-10-03, 19:35)Roland Melkert Wrote: With crossed you mean it's at the underside? 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 RE: Seeking a ldcad animation script method - David Manley - 2021-10-08 I've updated the zip file with a newer Lua script. The primary visible differences are;
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! RE: Seeking a ldcad animation script method - liu - 2021-12-15 (2021-10-08, 5:44)David Manley Wrote: I've updated the zip file with a newer Lua script. The primary visible differences are; 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 |