MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/MaterialX / getTypeString

Function getTypeString

python/MaterialX/datatype.py:32–50  ·  view source on GitHub ↗

Return the MaterialX type string associated with the given Python value If the type of the given Python value is not recognized by MaterialX, then None is returned. Examples: getTypeString(1.0) -> 'float' getTypeString(mx.Color3(1)) -> 'color3

(value)

Source from the content-addressed store, hash-verified

30
31#--------------------------------------------------------------------------------
32def getTypeString(value):
33 """Return the MaterialX type string associated with the given Python value
34 If the type of the given Python value is not recognized by MaterialX,
35 then None is returned.
36
37 Examples:
38 getTypeString(1.0) -> 'float'
39 getTypeString(mx.Color3(1)) -> 'color3'"""
40
41 valueType = type(value)
42 if valueType in _typeToName:
43 return _typeToName[valueType]
44 if valueType in (tuple, list):
45 if len(value):
46 elemType = type(value[0])
47 if elemType in _typeToName:
48 return _typeToName[elemType] + 'array'
49 return 'stringarray'
50 return None
51
52def getValueString(value):
53 """Return the MaterialX value string associated with the given Python value

Callers 7

getValueStringFunction · 0.85
_setValueFunction · 0.85
_setInputValueFunction · 0.85
_setPropertyValueFunction · 0.85
_setGeomPropValueFunction · 0.85
_typeToNameFunction · 0.85
_stringToValueFunction · 0.85

Calls 2

lenFunction · 0.85
typeClass · 0.50

Tested by

no test coverage detected