my first real script

I didn’t do programming, and actually one year ago I didn’t even know what a ‘string’ was. But I’ve been using a little bit of python to automate tasks within Softimage. It’s still challenging, but excited too. Now I feel like I was living in a foreign country without knowing it’s language…

So, ¬†here’s my first script. It’s dumb, but for me it’s very useful: it places a null as a parent of the selected objects, respecting the rest of the hierarchy; and if you hold down Ctrl, Alt or Shift, it places the null as a child…

download: ed_AddNullAsRelative.pys

#Add Null as Relative
#by Ed Schiffer
xsi = Application
oRoot = xsi.ActiveSceneRoot
sel = xsi.Selection
ks = xsi.GetKeyboardState()
for obj in sel:
	#if Ctrl, Alt or Shift is pressed, add a null as child:
	if ks(1) >= 1:
		oNull = oRoot.AddNull(obj.Name +"_child")
		xsi.MatchTransform(oNull, obj, "siSRT", "")
		xsi.ParentObj(obj, oNull)
	#else, add it as parent:
		oNull = oRoot.AddNull(obj.Name +"_root")
		oParent = obj.Parent
		xsi.MatchTransform(oNull, obj, "siSRT", "")
		xsi.ParentObj(oParent, oNull)
		xsi.ParentObj(oNull, obj)

Just drag&drop it under Softimage’s Script Editor.

Even for the simplest rig, like a rock, I find myself always putting an extra parent object for the animation controller, so it can be constrained at a higher level and the controller is still free to animate…



Leave a Reply