Module sbsgenerator aims to provide useful functions to create/duplicate/connect SBSObjects
sbsgenerator.createCompFilterNode(aParentGraph, aFilter, aParameters = None, aInheritance = None)
Create a new compositing node filter with the given parameters. For a Bitmap or Svg node, use createResourceNode instead.
Parameters: | - aParentGraph (
SBSGraph ) – graph which will contain the created CompFilter node - aFilter (
FilterEnum or str) – type of filter to create - aParameters (dictionary in the format {parameterName(
CompNodeParamEnum ) : parameterValue(str)}, optional) – parameters of the filter node - aInheritance (dictionary with the format {parameterName(
CompNodeParamEnum ) : parameterInheritance(ParamInheritanceEnum )}, optional) – Inheritance of the parameters |
Returns: | The new SBSCompNode object |
sbsgenerator.createCompInstanceNode(aParentGraph, aGraph, aDependency, aPath, aParameters = None, aInheritance = None)
Create a new compositing node instance with the given parameters.
Parameters: | - aParentGraph (
SBSGraph ) – graph which will contain the created comp instance node - aGraph (
SBSGraph ) – graph to instantiate in the compositing node - aDependency (
SBSDependency ) – dependency associated to the referenced object (himself or external) - aPath (str) – path of the graph definition
- aParameters (dictionary in the format {parameterName(
CompNodeParamEnum ) : parameterValue(str)}) – parameters of the filter node - aInheritance (dictionary with the format {parameterName(
CompNodeParamEnum ) : parameterInheritance(ParamInheritanceEnum )}) – Inheritance of the parameters |
Returns: | The new SBSCompNode object |
sbsgenerator.createCurveParamsArray(aCompFilter, aCurveDefinition)
Create the hierarchy of SBSObject necessary to describe the given gradient key values.
sbsgenerator.createEmbeddedSVG(aSBSDocument, aResourcePath, aResourceGroup = 'Resources', aIdentifier = None, aAttributes = None, aCookedQuality = None)
Process the given resource: Create a new SBSResource in the folder ResourceGroup if the resource is not already in. Create the SBSGroup ResourceGroup if necessary. Create the dependency ‘?himself’ if necessary.
Parameters: | - aSBSDocument (
SBSDocument ) – reference document - aResourcePath (str) – relative or absolute path to the resource
- aResourceGroup (
SBSGroup or str, optional) – SBSGroup or identifier of the group where the resource will be added (the group is created if necessary). Default to ‘Resources’. Put None to create the resource at the root of the package. - aIdentifier (str, optional) – Identifier of the resource. If None, the identifier is taken from the resource path
- aAttributes (dictionary in the format {
AttributesEnum : value(str)}, optional) – attributes of the resource - aCookedQuality (float between 0 and 1, optional) – bitmap compression quality (only for BITMAP and SVG). Default value is 0
|
Returns: | The new SBSResource object |
sbsgenerator.createFunction(aParentObject, aFunctionIdentifier)
Parameters: | - aParentObject (
SBSObject ) – reference to the parent object that will contain this function - aFunctionIdentifier (str) – name of the function
|
Returns: | The new SBSFunction object |
sbsgenerator.createFunctionInstanceNode(aSBSDynamicValue, aFunction, aPath, aDependency)
Create a new function node instance of the given function, and set the parameters.
Parameters: | - aSBSDynamicValue (
SBSDynamicValue ) – the dynamic value which will contain the created ParamNode - aFunction (graph.SBSFunction) – the function that will be instantiated with the instance node
- aPath (str) – path of the function definition
- aDependency – dependency associated to the referenced object (himself or external)
- aDependency –
SBSDependency |
Returns: | The new SBSParamNode object |
sbsgenerator.createFunctionNode(aSBSDynamicValue, aFunction, aParameters = None)
Create a new function node (SBSParamNode) with the given parameters.
Parameters: | - aSBSDynamicValue (
SBSDynamicValue ) – the dynamic value which will contain the created ParamNode - aFunction (
FunctionEnum or str) – type of function to create - aParameters (dictionary in the format {parameterName(
FunctionEnum ) : parameterValue(str)}) – parameters of the function node |
Returns: | The new SBSParamNode object |
sbsgenerator.createGUIObject(aParentObject, aObjectType, aGUIName, aGUIPos, aSize, aTitle = None, aColor = None, aIsTitleVisible = False, aIsFrameVisible = False)
Parameters: | - aParentObject (
SBSGraph or SBSFunction ) – The parent graph / function that will contain the GUI object - aObjectType (
GUIObjectTypeEnum ) – Kind of GUI Object to create - aGUIName (str) – The GUI object textual content
- aGUIPos (list of 3 float) – The position of the GUI object
- aGUIDependency (str, optional) – The GUI dependency value (‘NODE?’), if this GUI object is linked to another object in the graph
- aSize (list of 2 float) – The size of the GUI object
- aTitle – The title of the GUI object (only for framed comments)
- aColor (list of 4 float, optional) – The color of the GUI object (only for framed comments)
- aIsTitleVisible (boolean, optional) – True to display the title of a framed comment. Default to False
- aIsFrameVisible (boolean, optional) – True in case of a framed comment. Default to False
|
Returns: | The SBSGUIObject created |
sbsgenerator.createGradientMapParamsArray(aCompFilter, aKeyValues)
Create the hierarchy of SBSObject necessary to describe the given gradient key values.
Parameters: | - aCompFilter (
SBSCompFilter ) – the Gradient map filter - aKeyValues (list of
GradientKey ) – the gradient map key values to set |
Returns: | the new SBSParamsArray if success, None otherwise |
sbsgenerator.createGraph(aParentObject, aGraphIdentifier, aParameters = None, aInheritance = None)
Parameters: | - aParentObject (
SBSDocument or SBSContent ) – reference to the parent object that will contain this graph - aGraphIdentifier (str) – name of the graph
- aParameters (dictionary with the format {parameterName(
CompNodeParamEnum ) : parameterValue(str)}, optional) – parameters of the graph (among the sbslibrary.sbslibclasses.BaseParameters only) - aInheritance (dictionary with the format {parameterName(
CompNodeParamEnum ) : parameterInheritance(ParamInheritanceEnum )}, optional) – Inheritance of the parameters |
Returns: | The new SBSGraph object |
sbsgenerator.createGroup(aParentObject, aGroupIdentifier)
Parameters: | - aParentObject (
SBSObject ) – reference to the parent object that will contain this graph - aGroupIdentifier (str) – name of the group
|
Returns: | The new SBSGroup object |
sbsgenerator.createIcon(aIconAbsPath)
Create a SBSIcon from the given image path
Parameters: | aIconAbsPath (str) – The absolute path of the image to set |
Returns: | The SBSIcon object created |
sbsgenerator.createImportedBitmap(aSBSDocument, aResourcePath, aResourceGroup = 'Resources', aIdentifier = None, aAttributes = None, aCookedFormat = None, aCookedQuality = None)
Process the given resource: Create a new SBSResource in the folder ResourceGroup if the resource is not already in. Create the SBSGroup ResourceGroup if necessary.
Parameters: | - aSBSDocument (
SBSDocument ) – reference document - aResourcePath (str) – relative or absolute path to the resource
- aResourceGroup (
SBSGroup or str, optional) – SBSGroup or identifier of the group where the resource will be added (the group is created if necessary). ‘Resources’ by default. Put None to create the resource at the root of the package. - aIdentifier (str, optional) – Identifier of the resource. If None, the identifier is taken from the resource path
- aAttributes (dictionary in the format {
AttributesEnum : value(str)}, optional) – attributes of the resource - aCookedFormat (
BitmapFormatEnum , optional) – bitmap format (JPEG/RAW) (only for BITMAP). Default value is RAW - aCookedQuality (float between 0 and 1, optional) – bitmap compression quality (only for BITMAP and SVG). Default value is 0
|
Returns: | The new SBSResource object |
sbsgenerator.createImportedResource(aSBSDocument, aResourceTypeEnum, aResourcePath, aResourceGroup = 'Resources', aIdentifier = None, aAttributes = None)
Process the given resource (font, light profile or bsdf measurement): Create a new SBSResource in the folder ResourceGroup if the resource is not already in. Create the SBSGroup ResourceGroup if necessary.
Parameters: | - aSBSDocument (
SBSDocument ) – reference document - aResourceTypeEnum (
ResourceKindEnum ) – resource kind, among FONT/LIGHT_PROFILE/M_BSDF - aResourcePath (str) – relative or absolute path to the resource
- aResourceGroup (
SBSGroup or str, optional) – SBSGroup or identifier of the group where the resource will be added (the group is created if necessary). Default to ‘Resources’. Put None to create the resource at the root of the package. - aIdentifier (str, optional) – Identifier of the resource. If None, the identifier is taken from the resource path
- aAttributes (dictionary in the format {
AttributesEnum : value(str)}, optional) – attributes of the resource |
Returns: | The new SBSResource object |
sbsgenerator.createInputNode(aParentGraph, aIdentifier, aColorMode = sbsenum.ColorModeEnum.COLOR, aAttributes = None, aUsages = None, aSetAsPrimary = False, aParameters = None, aInheritance = None, aGroup = None, aVisibleIf = None)
Create a new compositing node input with the appropriate color. Declare it as PrimaryInput if this is the first input node. Declare the new SBSParamInput
Parameters: | - aParentGraph (
SBSGraph ) – graph which will contain the created Output node - aIdentifier (str) – output identifier
- aColorMode (
ColorModeEnum , optional) – color or grayscale. Default is color - aAttributes (dictionary in the format {
AttributesEnum : value(str)}, optional) – attributes of the output node - aUsages (dictionary in the format: {
UsageEnum : {UsageDataEnum : string}, optional) – usages of this output - aSetAsPrimary (bool, optional) – True to define this input as the PrimaryInput of the graph. Even if False, the input will be set as the PrimaryInput if this is the first input of the graph. Default to False
- aParameters (dictionary {parameter(
CompNodeParamEnum ) : parameterValue(str)}, optional) – parameters of the input node - aInheritance (dictionary with the format {parameterName(
CompNodeParamEnum ) : parameterInheritance(ParamInheritanceEnum )}, optional) – Inheritance of the parameters - aGroup (str, optional) – GUI group name. Can uses path with ‘/’ separators.
- aVisibleIf (str, optional) – Condition of visibility of this input
|
Returns: | The new SBSCompNode object |
sbsgenerator.createInputParameter(aUID, aIdentifier, aWidget, aDefaultValue = None, aOptions = None, aDescription = None, aLabel = None, aGroup = None, aUserData = None, aVisibleIf = None)
Create a SBSParamInput
with the given parameters.
Parameters: | - aUID (str) – UID of the input parameter
- aIdentifier (str) – identifier of the input parameter
- aWidget (
WidgetEnum ) – widget to use for this parameter - aDefaultValue (str, optional) – default value
- aIsConnectable (bool, optional) – Whether this parameter can be connected for value computation
- aOptions (dictionary in the format {
WidgetOptionEnum : value(str)}, optional) – options - aDescription (str, optional) – textual description
- aLabel (str, optional) – GUI label for this input parameter
- aGroup (str, optional) – string that contains a group name. Can uses path with ‘/’ separators.
- aUserData (str, optional) – user tags
- aVisibleIf (str, optional) – string boolean expression based on graph inputs values
|
Returns: | The created SBSParamInput object |
Raise: | api_exceptions.SBSImpossibleActionError |
sbsgenerator.createIterationOnPattern(aParentObject, aNbIteration, aNodeUIDs, aNodeUIDs_NextPattern = None, aForceRandomSeed = False, aIncrementIteration = False, aGUIOffset = None)
Duplicate NbIteration times the given pattern of compositing nodes, and connect each pattern with the previous one to create this kind of connection:
Pattern -> Pattern_1 -> Pattern_2 -> … -> Pattern_N
It allows to completely define the way two successive patterns are connected.
For instance, provide aNodeUIDs = [A, B, C] and aNodeUIDs_NextPattern = [A’], if the pattern is A -> B -> C, and if C is connected to A’
If aNodeUIDs_NextPattern is let empty, the function will try to connect the successive patterns by the most obvious way, respecting the input / output type (color / grayscale)
Parameters: | - aParentObject (
SBSGraph or SBSDynamicValue ) – reference SBSObject where the iteration is created - aNbIteration (positive integer) – number of time the pattern must be duplicated
- aNodeUIDs (list of str) – list of node’s UID that constitute the pattern to duplicate
- aNodeUIDs_NextPattern (list of str, optional) – list of node’s UID that correspond to the inputs of the next pattern, which must be connected to the given pattern. Default to []
- aForceRandomSeed (bool, optional) – specify if a different random seed must be generated for each iteration. Default to False
- aIncrementIteration (bool, optional) – specify if the parameter ‘iteration’ must be incremented at each iteration. Default to False
- aGUIOffset (list of 2 float, optional) – pattern position offset. Default to [150, 0]
|
Returns: | The list of SBSCompNode objects created (including the nodes given in aNodeUIDs_NextPattern), None if failed |
Raise: | api_exceptions.SBSImpossibleActionError |
sbsgenerator.createLinkedResource(aSBSDocument, aResourcePath, aResourceTypeEnum = sbsenum.ResourceTypeEnum.BITMAP, aResourceGroup = 'Resources', aIdentifier = None, aAttributes = None, aCookedFormat = None, aCookedQuality = None, isUDIM = False, aForceNew = False)
Process the given resource: Create a new SBSResource in the folder ResourceGroup if the resource is not already in. Create the SBSGroup ResourceGroup if necessary.
Parameters: | - aSBSDocument (
SBSDocument ) – reference document - aResourcePath (str) – relative or absolute path to the resource
- aResourceTypeEnum (
ResourceTypeEnum ) – type of the resource (BITMAP/SVG/SCENE). Default is BITMAP - aResourceGroup (
SBSGroup or str, optional) – SBSGroup or identifier of the group where the resource will be added (the group is created if necessary). ‘Resources’ by default. None to put the resource at the root of the package. - aIdentifier (str, optional) – Identifier of the resource. If None, the identifier is taken from the resource path
- aAttributes (dictionary in the format {
AttributesEnum : value(str)}, optional) – attributes of the resource - aCookedFormat (
BitmapFormatEnum , optional) – bitmap format (JPEG/RAW) (only for BITMAP). Default value is RAW - aCookedQuality (float between 0 and 1, optional) – bitmap compression quality (only for BITMAP and SVG). Default value is 0
- isUDIM (bool, optional) – (only for SCENE) True to use UDIMs on this scene resource. Default to False
- aForceNew (bool, optional) – True to force the resource creation even if it is already included in the package. Default to False
- isRelToPackage (bool, optional) – the given path is relative, if isRelToPackage is True it is relative to the sbs package otherwise it is relative to cwd.
|
Returns: | The new SBSResource object |
sbsgenerator.createMDLGraph(aParentObject, aGraphIdentifier)
Create a new MDL graph with an output node.
Parameters: | - aParentObject (
SBSDocument or SBSContent ) – reference to the parent object that will contain this graph - aGraphIdentifier (str) – name of the graph
- aCreateOutputNode (bool) – True to create the output node. Default to True
|
Returns: | The new SBSGraph object |
sbsgenerator.createMDLNode(aParentGraph, aPath, aParameters = None)
Create a new MDL node with the given parameters.
Parameters: | - aParentGraph (
MDLGraph ) – graph which will contain the created MDL node - aImplementationKind (
MDLImplementationKindEnum ) – kind of mdl node implementation to create - aPath (str, optional) – mdl path of the node to create
- aParameters (dictionary in the format {parameterName(str) : parameterValue(str)}, optional) – parameters of the mdl node
- aCstAnnotations (dictionary in the format {annotation(
MDLAnnotationEnum ),annotationValue(str)}, optional) – for a constant: annotations of the mdl node - aCstIsExposed (bool, optional) – for a constant: defines if this constant is exposed as an input parameter of the graph
- aCstName (str, optional) – for a constant: name of the constant. If None, a name is affected by default using the constant type
- aCstValue (any type, optional) – for a constant: value of the constant
- aCstTypeModifier (
MDLTypeModifierEnum ) – for a constant: type modifier to set. Default to ‘auto’ - aInstanceOfGraph (
BaseGraph ) – for a Substance or MDL graph instance: the instantiated graph - aInstanceDependency (
SBSDependency ) – for a Substance or MDL graph instance: the associated dependency |
Returns: | The new MDLNode object |
Raise: | SBSImpossibleActionError |
sbsgenerator.createOutputNode(aParentGraph, aIdentifier, aAttributes = None, aOutputFormat = sbsenum.TextureFormatEnum.DEFAULT_FORMAT, aMipmaps = None, aUsages = None, aGroup = None, aVisibleIf = None)
Create a new compositing node output. Declare the new SBSRootOutput
and SBSGraphOutput
Parameters: | - aParentGraph (
SBSGraph ) – graph which will contain the created Output node - aIdentifier (str) – output identifier
- aAttributes (dictionary in the format {
AttributesEnum : value(str)}, optional) – attributes of the output node - aOutputFormat (
TextureFormatEnum , optional) – output format. default value is DEFAULT_FORMAT - aMipmaps (
MipmapEnum , optional) – default value is FULL_PYRAMID - aUsages (dictionary in the format: {
UsageEnum : {UsageDataEnum : string}, optional) – usages of this output - aGroup (str, optional) – GUI group of this output
- aVisibleIf (str, optional) – Condition of visibility of this output
|
Returns: | The new SBSCompNode object |
sbsgenerator.createPreset(aParentGraph, aLabel, aUsertags=None)
Create a new empty preset with the given label and usertags.
Parameters: | - aParentGraph (
SBSGraph ) – The graph associated to the preset to create - aLabel (str) – The label of this preset
- aUsertags (str, optional) – The usertags of this preset
|
Returns: | the created preset as a SBSPreset |
sbsgenerator.createResourceNode(aFilter, aSBSDocument, aParentGraph, aResourcePath, aParameters = None, aInheritance = None, aResourceGroup = 'Resources', aCookedFormat = None, aCookedQuality = None, aAttributes = None)
Create a new ‘bitmap’ node using the provided resourcePath. Create the referenced resource if necessary.
Parameters: | - aFilter (
FilterEnum ) – Filter type: BITMAP or SVG - aSBSDocument (
SBSDocument ) – reference document - aParentGraph (
SBSGraph ) – graph which will contain the created Bitmap node - aResourcePath (str) – internal (pkg:///MyGroup/MyResourceIdentifier), relative (to the current package) or absolute path to the bitmap resource to use as resource
- aParameters (dictionary in the format {parameterName(
CompNodeParamEnum ) : parameterValue(str)}, optional) – parameters of the Bitmap node - aInheritance (dictionary with the format {parameterName(
CompNodeParamEnum ) : parameterInheritance(ParamInheritanceEnum )}, optional) – Inheritance of the parameters - aResourceGroup (
SBSGroup or str, optional) – SBSGroup or identifier of the group where the resource will be added (the group is created if necessary). Default to ‘Resources’. Put None to create the resource at the root of the package. - aCookedFormat (
BitmapFormatEnum , optional) – resource bitmap format (JPEG/RAW). default value is RAW - aCookedQuality (float between 0 and 1, optional) – resource bitmap compression quality. default value is 0
- aAttributes (dictionary in the format {
AttributesEnum : value(str)}, optional) – attributes of the resource - aAutodetectImageParameters (bool, optional) – Autodetect and set resolution and bitdepth for the bitmap. Default to False
|
Returns: | The new SBSCompNode object |
Raise: | api_exceptions.SBSImpossibleActionError |
sbsgenerator.createSBSDocument(aContext, aFileAbsPath, aGraphIdentifier = None, aParameters = None, aInheritance = None)
Create a new sbs document.
Parameters: | - aContext (
Context ) – initialized context (contains alias information) - aFileAbsPath (str) – destination file of the sbs document (.sbs extension)
- aGraphIdentifier (str, optional) – name of the graph to create by default. if None, no graph is created
- aParameters (dictionary with the format {parameterName(
CompNodeParamEnum ) : parameterValue(str)}, optional) – parameters of the graph (among the sbslibrary.sbslibclasses.BaseParameters only) - aInheritance (dictionary with the format {parameterName(
CompNodeParamEnum ) : parameterInheritance(ParamInheritanceEnum )}, optional) – Inheritance of the parameters |
Returns: | The new SBSDocument object |
sbsgenerator.createSBSParamInputFromSBSARInput(aParentGraph, aSBSARInput, aIdentifier=None, aLabel=None, aDefaultValue=None)
Create a SBSParamInput
by giving a SBSARInput
. If an identifier, label or default value is not given the aSBSARInput’s values will be used instead.
Parameters: | - aParentGraph (
SBSGraph ) – the graph that will receive the parameter - aSBSARInput (
SBSARInput ) – An input from a SBSAR file. SBSParamInput attributes will be derived from it. - aIdentifier (str) – given if the new SBSParamInput’s identifier must be different than the aSBSARInput’s identifier
- aLabel (str) – given if the new SBSParamInput’s label must be different than the aSBSARInput’s label
- aDefaultValue (str) – given if the new SBSParamInput’s default value must be different than the aSBSARInput one
|
Returns: | SBSParamInput |