LDraw.org Discussion Forums
Operating on multiple parts - Printable Version

+- LDraw.org Discussion Forums (https://forums.ldraw.org)
+-- Forum: LDraw Programs (https://forums.ldraw.org/forum-7.html)
+--- Forum: LDraw Editors and Viewers (https://forums.ldraw.org/forum-11.html)
+--- Thread: Operating on multiple parts (/thread-22635.html)



Operating on multiple parts - Michael Horvath - 2017-12-27

Is it possible to apply the same rotations on more than one part at the same time? E.g. rotate each part around the y axis by 90 degrees for instance, but not around a common center but around each part locally. Can this be done in MLCAD?


RE: Operating on multiple parts - Jarema - 2017-12-27

Maybe you should go to LDDP Homepage. This app in dedicated for mathematical operation on LDraw models too.


RE: Operating on multiple parts - Michael Horvath - 2017-12-27

(2017-12-27, 11:07)Jarema Wrote: Maybe you should go to LDDP Homepage. This app in dedicated for mathematical operation on LDraw models too.

Thanks. I was actually thinking that this might be easier by editing the source files by hand, and LDDP seems designed for that.


RE: Operating on multiple parts - Roland Melkert - 2017-12-27

(2017-12-27, 2:38)Michael Horvath Wrote: Is it possible to apply the same rotations on more than one part at the same time? E.g. rotate each part around the y axis by 90 degrees for instance, but not around a common center but around each part locally. Can this be done in MLCAD?

You can do this in my LDCad if you not afraid of an adventure in scripting.

edit: using this script:
Code:
function onRotInsRun()
 local sf=ldc.subfile()
 
 if sf:isLinked() then
   local sel=ldc.session():getSelection()

   local ori=ldc.matrix()
   ori:setRotate(45,0,1,0)

   for i=1,sel:getRefCount() do
     local ref=sel:getRef(i)
     ref:setOri(ori)
   end
 end
end

function register()

 local ani=ldc.macro('Rotate instances')
 ani:setEvent('run', 'onRotInsRun')
end

register()



RE: Operating on multiple parts - Michael Horvath - 2017-12-27

(2017-12-27, 18:58)Roland Melkert Wrote:
(2017-12-27, 2:38)Michael Horvath Wrote: Is it possible to apply the same rotations on more than one part at the same time? E.g. rotate each part around the y axis by 90 degrees for instance, but not around a common center but around each part locally. Can this be done in MLCAD?

You can do this in my LDCad if you not afraid of an adventure in scripting.

edit: using this script:
Code:
function onRotInsRun()
 local sf=ldc.subfile()
 
 if sf:isLinked() then
   local sel=ldc.session():getSelection()

   local ori=ldc.matrix()
   ori:setRotate(45,0,1,0)

   for i=1,sel:getRefCount() do
     local ref=sel:getRef(i)
     ref:setOri(ori)
   end
 end
end

function register()

 local ani=ldc.macro('Rotate instances')
 ani:setEvent('run', 'onRotInsRun')
end

register()

Can I select the objects to operate upon using the mouse? That would save a lot of time.


RE: Operating on multiple parts - Roland Melkert - 2017-12-27

(2017-12-27, 21:47)Michael Horvath Wrote: Can I select the objects to operate upon using the mouse? That would save a lot of time.

Yes it uses the active selection and applies the 45 deg rotation matrix to them all.

I've reworked the macro to apply the rotation of the first item in a selection (the one clicked first) to all the other items in the selection.

As this is a handy thing to have I added it to the samples module for the next version, but you can easilly use it now by replacing %appdata%\LDCad\scripts\default\global\samples.lua by the one in the attached zip file

You can use it on any selection through "scripts/samples/copy orientation" menu when installed.

ps: I'm assuming you're using the latest 1.6 version and not the older one from the AIOI. If so you can upgrade by running the 1.6a setup.