ScriptSpot

Forum topic · General Scripting

Loop copy object, translate with local pivot and rotate

By Rodman · 2012-09-26

Description

Hello,

I'm trying to do like in this picture : http://imageshack.us/a/img855/5153/explanation.jpg

I wrote these lines, but I don't know how to make it work :


-- size of the object
dim_selobj =  (selobj.max - selobj.min)

-- object.min pivot
selobj.pivot = selobj.min

-- object coordonate
selobj_x = selobj.pos.x
selobj_y = selobj.pos.y
selobj_z = selobj.pos.z

for i = 1 to 10 do
(
		rot_angle_z = 45 -- theta angle
		rot_angle = eulerangles 0 0 rot_angle_z
		rotate selobj rot_angle
		selobj_copy_x = copy selobj
		in coordsys local selobj_copy_x.pos = [-i * dim_selobj[1] + selobj_x,selobj_y,dim_selobj[3]]

)
Comments (5)

le1setreter · 2012-09-26

between your two posts i changed your script a bit. just run it in empty scene...
maybe this helps you.

the difference is i do work with my last instance/copy instead with the base/start object.


rotationDegree = 13
instanceCount = 23

selobj = box length:4 width:8 height:4



-- size of the object
dim_selobj =  (selobj.max - selobj.min)
 
-- object.min pivot
selobj.pivot = selobj.min
 
-- object coordonate
selobj_x = selobj.pos.x
selobj_y = selobj.pos.y
selobj_z = selobj.pos.z
 


lastObj = selObj
 
for i = 1 to instanceCount-1 do
(
	
		tmpIns = instance lastObj
		
		in coordsys local tmpIns.pos = [tmpIns.pos[1]+dim_selobj[1],tmpIns.pos[2],tmpIns.pos[3]]
		
		
		rot_angle = eulerangles 0 0 -rotationDegree
		rotate tmpIns rot_angle
		
	
		lastObj = tmpIns


)

Thank you ! It works !

Rodman · 2012-09-26

I'm gonna adapt it to my code and i'll tell you the result. :)

Rodman · 2012-09-26

I don't know which video to see. But from what i see, there is a spline and I don't want to use it, and moreover I don't want to animate.

The problem in my script is the loop is made on the first object. But the loop should be on the last object created.This is my problem.

Thanks for your help by the way. :)