Help scripting parenting please

Hi,
I'm trying to script a parenting function within a larger script but having trouble.

I've found that when the names are predetermined this works fine:
$.parent = $Sphere001_ROOT

(Sphere001 is Selected, Sphere001_Root is a point helper)
However the names change from object to object. What I'm hoping to get working is proper syntax for the following:

tempobj = $
--start object is collected at start when object is selected

tempdummy = $
--dummy object is collected at when dummy is created

tempobj.parent = tempdummy

I guess the basic form of the question is how to parent objects without using the object name.

Any help would be appreciated.
Thanks

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

If you selection is with proper order then you will know which object to wjich dummy will be linked. I mean that the code below uses selection order.

(	
	startObjsArr = selection as array
	dummyObjsArr = selection as array
 
	if startObjsArr.count == dummyObjsArr.count do
	(
		for i = 1 to startObjsArr.count do
		(
			startObjsArr[i].parent = dummyObjsArr[i]
		)
	)
)
boudini's picture

That's perfect, thanks very

That's perfect, thanks very much!

I'm very poor at scripting but you helped me make my job that little bit easier.

miauu's picture

.

Glad to help. :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.