Skip to content

Commit 0f929c3

Browse files
committed
IECoreUSD::DataAlgo : Add support for SdfAssetPath
1 parent 789e741 commit 0f929c3

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

contrib/IECoreUSD/src/IECoreUSD/DataAlgo.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ IECore::DataPtr dataFromArray( const pxr::VtValue &value, GeometricData::Interpr
139139
return d;
140140
}
141141

142+
IECore::DataPtr dataFromSdfAssetPath( const pxr::VtValue &value, GeometricData::Interpretation interpretation, bool arrayAccepted )
143+
{
144+
return new StringData( value.Get<SdfAssetPath>().GetResolvedPath() );
145+
}
146+
142147
static const std::map<pxr::TfType, IECore::DataPtr (*)( const pxr::VtValue &, GeometricData::Interpretation, bool )> g_fromVtValueConverters = {
143148

144149
// Numeric types
@@ -202,7 +207,8 @@ static const std::map<pxr::TfType, IECore::DataPtr (*)( const pxr::VtValue &, Ge
202207
{ TfType::Find<string>(), &dataFromValue<string> },
203208
{ TfType::Find<VtArray<string>>(), &dataFromArray<string> },
204209
{ TfType::Find<TfToken>(), &dataFromValue<TfToken> },
205-
{ TfType::Find<VtArray<TfToken>>(), &dataFromArray<TfToken> }
210+
{ TfType::Find<VtArray<TfToken>>(), &dataFromArray<TfToken> },
211+
{ TfType::Find<SdfAssetPath>(), &dataFromSdfAssetPath }
206212

207213
};
208214

contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,5 +2938,19 @@ def testHoudiniVaryingLengthArrayPrimVar( self ) :
29382938
)
29392939
)
29402940

2941+
def testAssetAttributes( self ) :
2942+
2943+
root = IECoreScene.SceneInterface.create(
2944+
os.path.join( os.path.dirname( __file__ ), "data", "assetPathAttribute.usda" ),
2945+
IECore.IndexedIO.OpenMode.Read
2946+
)
2947+
xform = root.child( "xform" )
2948+
2949+
self.assertEqual( xform.attributeNames(), [ "render:testAsset" ] )
2950+
self.assertEqual(
2951+
xform.readAttribute( "render:testAsset", 0 ),
2952+
IECore.StringData( os.path.join( os.path.dirname( __file__ ), "data", "cube.usda" ) )
2953+
)
2954+
29412955
if __name__ == "__main__":
29422956
unittest.main()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#usda 1.0
2+
3+
def Xform "xform"
4+
{
5+
6+
asset primvars:testAsset = @./cube.usda@
7+
8+
}
9+

0 commit comments

Comments
 (0)