@@ -283,6 +283,8 @@ def testPrimVarTypes ( self ) :
283283 'test_Float2_Scalar_constant' : IECore .V2fData ( imath .V2f ( 0.1 , 0.2 ) ),
284284 'test_Float3_Array_constant' : IECore .V3fVectorData ( [imath .V3f ( 1.1 , 1.2 , 1.3 ), imath .V3f ( 2.1 , 2.2 , 2.3 ), imath .V3f ( 3.1 , 3.2 , 3.3 )] ),
285285 'test_Float3_Scalar_constant' : IECore .V3fData ( imath .V3f ( 0.1 , 0.2 , 0.3 ) ),
286+ 'test_Float4_Array_constant' : IECore .Color4fVectorData ( [imath .Color4f ( 1.1 , 1.2 , 1.3 , 1.4 ), imath .Color4f ( 2.1 , 2.2 , 2.3 , 2.4 ), imath .Color4f ( 3.1 , 3.2 , 3.3 , 3.4 )] ),
287+ 'test_Float4_Scalar_constant' : IECore .Color4fData ( imath .Color4f ( 0.1 , 0.2 , 0.3 , 0.4 ) ),
286288 'test_Float_Array_constant' : IECore .FloatVectorData ( [0.7 , 0.8 , 0.9 ] ),
287289 'test_Float_Scalar_constant' : IECore .FloatData ( 0.6 ),
288290 'test_Half_Array_constant' : IECore .HalfVectorData ( [0.0999756 , 0.199951 , 0.300049 ] ),
@@ -2482,7 +2484,7 @@ def assertAttributesValues( sphere ):
24822484
24832485 # Check that the USD file written looks as expected
24842486 stage = pxr .Usd .Stage .Open ( fileName )
2485- sphereUsd = pxr .UsdGeom .Imageable ( stage .GetPrimAtPath ( "/sphere" ) )
2487+ sphereUsd = pxr .UsdGeom .PrimvarsAPI ( stage .GetPrimAtPath ( "/sphere" ) )
24862488 self .assertEqual ( sphereUsd .GetPrim ().GetAttribute ( "customNamespaced:testAnimated" ).Get ( 0 ), 0 )
24872489 self .assertEqual ( sphereUsd .GetPrimvar ( "test" ).Get ( 0 ), "cyan" )
24882490 self .assertEqual ( sphereUsd .GetPrimvar ( "user:bongo" ).Get ( 0 ), "cyan" )
@@ -2491,7 +2493,7 @@ def assertAttributesValues( sphere ):
24912493 self .assertEqual ( sphereUsd .GetPrim ().GetAttribute ( "radius" ).Get ( 0 ), 10 )
24922494 self .assertEqual ( sphereUsd .GetPrim ().GetAttribute ( "studio:foo" ).Get ( 0 ), "brown" )
24932495
2494- abUsd = pxr .UsdGeom .Imageable ( stage .GetPrimAtPath ( "/ab" ) )
2496+ abUsd = pxr .UsdGeom .PrimvarsAPI ( stage .GetPrimAtPath ( "/ab" ) )
24952497 self .assertEqual ( abUsd .GetPrimvar ( "bar" ).Get ( 0 ), "black" )
24962498 self .assertEqual ( abUsd .GetPrimvar ( "bar" ).GetAttr ().GetMetadata ( "cortex_isConstantPrimitiveVariable" ), True )
24972499 self .assertEqual ( abUsd .GetPrimvar ( "notUserPrefixAttribute" ).Get ( 0 ), "orange" )
@@ -3271,5 +3273,34 @@ def testPointInstancerPrimvars( self ) :
32713273 self .assertEqual ( points ["myColor" ].interpolation , IECoreScene .PrimitiveVariable .Interpolation .Vertex )
32723274 self .assertEqual ( points ["myColor" ].indices , None )
32733275
3276+ def testArnoldArrayInputs ( self ) :
3277+
3278+ def assertExpectedArrayInputs ( network ) :
3279+
3280+ inputs = network .inputConnections ( "rampRGB" )
3281+ self .assertEqual ( len ( inputs ), 2 )
3282+ self .assertEqual ( inputs [0 ], ( ( "noise" , "out" ), ( "rampRGB" , "color[0]" ) ) )
3283+ self .assertEqual ( inputs [1 ], ( ( "flat" , "out" ), ( "rampRGB" , "color[1]" ) ) )
3284+
3285+ # Load original USD out of USD-Arnold.
3286+
3287+ scene = IECoreScene .SceneInterface .create (
3288+ os .path .join ( os .path .dirname ( __file__ ), "data" , "arnoldArrayInputs.usda" ),
3289+ IECore .IndexedIO .OpenMode .Read
3290+ )
3291+ network = scene .child ( "sphere" ).readAttribute ( "ai:surface" , 0 )
3292+
3293+ assertExpectedArrayInputs ( network )
3294+
3295+ # Write our own USD from that data, to check we can round-trip it.
3296+
3297+ fileName = os .path .join ( self .temporaryDirectory (), "arnoldArrayInputsRewritten.usda" )
3298+ scene = IECoreScene .SceneInterface .create ( fileName , IECore .IndexedIO .OpenMode .Write )
3299+ scene .createChild ( "sphere" ).writeAttribute ( "ai:surface" , network , 0 )
3300+
3301+ del scene
3302+ scene = IECoreScene .SceneInterface .create ( fileName , IECore .IndexedIO .OpenMode .Read )
3303+ assertExpectedArrayInputs ( scene .child ( "sphere" ).readAttribute ( "ai:surface" , 0 ) )
3304+
32743305if __name__ == "__main__" :
32753306 unittest .main ()
0 commit comments