Skip to content

Commit b2526db

Browse files
committed
USD module : Bind DataAlgo::toUSD()
1 parent 2e68dc3 commit b2526db

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

Changes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
10.5.x.x (relative to 10.5.7.1)
22
========
33

4+
Improvements
5+
------------
6+
7+
- IECoreUSD::DataAlgo : Added binding for `toUSD()` function.
8+
49
Fixes
510
-----
611

contrib/IECoreUSD/src/IECoreUSD/bindings/IEUSDModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ BOOST_PYTHON_MODULE( _IECoreUSD )
9696
scope dataAlgoModuleScope( dataAlgoModule );
9797

9898
def( "role", &DataAlgo::role );
99+
def( "toUSD", (pxr::VtValue (*)( const IECore::Data *, bool ))&DataAlgo::toUSD, ( arg( "data" ), arg( "arrayRequired" ) = false ) );
99100
def( "valueTypeName", &DataAlgo::valueTypeName );
100101
}
101102

contrib/IECoreUSD/test/IECoreUSD/DataAlgoTest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ def testValueTypeNameBinding( self ) :
6868

6969
self.assertEqual( IECoreUSD.DataAlgo.valueTypeName( IECore.Color3fData( imath.Color3f( 0.0 ) ) ).type.typeName, "GfVec3f" )
7070

71+
def testToUSDBinding( self ) :
72+
73+
# Note : On the C++ side we are converting to VtValue, but the
74+
# bindings for that convert back to native Python types.
75+
76+
for data, value in [
77+
( IECore.IntData( 10 ), 10 ),
78+
( IECore.FloatData( 2.5 ), 2.5 ),
79+
( IECore.IntVectorData( [ 1, 2, 3 ] ), [ 1, 2, 3 ] ),
80+
] :
81+
self.assertEqual( IECoreUSD.DataAlgo.toUSD( data ), value )
82+
7183
def testToFromInternalName( self ) :
7284

7385
a = "a-name(that-is-bad)"

0 commit comments

Comments
 (0)