Python – Adding parameter to SCOP


Here’s a Python version of the CustomOperator.AddParameter example in the SDK docs, which shows how to add parameters to a scripted operator (SCOP).

from win32com.client import constants
import win32com.client
f = win32com.client.Dispatch( "XSI.Factory" )


null1 = Application.GetPrim( "null" )


s = """def MySOP_Update( ctx, out ):
   xsi = Application
   xsi.logmessage( 'update' )"""

sop = f.CreateScriptedOp( "MySOP", s, "Python" )


sop.AddOutputPort( null1.posx )

param1 = sop.AddParameter( f.CreateParamDef2("text", constants.siString, "hello") )
param2 = sop.AddParameter( f.CreateParamDef2("bool", constants.siBool, True) )
param3 = sop.AddParameter( f.CreateParamDef2("int", constants.siInt4, 10, 0, 100) )
param4 = sop.AddParameter( f.CreateParamDef2("dbl", constants.siDouble, 0.5, 0.0, 1.0) )

sop.Connect()

Application.InspectObj( sop )

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Connecting to %s