LDCad Restricting parts to whole number x,y,z script


Restricting parts to whole number x,y,z script
#1
So I wrote this script in lua that takes all the parts in a ldr and moves them to their "rounded" location (I have a massive studio 2.0 file that I have been working on for a while, and a bunch of stuff is slightly out of place in completely different directions)

I tried the script, and it works perfectly, but I was wondering if there was a way to make it so that the individual parts of each submodel could also be targeted and align to the world grid.

btw i used another script by N W Perry as a starting point


Attached Files
.lua   aligngrid.lua (Size: 807 bytes / Downloads: 8)
Reply
RE: Restricting parts to whole number x,y,z script
#2
(2023-11-28, 4:22)Ironmatt Wrote: a bunch of stuff is slightly out of place in completely different directions

This is due to the fact that Stud.io is not always using the LDraw file as model but a file from another source (LDD meshes, LEGO, ...) and these files may have a different origin.
Reply
RE: Restricting parts to whole number x,y,z script
#3
(2023-11-28, 7:25)Vincent Messenet Wrote: This is due to the fact that Stud.io is not always using the LDraw file as model but a file from another source (LDD meshes, LEGO, ...) and these files may have a different origin.

That's good to know, but I wonder why. Pretty much all the parts in stud.io also have ldraw models, is it just that parts are already in the program, so they don't feel like updating them?
Reply
RE: Restricting parts to whole number x,y,z script
#4
(2023-11-28, 18:13)Ironmatt Wrote: That's good to know, but I wonder why. Pretty much all the parts in stud.io also have ldraw models, is it just that parts are already in the program, so they don't feel like updating them?

Yes Studio has been initially released based on LDraw's 2017-01 update so all other parts are from unofficial LDraw's parts or other sources as I told above. Earlier this year they have finally updated parts from 2018-01 and 2018-02 so let's hope they will continue with next ones... but with latest 2023-06 it means they still have 18 LDraw's updates to catch up.
Reply
RE: Restricting parts to whole number x,y,z script
#5
No, Studio has their own update system, they sometimes even use parts who arent even official yet...
Reply
RE: Restricting parts to whole number x,y,z script
#6
So back to my origonal question, is there a way to access submodels in scripts, or is that not possible
Reply
RE: Restricting parts to whole number x,y,z script
#7
(2023-11-28, 22:26)Ironmatt Wrote: So back to my origonal question, is there a way to access submodels in scripts, or is that not possible

To apply it to submodels you'll have to recursively handle all references. Problem being you want to restrict that to the current mpd and excluding parts. You also need to keep track of a 'localToGlobal' transformation matrix.

This all is possible but a pain to code.

An easier way would be to process the current selection instead of the current model's references. That way you can use nested mode to select everything no matter the model it resides in.

Only limitation is  all submodels can only be used once, if not weird things might happen as parts inside models used multiple items would have multiple solutions (last should win though)
Reply
RE: Restricting parts to whole number x,y,z script
#8
(2023-11-28, 22:42)Roland Melkert Wrote: To apply it to submodels you'll have to recursively handle all references. Problem being you want to restrict that to the current mpd and excluding parts. You also need to keep track of a 'localToGlobal' transformation matrix.

This all is possible but a pain to code.

An easier way would be to process the current selection instead of the current model's references. That way you can use nested mode to select everything no matter the model it resides in.

Only limitation is  all submodels can only be used once, if not weird things might happen as parts inside models used multiple items would have multiple solutions (last should win though)

Thanks for the advice, I think I will just stay away from models with over 100 submodels for now Big Grin
Reply
RE: Restricting parts to whole number x,y,z script
#9
(2023-11-28, 4:22)Ironmatt Wrote: btw i used another script by N W Perry as a starting point

I'm honored.  Blush
Reply
RE: Restricting parts to whole number x,y,z script
#10
(2023-11-28, 21:55)Rene Rechthaler Wrote: No, Studio has their own update system, they sometimes even use parts who arent even official yet...

That's what I wrote Wink They use unofficial LDraw's parts
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 5 Guest(s)