import Gaffer
import GafferOSL
import GafferScene
import IECore
import imath
Gaffer.Metadata.registerValue( parent, "serialiser:milestoneVersion", 1, persistent=False )
Gaffer.Metadata.registerValue( parent, "serialiser:majorVersion", 4, persistent=False )
Gaffer.Metadata.registerValue( parent, "serialiser:minorVersion", 0, persistent=False )
Gaffer.Metadata.registerValue( parent, "serialiser:patchVersion", 0, persistent=False )
__children = {}
__children["Plane"] = GafferScene.Plane( "Plane" )
parent.addChild( __children["Plane"] )
__children["Plane"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["PathFilter2"] = GafferScene.PathFilter( "PathFilter2" )
parent.addChild( __children["PathFilter2"] )
__children["PathFilter2"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["OSLCode2"] = GafferOSL.OSLCode( "OSLCode2" )
parent.addChild( __children["OSLCode2"] )
__children["OSLCode2"]["parameters"].addChild( Gaffer.StringPlug( "test_string", defaultValue = '', flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["OSLCode2"]["parameters"].addChild( Gaffer.StringPlug( "int_list", defaultValue = '', flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["OSLCode2"]["out"].addChild( Gaffer.StringPlug( "string_out", direction = Gaffer.Plug.Direction.Out, defaultValue = '', flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["OSLCode2"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["OSLObject2"] = GafferOSL.OSLObject( "OSLObject2" )
parent.addChild( __children["OSLObject2"] )
__children["OSLObject2"]["primitiveVariables"].addChild( Gaffer.NameValuePlug( "customString", Gaffer.StringPlug( "value", defaultValue = '', flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ), True, "primitiveVariable", Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) )
__children["OSLObject2"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["Plane"]["dimensions"]["x"].setValue( 4.0 )
__children["Plane"]["dimensions"]["y"].setInput( __children["Plane"]["dimensions"]["x"] )
__children["Plane"]["divisions"]["x"].setValue( 4 )
__children["Plane"]["divisions"]["y"].setInput( __children["Plane"]["divisions"]["x"] )
__children["Plane"]["__uiPosition"].setValue( imath.V2f( -51.8708267, -2.62412763 ) )
__children["PathFilter2"]["paths"].setValue( IECore.StringVectorData( [ '/plane' ] ) )
__children["PathFilter2"]["__uiPosition"].setValue( imath.V2f( -19.7563572, -10.466156 ) )
__children["OSLCode2"]["parameters"]["test_string"].setValue( 'test' )
__children["OSLCode2"]["parameters"]["int_list"].setValue( '1,2,3,4,5' )
__children["OSLCode2"]["code"].setValue( 'int index;\ngetattribute( "shading:index", index );\n\nstring_out = "";\n\nif (int_list != "")\n{\n\tstring int_array[5];\n\tsplit( int_list, int_array, "," );\n\n\tint start_index, end_index;\n\t\n\tstart_index = stoi(int_array[0]);\n\tend_index = stoi(int_array[-1]);\n\t\n\t// for (int n=start_index+1; n=end_index+1; n++){\n\t// \tif (n == index){\n\t// \t\tstring_out = test_string;\n\t// \t}\n\t// }\n}\n\n' )
__children["OSLCode2"]["__uiPosition"].setValue( imath.V2f( -71.8838272, -20.8342361 ) )
__children["OSLObject2"]["in"].setInput( __children["Plane"]["out"] )
__children["OSLObject2"]["filter"].setInput( __children["PathFilter2"]["out"] )
__children["OSLObject2"]["interpolation"].setValue( 2 )
__children["OSLObject2"]["primitiveVariables"]["primitiveVariable"]["value"].setInput( __children["OSLCode2"]["out"]["string_out"] )
__children["OSLObject2"]["__uiPosition"].setValue( imath.V2f( -51.8708267, -21.4342365 ) )
del __children