Notifications
Clear all

[Closed] help with object placing code

hi im trying to write a script
to take a reference object and placing a copy of it within the bounding box of another object
and orienting it to the to a face on the object

everything looks like its working fine
but when the target object is rotated , then the object im trying to copy and place , comes out bigger .

here is a screen capture of the result

here is the code im using right now:
(
obj = $box002
target = $
the_move = [target.center.x – obj.center.x,target.center.y – obj.center.y,target.min.z – obj.min.z]
target.EditablePoly.SetSelection #Edge #{2}
edg= (polyop.getEdgeSelection target)
verts=(polyop.getvertsusingedge target edg) as array
newdir=((v2=polyop.getvert target verts[2])-(v1=polyop.getvert target verts[1]))
p=instance obj
move p the_move
p.dir=newdir —orient to edge
p.rotation.x_rotation = 0 — point object up
ratios = (target.max – target.min) / (obj.max – obj.min)
the_scale = amin #(ratios.x, ratios.y,100)
scale p (the_scale * [1, 1, 1])
)

i would love some help with it
any suggestions will be good

2 Replies

Try to get the target object rotation, then rotate it to have it straight, execute your code and then rotate both objects to have the initial rotation of the target.

Ok , sounds a bit messy but probobly will work !
Thanks ! I’ll give it a try