Shortcuts and default properties for custom parameters

Custom properties and the PPG object provide shortcuts for direct access to parameters.

For custom properties, that means you can type the shortcut oProp.SomeParam instead of oProp.Parameters(“SomeParam”). Note that that in this case, the default property is Name: if you print oProp.SomeParam, you get the name of the parameter.

from win32com.client import constants as C
si = Application

p = si.ActiveProject.ActiveScene.Root.AddCustomProperty( "Test" )
x = p.AddParameter2("X",C.siString,"a;b;c;d",None,None,None,None,C.siClassifUnknown,C.siPersistable)

print p.X
print p.X.IsEqualTo( p.Parameters("X") )
print x.IsEqualTo( p.X )

# Test.X
# True
# True

For the PPG object, the shortcut is even more of a convenience. To access a parameter named “Param”, you can type PPG.Param instead of PPG.Inspected(0).Param. And when you use the PPG.Param shortcut, the default property is Value.

So you can do this:

PPG.Param = 'hello;world'

There’s no need to type “PPG.Param.Value”, unless you’re doing something like this:

list = PPG.Param.Value.split(';')

One thought on “Shortcuts and default properties for custom parameters

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s