Objects and default properties


Here’s a scripting question from the mailing list:

Why do I get “None” when I print ChainRoot.Children and
ChainRoot.Bones?

si = Application
chainRoot = si.Create2DSkeleton(0, 0, 0, 10, 0, 0, -90, 0, 0, 4)

print chainRoot
print chainRoot.Children # Not working
print chainRoot.Bones # Not working
print chainRoot.Effector

# root1
# None
# None
# eff1

The answer is that ChainRoot.Children and ChainRoot.Bones are objects that don’t have a default property, so (in Python) you get the string representation of those objects, which is “None”.

ChainRoot and ChainRoot.Effector, being types of SIObject, and they do have a default property: the Name property.

ChainRoot.Children is an X3DObjectCollection, and ChainRoot.Bones is a ChainBoneCollection, and for whatever reason, those two collections don’t have Item as their default property (for some collections, like ISIVTCollection and LinktabRuleCollection, the Item property is the default property).

So the above Python is equivalent to this:

si = Application
chainRoot = si.Create2DSkeleton(0, 0, 0, 10, 0, 0, -90, 0, 0, 4)

print chainRoot.Name
print str( chainRoot.Children )
print chainRoot.Bones.__str__()
print chainRoot.Effector.Name

# root1
# None
# None
# eff1

Note that in JScript and VBScript, you’d get a “Type mismatch” error instead of the string “None” (in the original snippet).

Finding hidden objects


Here’s a little Python snippet that finds all 3d objects that have View Visibility turned off. After you run the snippet, those hidden objects are selected, so you can open the Explorer and press E to see them.

import win32com.client
viewvis = win32com.client.Dispatch( "XSI.Collection" )
hidden = win32com.client.Dispatch( "XSI.Collection" )

si = Application

viewvis.Items = '*.visibility.viewvis'
for o in viewvis:
	if o.Value == False and si.ClassName( o.Parent3DObject ) == "X3DObject" :
		hidden.Add( o.Parent3DObject )

si.SelectObj( hidden )
for o in hidden:
	print o

Finding custom properties by type


Many custom properties, like self-installing custom properties, have a specific type that isn’t “customparamset”. This means you can filter the collection returned by XSIApplication.FindObjects2.

from sipyutils import si		# win32com.client.Dispatch('XSI.Application')
from sipyutils import C			# win32com.client.constants

si = si()

props = si.FindObjects2( C.siCustomPropertyID ).Filter( 'Arnold_Render_Options' )
print props.Count
for p in props:
	print p.FullName
	print "   Shaders search path : %s" % p.Parameters( "shaders_path" ).Value
	print "   Textures search path: %s" % p.Parameters( "textures_path" ).Value

SDKExplorer_Custom_Property_Type

About transformation matrices…


You don’t necessarily have to understand everything about transformation matrices to use them. Just understand then when you multiply a point by a transformation matrix, you’re applying scaling, rotation, and translation to that point all at once.

If you do want to understand more, you can use ICE to visualize what goes into a transformation matrix:
srt-transfo-matrix

And you can do some reading 🙂