sbsgenerator module
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 nodeaFilter (
FilterEnumor str) – type of filter to createaParameters (dictionary in the format {parameterName(
CompNodeParamEnum) : parameterValue(str)}, optional) – parameters of the filter nodeaInheritance (dictionary with the format {parameterName(
CompNodeParamEnum) : parameterInheritance(ParamInheritanceEnum)}, optional) – Inheritance of the parameters
- Returns:
The new
SBSCompNodeobject
- 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 nodeaGraph (
SBSGraph) – graph to instantiate in the compositing nodeaDependency (
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 nodeaInheritance (dictionary with the format {parameterName(
CompNodeParamEnum) : parameterInheritance(ParamInheritanceEnum)}) – Inheritance of the parameters
- Returns:
The new
SBSCompNodeobject
- sbsgenerator.createCurveParamsArray(aCompFilter, aCurveDefinition)
Create the hierarchy of SBSObject necessary to describe the given gradient key values.
- Parameters:
aCompFilter (
SBSCompFilter) – the Gradient map filteraCurveDefinition (
CurveDefinition) – the curve definition to set
- Returns:
the new
SBSParamsArrayif success, None otherwise
- 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 documentaResourcePath (str) – relative or absolute path to the resource
aResourceGroup (
SBSGroupor str, optional) –SBSGroupor 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 resourceaCookedQuality (float between 0 and 1, optional) – bitmap compression quality (only for BITMAP and SVG). Default value is 0
- Returns:
The new
SBSResourceobject
- sbsgenerator.createFunction(aParentObject, aFunctionIdentifier)
Create a new function.
- Parameters:
aParentObject (
SBSObject) – reference to the parent object that will contain this functionaFunctionIdentifier (str) – name of the function
- Returns:
The new
SBSFunctionobject
- 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 ParamNodeaFunction (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
SBSParamNodeobject
- 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 ParamNodeaFunction (
FunctionEnumor str) – type of function to createaParameters (dictionary in the format {parameterName(
FunctionEnum) : parameterValue(str)}) – parameters of the function node
- Returns:
The new
SBSParamNodeobject
- sbsgenerator.createGUIObject(aParentObject, aObjectType, aGUIName, aGUIPos, aSize, aTitle=None, aColor=None, aIsTitleVisible=False, aIsFrameVisible=False)
- Parameters:
aParentObject (
SBSGraphorSBSFunction) – The parent graph / function that will contain the GUI objectaObjectType (
GUIObjectTypeEnum) – Kind of GUI Object to createaGUIName (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?<uid>’), 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
SBSGUIObjectcreated
- sbsgenerator.createGradientMapParamsArray(aCompFilter, aKeyValues)
Create the hierarchy of SBSObject necessary to describe the given gradient key values.
- Parameters:
aCompFilter (
SBSCompFilter) – the Gradient map filteraKeyValues (list of
GradientKey) – the gradient map key values to set
- Returns:
the new
SBSParamsArrayif success, None otherwise
- sbsgenerator.createGraph(aParentObject, aGraphIdentifier, aParameters=None, aInheritance=None)
Create a new graph.
- Parameters:
aParentObject (
SBSDocumentorSBSContent) – reference to the parent object that will contain this graphaGraphIdentifier (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
SBSGraphobject
- sbsgenerator.createGroup(aParentObject, aGroupIdentifier)
Create a new group.
- sbsgenerator.createIcon(aIconAbsPath)
Create a SBSIcon from the given image path
- Parameters:
aIconAbsPath (str) – The absolute path of the image to set
- Returns:
The
SBSIconobject 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 documentaResourcePath (str) – relative or absolute path to the resource
aResourceGroup (
SBSGroupor str, optional) –SBSGroupor 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 resourceaCookedFormat (
BitmapFormatEnum, optional) – bitmap format (JPEG/RAW) (only for BITMAP). Default value is RAWaCookedQuality (float between 0 and 1, optional) – bitmap compression quality (only for BITMAP and SVG). Default value is 0
- Returns:
The new
SBSResourceobject
- 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 documentaResourceTypeEnum (
ResourceKindEnum) – resource kind, among FONT/LIGHT_PROFILE/M_BSDFaResourcePath (str) – relative or absolute path to the resource
aResourceGroup (
SBSGroupor str, optional) –SBSGroupor 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
SBSResourceobject
- 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 nodeaIdentifier (str) – output identifier
aColorMode (
ColorModeEnum, optional) – color or grayscale. Default is coloraAttributes (dictionary in the format {
AttributesEnum: value(str)}, optional) – attributes of the output nodeaUsages (dictionary in the format: {
UsageEnum: {UsageDataEnum: string}, optional) – usages of this outputaSetAsPrimary (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 nodeaInheritance (dictionary with the format {parameterName(
CompNodeParamEnum) : parameterInheritance(ParamInheritanceEnum)}, optional) – Inheritance of the parametersaGroup (str, optional) – GUI group name. Can uses path with ‘/’ separators.
aVisibleIf (str, optional) – Condition of visibility of this input
- Returns:
The new
SBSCompNodeobject
- sbsgenerator.createInputParameter(aUID, aIdentifier, aWidget, aDefaultValue=None, aOptions=None, aDescription=None, aLabel=None, aGroup=None, aUserData=None, aVisibleIf=None)
Create a
SBSParamInputwith 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 parameteraDefaultValue (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) – optionsaDescription (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
SBSParamInputobject- 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_NIt 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 (
SBSGraphorSBSDynamicValue) – reference SBSObject where the iteration is createdaNbIteration (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
SBSCompNodeobjects 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 documentaResourcePath (str) – relative or absolute path to the resource
aResourceTypeEnum (
ResourceTypeEnum) – type of the resource (BITMAP/SVG/SCENE). Default is BITMAPaResourceGroup (
SBSGroupor str, optional) –SBSGroupor 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 resourceaCookedFormat (
BitmapFormatEnum, optional) – bitmap format (JPEG/RAW) (only for BITMAP). Default value is RAWaCookedQuality (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
SBSResourceobject
- 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
SBSRootOutputandSBSGraphOutput- Parameters:
aParentGraph (
SBSGraph) – graph which will contain the created Output nodeaIdentifier (str) – output identifier
aAttributes (dictionary in the format {
AttributesEnum: value(str)}, optional) – attributes of the output nodeaOutputFormat (
TextureFormatEnum, optional) – output format. default value is DEFAULT_FORMATaMipmaps (
MipmapEnum, optional) – default value is FULL_PYRAMIDaUsages (dictionary in the format: {
UsageEnum: {UsageDataEnum: string}, optional) – usages of this outputaGroup (str, optional) – GUI group of this output
aVisibleIf (str, optional) – Condition of visibility of this output
- Returns:
The new
SBSCompNodeobject
- sbsgenerator.createPreset(aParentGraph, aLabel, aUsertags=None)
Create a new empty preset with the given label and usertags.
- 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 SVGaSBSDocument (
SBSDocument) – reference documentaParentGraph (
SBSGraph) – graph which will contain the created Bitmap nodeaResourcePath (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 nodeaInheritance (dictionary with the format {parameterName(
CompNodeParamEnum) : parameterInheritance(ParamInheritanceEnum)}, optional) – Inheritance of the parametersaResourceGroup (
SBSGroupor 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 RAWaCookedQuality (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 resourceaAutodetectImageParameters (bool, optional) – Autodetect and set resolution and bitdepth for the bitmap. Default to False
- Returns:
The new
SBSCompNodeobject- 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
SBSDocumentobject
- sbsgenerator.createSBSParamInputFromSBSARInput(aParentGraph, aSBSARInput, aIdentifier=None, aLabel=None, aDefaultValue=None)
Create a
SBSParamInputby giving aSBSARInput. 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 parameteraSBSARInput (
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: