ScriptSpot

Forum topic · General Scripting

Help scripting parenting please

By boudini · 2014-05-14

Description

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 (3)

.

miauu · 2014-05-15

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 · 2014-05-15

That's perfect, thanks very much!

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

.

miauu · 2014-05-15

Glad to help. :)