User Guide Cancel

mdlcommon | Substance 3D Automation ToolKit

mdlcommon

Module mdlcommon provides the definition of common interfaces for MDLObjects:

class mdl.mdlcommon.MDLImplWithOperands(aOperands=None)
class mdl.mdlcommon.MDLImplWithOperands(aOperands=None)
 class mdl.mdlcommon.MDLImplWithOperands(aOperands=None)  

Bases: mdl.mdlcommon.MDLNodeImpl

This class allows to gather the parameter management for classes MDLImplConstant, MDLImplMDLInstance and MDLImplMDLGraphInstance

Members:
classify(aOther)
classify(aOther)
 classify(aOther)  

Compare the path of the two instances to classify them.

Parameters:aOther (MDLNodeImpl) – The filter to compare to.
Returns:1 if itself is considered greater than the other node, -1 for the opposite. 0 in case of equality.
equals(other)
equals(other)
 equals(other)  

Check if this SBSObject is equivalent to the other SBSObject. Some members may be excluded from this check, the UIDs or GUILayout for instance.

Parameters:other (SBSObject) – The SBSObject to compare to
Returns:True if the two SBSObject are similar according to their definition.
getDefinition()
getDefinition()
 getDefinition()  

Get the definition of the node (Inputs, Outputs, Parameters)

Returns:a MDLNodeDef object
getDisplayName()
getDisplayName()
 getDisplayName()  
Returns:the display name of this node as a string
getInputDefinition(self, aInputIdentifier=None)
getInputDefinition(self, aInputIdentifier=None)
 getInputDefinition(self, aInputIdentifier=None)  

Get the input definition corresponding to the given identifier.

Parameters:aInputIdentifier (str, optional) – The identifier to get. If let None, the first input will be returned
Returns:the input definition as a MDLNodeDefInput if found, None otherwise
getOperand(aOperandName)
getOperand(aOperandName)
 getOperand(aOperandName)  

Get the operand with the given name

Returns:a MDLOperand object if found, None otherwise
getOperands()
getOperands()
 getOperands()  

Get the list of operands objects

Returns:a list of MDLOperand
getOutputType(aOutputIdentifier=None)
getOutputType(aOutputIdentifier=None)
 getOutputType(aOutputIdentifier=None)  

Get the output type of this node given the output identifier.

Parameters:aOutputIdentifier (str, optional) – The output identifier to look for. If None, the first output will be considered
Returns:The node output type as a string (color or float) if found, None otherwise
getParameter(aParameter=None)
getParameter(aParameter=None)
 getParameter(aParameter=None)  

Get the parameter with the given name among the parameters available on the node. aParameter can be None in case of a Constant or Selector node, where there is only one parameter.

Parameters:aParameter (str, optional) – Parameter identifier
Returns:The parameter if found (MDLParameter or MDLOperand), None otherwise
getParameterValue(aParameter=None)
getParameterValue(aParameter=None)
 getParameterValue(aParameter=None)  

Find a parameter with the given name among the parameters available on the node and return its value. aParameter can be None in case of a Constant or Selector node, where there is only one parameter.

Parameters:aParameter (str, optional) – Parameter identifier
Returns:The parameter value if found (string or MDLOperand, None otherwise
getUidIsUsed(aUID)
getUidIsUsed(aUID)
 getUidIsUsed(aUID)  

Check if the given uid is already used in the context of this SBSObject.

Parameters:aUID (str) – UID to check
Returns:True if the uid is already used, False otherwise
Raise:AttributeError if the function getUidIsUsed in not properly overloaded on this SBSObject
parse(aContext, aDirAbsPath, aSBSParser, aXmlNode)
parse(aContext, aDirAbsPath, aSBSParser, aXmlNode)
 parse(aContext, aDirAbsPath, aSBSParser, aXmlNode)  

Parse recursively the given xml node to retrieve the content of the SBSObject.

Parameters:
  • aContext (Context) – execution context
  • aDirAbsPath (str) – the absolute directory containing the current parsed package (.sbs file)
  • aSBSParser (SBSParser) – the substance parser
  • aXmlNode (xml.etree.ElementTree) – the xml node to parse
resetParameter(aParameter = None)
resetParameter(aParameter = None)
 resetParameter(aParameter = None)  

Reset the given parameter to its default value. aParameter can be None in case of a Constant or Selector node, where there is only one parameter.

Parameters:aParameter (str) – identifier of the parameter to reset
Returns:True if succeed, False otherwise
Raise:api_exceptions.SBSLibraryError
setParameterValue(aParameter, aParamValue)
setParameterValue(aParameter, aParamValue)
 setParameterValue(aParameter, aParamValue)  

Set the value of the given parameter to the given value, if compatible with this node.

Parameters:
  • aParameter (str) – identifier of the parameter to set
  • aParamValue (any parameter type) – value of the parameter
Returns:

True if succeed, False otherwise

Raise:

api_exceptions.SBSLibraryError

write(aSBSWriter, aXmlNode)
write(aSBSWriter, aXmlNode)
 write(aSBSWriter, aXmlNode)  

Write recursively the content of the SBSObject into the given xml node.

Parameters:
  • aSBSWriter (SBSWriter) – the substance writer
  • aXmlNode (xml.etree.ElementTree) – the xml node to fill
class mdl.mdlcommon.MDLNodeImpl
class mdl.mdlcommon.MDLNodeImpl
 class mdl.mdlcommon.MDLNodeImpl  

Bases: pysbs.common_interfaces.sbsobject.SBSObject

This abstract class allows to provide a common interface for all MDL node implementation kind.

classify(aOther)
classify(aOther)
 classify(aOther)  

Compare the path of the two instances to classify them.

Parameters:aOther (MDLNodeImpl) – The filter to compare to.
Returns:1 if itself is considered greater than the other node, -1 for the opposite. 0 in case of equality.
equals(other)
equals(other)
 equals(other)  

Check if this SBSObject is equivalent to the other SBSObject. Some members may be excluded from this check, the UIDs or GUILayout for instance.

Parameters:other (SBSObject) – The SBSObject to compare to
Returns:True if the two SBSObject are similar according to their definition.
getDefinition()
getDefinition()
 getDefinition()  

Get the definition of the node (Inputs, Outputs, Parameters)

Returns:a MDLNodeDef object
getDisplayName()
getDisplayName()
 getDisplayName()  
Returns:the display name of this node as a string
getInputDefinition(self, aInputIdentifier=None)
getInputDefinition(self, aInputIdentifier=None)
 getInputDefinition(self, aInputIdentifier=None)  

Get the input definition corresponding to the given identifier.

Parameters:aInputIdentifier (str, optional) – The identifier to get. If let None, the first input will be returned
Returns:the input definition as a MDLNodeDefInput if found, None otherwise
getOutputType(aOutputIdentifier=None)
getOutputType(aOutputIdentifier=None)
 getOutputType(aOutputIdentifier=None)  

Get the output type of this node given the output identifier.

Parameters:aOutputIdentifier (str, optional) – The output identifier to look for. If None, the first output will be considered
Returns:The node output type as a string (color or float) if found, None otherwise
getParameter(aParameter=None)
getParameter(aParameter=None)
 getParameter(aParameter=None)  

Get the parameter with the given name among the parameters available on the node. aParameter can be None in case of a Constant or Selector node, where there is only one parameter.

Parameters:aParameter (str, optional) – Parameter identifier
Returns:The parameter if found (MDLParameter or MDLOperand), None otherwise
getParameterValue(aParameter=None)
getParameterValue(aParameter=None)
 getParameterValue(aParameter=None)  

Find a parameter with the given name among the parameters available on the node and return its value. aParameter can be None in case of a Constant or Selector node, where there is only one parameter.

Parameters:aParameter (str, optional) – Parameter identifier
Returns:The parameter value if found (string or MDLOperand, None otherwise
getUidIsUsed(aUID)
getUidIsUsed(aUID)
 getUidIsUsed(aUID)  

Check if the given uid is already used in the context of this SBSObject.

Parameters:aUID (str) – UID to check
Returns:True if the uid is already used, False otherwise
Raise:AttributeError if the function getUidIsUsed in not properly overloaded on this SBSObject
parse(aContext, aDirAbsPath, aSBSParser, aXmlNode)
parse(aContext, aDirAbsPath, aSBSParser, aXmlNode)
 parse(aContext, aDirAbsPath, aSBSParser, aXmlNode)  

Parse recursively the given xml node to retrieve the content of the SBSObject.

Parameters:
  • aContext (Context) – execution context
  • aDirAbsPath (str) – the absolute directory containing the current parsed package (.sbs file)
  • aSBSParser (SBSParser) – the substance parser
  • aXmlNode (xml.etree.ElementTree) – the xml node to parse
resetParameter(aParameter = None)
resetParameter(aParameter = None)
 resetParameter(aParameter = None)  

Reset the given parameter to its default value. aParameter can be None in case of a Constant or Selector node, where there is only one parameter.

Parameters:aParameter (str) – identifier of the parameter to reset
Returns:True if succeed, False otherwise
Raise:api_exceptions.SBSLibraryError
setParameterValue(aParameter, aParamValue)
setParameterValue(aParameter, aParamValue)
 setParameterValue(aParameter, aParamValue)  

Set the value of the given parameter to the given value, if compatible with this node.

Parameters:
  • aParameter (str) – identifier of the parameter to set
  • aParamValue (any parameter type) – value of the parameter
Returns:

True if succeed, False otherwise

Raise:

api_exceptions.SBSLibraryError

write(aSBSWriter, aXmlNode)
write(aSBSWriter, aXmlNode)
 write(aSBSWriter, aXmlNode)  

Write recursively the content of the SBSObject into the given xml node.

Parameters:
  • aSBSWriter (SBSWriter) – the substance writer
  • aXmlNode (xml.etree.ElementTree) – the xml node to fill
class mdl.mdlcommon.MDLObjectWithAnnotations(aAllowedAnnotations, aAnnotations)
class mdl.mdlcommon.MDLObjectWithAnnotations(aAllowedAnnotations, aAnnotations)
 class mdl.mdlcommon.MDLObjectWithAnnotations(aAllowedAnnotations, aAnnotations)  

Bases: object

This abstract class allows to provide a common interface for all MDL object with annotations.

getAnnotation(aAnnotation)
getAnnotation(aAnnotation)
 getAnnotation(aAnnotation)  

Get the given annotation.

Parameters:aAnnotation (MDLAnnotationEnum or str) – The annotation to look for, as an enumeration or a mdl path
Returns:The annotation as a MDLAnnotation
getAnnotationValue(aAnnotation)
getAnnotationValue(aAnnotation)
 getAnnotationValue(aAnnotation)  

Get the value of the given annotation.

Parameters:aAnnotation (MDLAnnotationEnum or str) – The annotation to look for, as an enumeration or a mdl path
Returns:The annotation value as a string or list of string if found, None otherwise
getGroup()
getGroup()
 getGroup()  

Get the ‘in_group’ annotation value

Returns:The group/subgroup/subsubgroup value if found, None otherwise
getUsage()
getUsage()
 getUsage()  

Get the ‘sampler_usage’ annotation value

Returns:The ‘sampler_usage’ value if found, None otherwise
hasUsage(aUsage)
hasUsage(aUsage)
 hasUsage(aUsage)  

Check if the given usage is defined on this constant node

Parameters:aUsage (str or UsageEnum) – The usage to look for (can be an enum value or a custom string)
Returns:True if the given usage is defined on this param input, False otherwise
removeAnnotation(aAnnotation)
removeAnnotation(aAnnotation)
 removeAnnotation(aAnnotation)  

Remove the given annotation from the list of annotations

Parameters:aAnnotation (MDLAnnotationEnum or str) – The annotation to look for, as an enumeration or a mdl path
setAnnotation(aAnnotation, aAnnotationValue)
setAnnotation(aAnnotation, aAnnotationValue)
 setAnnotation(aAnnotation, aAnnotationValue)  

Set the given attribute

Parameters:
  • aAnnotation (MDLAnnotationEnum) – The annotation to set, as an enumeration or a mdl path
  • aAnnotationValue (str or list of str) – The value to set
Raise:

SBSImpossibleActionError

setGroup(aGroup, aSubGroup=None, aSubSubGroup=None)
setGroup(aGroup, aSubGroup=None, aSubSubGroup=None)
 setGroup(aGroup, aSubGroup=None, aSubSubGroup=None)  

Set the ‘in_group’ annotation value with the given group and subgroups

Parameters:
  • aGroup (str) – The main group
  • aSubGroup (str, optional) – The sub-group
  • aSubSubGroup (str, optional) – The sub-sub-group
setUsage(aUsage)
setUsage(aUsage)
 setUsage(aUsage)  

Set the ‘sampler_usage’ annotation value with the given usage

Parameters:aUsage (str) – The usage to set

Get help faster and easier

New user?