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)
| 30 | |
| 31 | #-------------------------------------------------------------------------------- |
| 32 | def 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 | |
| 52 | def getValueString(value): |
| 53 | """Return the MaterialX value string associated with the given Python value |
no test coverage detected