values module
Module values provides the definition of the classes relative to the value of parameters in the .sbs file:
- SBSConstantValue
- SBSOption
- SBSIcon
- SBSAttributes
- class sbscommon.values.SBSAttributes(aCategory=None, aLabel=None, aAuthor=None, aAuthorURL=None, aTags=None, aDescription=None, aUserTags=None, aIcon=None, aHideInLibrary=None, aPhysicalSize=None, aMaterialModel=None)
Bases:
SBSObjectClass that contains information on attributes as defined in a .sbs file
- Members:
mAuthor (str, optional): author information.
mAuthorURL (str, optional): author url.
mCategory (str, optional): data category. Slash separated strings.
mDescription (str, optional): textual description.
mHideInLibrary (str, optional): whether or not the object is hidden in library.
mIcon (
SBSIcon, optional): icon.mLabel (str, optional): user label.
mPhysicalSize (str, optional): the physical size (float3) of a graph.
mMaterialModel (str, optional): the material model of a graph.
mTags (str, optional): tags as comma separated strings.
mUserTags (str, optional): user information useful for the 3D engine using the substance engine (UNICODE string).
- 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.
- getAttribute(aAttributeIdentifier)
Get the given attribute value
- Parameters:
aAttributeIdentifier (
AttributesEnum) – the attribute identifier- Returns:
the attribute value if defined, None otherwise
- 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
- hasAttributes()
- Check if at least one attribute is defined among:
‘category’, ‘label’, ‘author’, ‘authorURL’, ‘tags’, ‘description’, ‘usertags’, ‘icon’, ‘hideInLibrary’, ‘physicalSize’, ‘materialModel’
- Returns:
True if at least one attribute is defined, False otherwise
- parse(aContext, aDirAbsPath, aSBSParser, aXmlNode)
Parse recursively the given xml node to retrieve the content of the SBSObject.
- setAttribute(self, aAttributeIdentifier, aAttributeValue)
Set the given attribute value
- Parameters:
aAttributeIdentifier (
AttributesEnum) – the attribute identifieraAttributeValue (str or
SBSIcon) – the attribute valueaParentObject (
SBSAttribute) – the object containing this attribute
- setAttributes(aAttributes, aParentObject)
Set the given attributes
- Parameters:
aAttributes (dictionary in the format {
AttributesEnum: value}) – The attributes to setaParentObject (
SBSAttribute) – the object containing this attribute
- class sbscommon.values.SBSConstantValue(aConstantValue=None, aTagName='')
Bases:
SBSObjectClass that contains information on a constant value as defined in a .sbs file
- Members:
mConstantValue (str): simple constant definition of a parameter.
mTagName (str): the tag name in the .sbs file, in the format ‘constantvalue<type>’
- 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.
- getType()
Get the type of this constant value
- Returns:
The type as a
ParamTypeEnumif success, None otherwise
- 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
- getValue()
Get the value of this constant value.
- Returns:
The value as a string if defined, None otherwise
- static isValidValue(aType, aValue)
setConstantValue(aType, aValue, aInt1 = False) Set the constant value to the given value, and set the tagname accordingly to the type of the value.
- Parameters:
aType (
ParamTypeEnum) – type of the valueaValue (str) – the value to set
aInt1 (bool) – True if the tag name must be ‘Int1’ instead of ‘Int32’ in the case of a value INTEGER1. Default to False
- parse(aContext, aDirAbsPath, aSBSParser, aXmlNode)
Parse recursively the given xml node to retrieve the content of the SBSObject.
- setConstantValue(aType, aValue, aInt1=False)
Set the constant value to the given value, and set the tagname accordingly to the type of the value.
- Parameters:
aType (
ParamTypeEnum) – type of the valueaValue (str) – the value to set
aInt1 (bool) – True if the tag name must be ‘Int1’ instead of ‘Int32’ in the case of a value INTEGER1. Default to False
- updateConstantValue(aValue)
Update the value.
- Parameters:
aValue (str) – the value to set
- class sbscommon.values.SBSIcon(aDataLength='', aFormat='', aStrdata='')
Bases:
SBSObjectClass that contains information on an icon as defined in a .sbs file. An icon can be added in the attributes section of a graph.
- Members:
mDataLength (str): length of the icon image data.
mFormat (str): icon format.
mStrdata (str): icon image data.
- 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.
- 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 recursively the given xml node to retrieve the content of the SBSObject.
- class sbscommon.values.SBSOption(aName='', aValue='')
Bases:
SBSObjectClass that contains information on an option that can appear in a substance graph / compNode
- Members:
mName (str): name of the option
mValue (str): value of the option
- 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.
- 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 recursively the given xml node to retrieve the content of the SBSObject.
- class sbscommon.values.SBSTree(aTreeElements=None)
Bases:
SBSObjectTree of options in the resource scene
- Members:
mTreeElements (collections.OrderedDict): Ordered dict of options with their name as ey
- asOptionList()
Recursively turns a tree into a list of options with paths. The options will have a name on the form a/b/c and a value representing the string at the leaf :return: [SBSOption]
- asStringList()
Returns the content of a tree representing a vector (meaning it has a size element and the indices as keys) :return: [str]
- 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.
- getChildByName(aName)
Returns a child node based on its name. Returns None if the child doesn’t exist :param aName: The name of the child to ask for :type aName: str :return: SBSTree SBSTreeList, SBSTreeStr, SBSTreeUrl or None if not found
- getChildByPath(aPath)
Queries a child by a path in a hierarchy of SBSTree and nodes :param aPath: The path to the child queried in the format a/b/c where a and b are SBStrees and c is the name of the element asked for :type aPath: str :return: SBSTree SBSTreeList, SBSTreeStr, SBSTreeUrl or None if not found
- 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 recursively the given xml node to retrieve the content of the SBSObject.
- setChildByPath(aPath, aValue, asURL=False)
Sets a child by a path in a hierarchy of SBSTree and nodes :param aPath: The path to the child queried in the format a/b/c where a and b are SBStrees and c is the name of the element to set If the element set already exists it will be overwritten by the new value :type aPath: str :param aValue: a string representing the value to set :type aValue: str :param asURL: Optional parameter to say whether the value should be created as an SBSTreeStr or SBSTreeUrl :type asURL: bool
- class sbscommon.values.SBSTreeList(aName='', aElements=None)
Bases:
SBSObjectList of options in the resource scene tree. Currently used in resource scenes
- Members:
mName (str): name of the option
aElements (list): a list of options to populate the list with
- 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.
- 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 recursively the given xml node to retrieve the content of the SBSObject.
- class sbscommon.values.SBSTreeStr(aName='', aValue='')
Bases:
SBSObjectA string option. Currently used in resource scenes
- Members:
mName (str): name of the option
mValue (str): value of the option
- 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.
- 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 recursively the given xml node to retrieve the content of the SBSObject.
- class sbscommon.values.SBSTreeUrl(aName='', aValue='')
Bases:
SBSObjectA url option. Currently used in resource scenes
- Members:
mName (str): name of the option
mValue (str): value of the option
- 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.
- 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 recursively the given xml node to retrieve the content of the SBSObject.