MCPcopy Create free account
hub / github.com/PixarAnimationStudios/OpenUSD / UsdPythonToSdfType

Function UsdPythonToSdfType

pxr/usd/usd/pyConversions.cpp:39–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39VtValue
40UsdPythonToSdfType(TfPyObjWrapper pyVal, SdfValueTypeName const &targetType)
41{
42 using namespace pxr_boost::python;
43
44 // Extract VtValue from python object.
45 VtValue val;
46 {
47 TfPyLock lock;
48 val = extract<VtValue>(pyVal.Get())();
49 }
50
51 // Attempt to cast the value to what we want. Get a default value for this
52 // attribute's type name.
53 VtValue defVal = targetType.GetDefaultValue();
54
55 // Attempt to cast the given value to the default value's type -- this
56 // will convert python buffer protocol objects (e.g. numpy arrays) to the
57 // appropriate typed VtArray when possible. If casting fails, attempt to
58 // continue with the given value. Deeper in the 'Set()' implementation,
59 // we'll issue a detailed type mismatch error.
60 VtValue cast = VtValue::CastToTypeOf(val, defVal);
61 if (!cast.IsEmpty())
62 cast.Swap(val);
63
64 return val;
65}
66
67bool
68UsdPythonToMetadataValue(

Callers 15

_CreateMassAttrFunction · 0.85
_CreateVelocityAttrFunction · 0.85
_CreateVolumeAttrFunction · 0.85
_CreateComplexStringAttrFunction · 0.85
_CreateIntAttrAttrFunction · 0.85
_CreateOrientationsAttrFunction · 0.85
_CreateOrientationshAttrFunction · 0.85
_CreatePositionsAttrFunction · 0.85
_CreatePositionshAttrFunction · 0.85
_CreateOrientationsAttrFunction · 0.85

Calls 4

GetMethod · 0.45
GetDefaultValueMethod · 0.45
IsEmptyMethod · 0.45
SwapMethod · 0.45

Tested by 13

_CreateTestAttrOneAttrFunction · 0.68
_CreateTestAttrTwoAttrFunction · 0.68
_CreateTempAttrFunction · 0.68
_CreateTempAttrFunction · 0.68
_CreateTempAttrFunction · 0.68
_CreateTestAttrOneAttrFunction · 0.68