Notifications
Clear all

[Closed] Instance selection 4 times and align to specific node

hi, I need to instance selection 4 times and align each instanced group to a specific node.

I have certain objects selected — wheel, each object has different pivot point
I need to copy this 4 times and align each to a specific dummy:

here’s my code I’m working on:

dstWhFL = $wh_fl_dummy
dstWhFR = $wh_fr_dummy
dstWhRL = $wh_rl_dummy
dstWhRR = $wh_rr_dummy

wheels = #()

for obj in selection do (
	append wheels obj
	for i = 1 to 3 do (
		newObj = instance obj
		append wheels newObj
	)
)

Format "Array Wheels contains %\n" wheels.count
Format "Array Wheels contains %\n" wheels

wheels[1].center = dstWhFL.center
wheels[2].center = dstWhFR.center
in coordsys local wheels[2].rotation.z_rotation = 180
wheels[3].center = dstWhRL.center
wheels[4].center = dstWhRR.center
in coordsys local wheels[4].rotation.z_rotation = 180

2 Replies

You can approach this in many different ways, so there is no single answer.
Based on your script and the screenshot, something like these could work:

(
	dummies = #()
	
	append dummies #($wh_fl_dummy,   0)
	append dummies #($wh_fr_dummy, 180)
	append dummies #($wh_rl_dummy,   0)
	append dummies #($wh_rr_dummy, 180)
	
	for d in dummies do
	(
		for j in selection do
		(
			obj = instance j wirecolor:j.wirecolor
			obj.center = d[1].center - (selection.center - obj.center)
			about d[1].center rotate obj (angleaxis d[2] [0,0,1])
		)
	)
)

I don’t know why yet but this working pretty cool. thank you!