User Guide Cancel

ag_functions | Substance 3D Automation ToolKit

  1. Substance 3D home
  2. Home
  3. Command Line Tools
    1. Command Line overview
    2. sbsbaker
      1. sbsbaker overview
      2. sbsbaker command line options
      3. sbsbaker Example Command Lines
    3. sbscooker
      1. sbscooker overview
      2. sbscooker command line options
      3. sbscooker pattern variables
    4. sbsmtools
      1. sbsmtools overview
      2. sbsmtools command line options
    5. sbsmutator
      1. sbsmutator overview
      2. sbsmutator command line options
      3. sbsmutator Example Command Lines
    6. sbsrender
      1. sbsrender overview
      2. sbsrender base parameters and pattern variables
      3. sbsrender command line options
      4. sbsrender example command lines
    7. sbsupdater
      1. sbsupdater overview
      2. sbsupdater command line options
  4. Pysbs - Python API
    1. Pysbs - Python API overview
    2. Getting started
    3. General topics
      1. Basic manipulation
      2. Substance creation
      3. Substances modification
      4. Dependencies management
      5. PySbs batchtools module
      6. metadata manipulation
      7. SAT demos
      8. Edit sbsar with SBSARManager
      9. Spot Colors
      10. Thumbnail creation with SAT
    4. Examples
      1. demohelloworld
      2. demos
      3. demos_batchtools
      4. script_update_with_sbsupdater
    5. API Content
      1. API Content overview
      2. Substance definitions
        1. Common interfaces
          1. basegraph
          2. package
          3. sbsarobject
          4. sbsobject
        2. compnode
          1. compnode overview
          2. common
          3. compimplementation
          4. paramgraph
        3. context projectmgr
        4. graph
          1. graph overview
          2. function
          3. inputparameters
          4. output
        5. mdl
          1. mdlannotation
          2. mdlcommon
          3. mdldictionaries
          4. mdlenum
          5. mdlgraph
          6. mdllibclasses
          7. mdlmanager
          8. mdlnode
          9. mdlnodeimpl
          10. mdloperand
          11. mdlsbsbridge
        6. modelgraphindex
          1. modelannotationnames
          2. modelgraph
          3. modelgraphgenerator
          4. modelgraphimplementation
          5. modelnodenames
          6. modeloperand
          7. modulegraphindex
          8. moduleannotation
          9. moduleconnection
          10. modulegraph
          11. modulegraphgenerator
          12. modulegraphimplementation
          13. modulegraphlibrary
          14. modulegraphregister
          15. modulenode
          16. modulenodeimplementation
          17. modulenodeinstance
          18. moduleoperand
          19. moduleoutputbridging
          20. moduleparaminput
        7. params
          1. params overview
          2. dynamicvalue
          3. paramnode
        8. projectmgrdoc
        9. sbsarchive
          1. sbsarchive overview
          2. sbsarenum
          3. sbsargraph
          4. sbsargui
          5. sbsarguiwidgets
          6. sbsarmanager
        10. sbscommon
          1. connections
          2. gui
          3. nodes
          4. values
        11. sbspreset
        12. sbsproject
        13. substance
          1. substance overview
          2. content
          3. resource
      3. Libraries
        1. sbsenum
        2. sbslibrary
          1. sbslibrary overview
          2. sbsdictionaries
          3. sbsfilters
          4. sbsfunctions
          5. sbsfxmapnodes
          6. sbslibclasses
          7. sbswidgets
        3. sbsbakerslibrary
          1. sbsbakerslibrary overview
          2. sbsbakersdef
          3. sbsbakersdefaultprops
          4. sbsbakersdictionaries
          5. sbsbakersenum
          6. sbsbakingconverter
          7. sbsbakingconverterparam
          8. sbsbakingparameters
          9. sbsdialogstate
          10. sbsscenedata
        4. Helpers
          1. sbscleaner
          2. sbsexporter
          3. sbsgenerator
          4. sbsparser
          5. sbswriter
          6. qtclasses
            1. qtclasses overview
            2. qtvariantreader
            3. qtvariantwriter
          7. psdparser
          8. sbsimpactmanager
          9. batchtools
          10. autograph
            1. ag_functions
            2. ag_layout
            3. ag_types
          11. info_mesh_parser
          12. sbsbaker_info_handlers
          13. sbsrender_render_handlers
          14. output_handlers
          15. spotcolorinfo_handler
          16. thumbnail
          17. batchtools overview
        5. Execution context
          1. context
          2. functions
        6. API Change log
  5. Samples
    1. Samples overview
    2. Texturing Template Demo
    3. Batch Tools Demo
    4. Variations
    5. Texture Mat
    6. Pixel Processor Ray tracer
  6. Setup and Getting Started
    1. Setup and Getting Started overview
    2. Compatibility
    3. Frequently asked Questions
    4. Known issues
    5. SAT Cookbook
    6. Use Pysbs in different python interpreter (maya, sd, blender...)
  7. Integrations
    1. Substance Maya toolset
      1. Substance Maya Toolset overview
      2. Installing
      3. Launching
      4. Baking
        1. Baking overview
        2. Export parameters
        3. Baker parameters
        4. Mesh setup
        5. Using a template
      5. Changelog
  8. Changelog overview

ag_functions

Module ag_functions provides the definition of the classes FunctionContext, used for making it simpler to define functions using the ag_types classes.

 class autograph.ag_functions.FunctionContext(doc, fn_node=None, name=None, use_constant_cache=True, layout_nodes=True, remove_unused_nodes=True)  

Bases: object

Class helping out generating functions by keeping track of the document and the root node in which the construction happens

 input_parameter(name, widget_type)  

Creates an input parameter for the graph and returns the node for accessing it.

Parameters:
  • name (string) – The name of the input parameter
  • widget_type (WidgetEnum) – The type with its visual representation
Returns:

Type

 variable(self, name, widget_type, use_param_type=False)  

Creates a reference to a variable in the graph and returns the node for accessing it.

Parameters:
  • name (string) – The name of the input parameter
  • widget_type (WidgetEnum) – The type with its visual representation
  • use_param_type (bool) – use ParamTypeEnum instead of WidgetEnum
Returns:

Type

 constant(constant, t=None)  

Creates a constant

Parameters:
  • constant (int, bool, float, [int], [float]) – The constant value
  • t (None or a class such as Float3) – Type constructor None means autodetect
Returns:

Type

 import_external_function(path)  

Imports a function from the same document as the function is created in

Parameters:path (string) – Path to function to import
Returns:Type the node representing the imported function
 import_local_function(name)  

Imports a function from an external file

Parameters:name (string) – Name of function to import
Returns:Type the node representing the imported function
 generate(output_node)  

Finalizes function generation.

Parameters:output_node (Type) – The node that is the return value
Returns:Type the output node
 dot(a, b)  

Dot product

Parameters:
  • a (FloatType, float or list of float) – input parameter 1
  • b (FloatType, float or list of float) – input parameter 2
Returns:

Float1

 sqrt(a)  

Sqrt

Parameters:a (FloatType, float or list of float) – input parameter 1
Returns:FloatType
 atan2(a)  

Atan2

Parameters:a (FloatType, float or list of float) – input parameter 1
Returns:FloatType
 abs_of(a)  

Modulus, or Absolute value, of a.

Parameters:a (FloatType, float or list of float) – input parameter 1
Returns:FloatType
 log(a)  

Log

Parameters:a (FloatType, float or list of float) – input parameter 1
Returns:FloatType
 exp(a)  

Exp

Parameters:a (FloatType, float or list of float) – input parameter 1
Returns:FloatType
 log2(a)  

Log2

Parameters:a (FloatType, float or list of float) – input parameter 1
Returns:FloatType
 pow2(a)  

Pow2

Parameters:a (FloatType, float or list of float) – input parameter 1
Returns:FloatType
 floor(a)  

Floor

Parameters:a (FloatType, float or list of float) – input parameter 1
Returns:FloatType
 ceil(a)  

Ceil

Parameters:a (FloatType, float or list of float) – input parameter 1
Returns:FloatType
 cos(a)  

Cos

Parameters:a (FloatType, float or list of float) – input parameter 1
Returns:FloatType
 sin(a)  

Sin

Parameters:a (FloatType, float or list of float) – input parameter 1
Returns:FloatType
 tan(a)  

Tan

Parameters:a (FloatType, float or list of float) – input parameter 1
Returns:FloatType
 rand(a)  

Rand

Parameters:a (FloatType, float or list of float) – input parameter 1
Returns:FloatType
 cartesian(a, b)  

Cartesian

Parameters:
  • a (FloatType) – input parameter 1, float or list of float
  • b (FloatType) – input parameter 2, float or list of float
Returns:

Float2

 max_of(a, b)  

Maximum of a and b

Parameters:
  • a (VectorType, int, float, list of float or list of int) – input parameter 1
  • b (VectorType, int, float, list of float or list of int) – input parameter 2
Returns:

VectorType

 maximum(*values)  

Maximum value of the values

Parameters:values (VectorType, int, float, list of float or list of int) – input values
Returns:VectorType
 min_of(a, b)  

Minimum of a and b

Parameters:
  • a (VectorType, int, float, list of float or list of int) – input parameter 1
  • b (VectorType, int, float, list of float or list of int) – input parameter 2
Returns:

VectorType

 minimum(*values)  

Minimum value of the values

Parameters:values (VectorType, int, float, list of float or list of int) – input values
Returns:VectorType
 clamp(a, b, x)  

Clamp value x between a and b.

Parameters:
  • a (VectorType, int, float, list of float or list of int) – min value of clamped x
  • b (VectorType, int, float, list of float or list of int) – max value of clamped x
  • x – value to clamp
Returns:

VectorType

 lerp(a, b, x)  

Lerp

Parameters:
  • a (FloatType, float or list of float) – input parameter 1
  • b (FloatType, float or list of float) – input parameter 2
  • x (Float1 or float) – lerp position
Returns:

FloatType

 swizzle_float1(src, out_vars)  

Swizzle Float1

Parameters:
  • src – input parameter
  • srcFloatType, float or list of float
  • out_vars (list of int) – Output variable index
Returns:

Float1

 swizzle_float2(src, out_vars)  

Swizzle Float2

Parameters:
  • src – input parameter
  • srcFloatType, float or list of float
  • out_vars (list of int) – Output variable indices
Returns:

Float2

 swizzle_float3(src, out_vars)  

Swizzle Float3

Parameters:
  • src – input parameter
  • srcFloatType, float or list of float
  • out_vars (list of int) – Output variable indices
Returns:

Float3

 swizzle_float4(src, out_vars)  

Swizzle Float4

Parameters:
  • src – input parameter
  • srcFloatType, float or list of float
  • out_vars (list of int) – Output variable indices
Returns:

Float4

 swizzle_int1(src, out_vars)  

Swizzle Int1

Parameters:
  • src – input parameter
  • srcIntType, int or list of int
  • out_vars (list of int) – Output variable indices
Returns:

Int1

 swizzle_int2(src, out_vars)  

Swizzle Int2

Parameters:
  • src – input parameter
  • srcIntType, int or list of int
  • out_vars (list of int) – Output variable indices
Returns:

Int2

 swizzle_int3(src, out_vars)  

Swizzle Int3

Parameters:
  • src – input parameter
  • srcIntType, int or list of int
  • out_vars (list of int) – Output variable indices
Returns:

Int3

 swizzle_int4(src, out_vars)  

Swizzle Int4

Parameters:
  • src – input parameter
  • srcIntType, int or list of int
  • out_vars (list of int) – Output variable indices
Returns:

Int4

 expand_to_int2(src, fill)  

Expands a Int1 to Int2

Parameters:
  • src (Int1 or int) – source vector
  • fill (IntType, int or list of int) – What to fill the empty values with
Returns:

Int2

 expand_to_int3(src, fill)  

Expands a Int1 or Int2 to Int3

Parameters:
  • src (IntType, int or list of int) – source vector
  • fill (IntType, int or list of int) – What to fill the empty values with
Returns:

Int3

 expand_to_int4(src, fill)  

Expands a Int1, Int2 or Int3 to Int4

Parameters:
  • src (IntType, int or list of int) – source vector
  • fill (IntType, int or list of int) – What to fill the empty values with
Returns:

Int4

 expand_to_float2(src, fill)  

Expands a Float1 to Float2

Parameters:
  • src (Float1 or float) – source vector
  • fill (FloatType, float or list of float) – What to fill the empty values with
Returns:

Float2

 expand_to_float3(src, fill)  

Expands a Float1 or Float2 to Float3

Parameters:
  • src (FloatType, float or list of float) – source vector
  • fill (FloatType, float or list of float) – What to fill the empty values with
Returns:

Float3

 expand_to_float4(src, fill)  

Expands a Float1, Float2 or Float3 to Float4

Parameters:
  • src (FloatType, float or list of float) – source vector
  • fill (FloatType, float or list of float) – What to fill the empty values with
Returns:

Float4

 expand(*vectors)  

Expand two vector to a vector of the appropriate type and dimension.

The sum of the dimension of the input vectors must not be larger than 4. Plus all input vectors must be integers or all input vectors must be float.

Parameters:vectors (VectorType, int, float, list of int, list of float) – vectors to concatenate
Returns:VectorType
 cast_to_float1(src)  

Casts an Int1 to Float1

Parameters:src (Int1 or int) – source
Returns:Float1
 cast_to_float2(src)  

Casts an Int2 to Float2

Parameters:src (Int2 or list of int) – source
Returns:Float2
 cast_to_float3(src)  

Casts an Int3 to Float3

Parameters:src (Int3 or list of int) – source
Returns:Float3
 cast_to_float4(src)  

Casts an Int4 to Float4

Parameters:src (Int4 or list of int) – source
Returns:Float4
 auto_cast_to_float(src)  

Casts a numeric vector to a float vector of the same dimension

Parameters:src (IntType, int or list of int) – source vector
Returns:FloatType
 cast_to_int1(src)  

Casts a Float1 to Int1

Parameters:src (Float1 or float) – source
Returns:Int1
 cast_to_int2(src)  

Casts a Float2 to Int2

Parameters:src (Float2 or list of float) – source
Returns:Int2
 cast_to_int3(src)  

Casts a Float3 to Int3

Parameters:src (Float3 or list of float) – source
Returns:Int3
 cast_to_int4(src)  

Casts a Float4 to Int4

Parameters:src (Float4 or list of float) – source
Returns:Int4
 auto_cast_to_int(src)  

Casts a numeric vector to an Int vector of the same dimension

Parameters:src (FloatType float or list of float) – source vector
Returns:IntType
 if_else(condition, value_on_true, value_on_false)  

Choose one of two values based on a condition

Parameters:
  • condition (Boolean or bool) – The condition to select on
  • value_on_true (VectorType, float, int, list of float or list of int) – Return value for true
  • value_on_false (VectorType, float, int, list of float or list of int) – Return value for false
Returns:

VectorType

 seq(a, b)  

Execute all nodes resulting in branch a then execute all nodes resulting in branch b. Outputs the output of branch b.

Parameters:
  • a (Type) – input sequence 1
  • b (Type) – input sequence 2
Returns:

Type

 sequence(*values)  

Execute all nodes in sequence and output the output of the last input.

Parameters:values (Type) – input sequences
Returns:Type
 set_var(a, name)  

Set a variable name to the give value.

Parameters:
  • a (Type, bool, int, float, list of int or list of float) – value to set
  • name (str) – name of the set value
Returns:

Type

 create_color_sampler(pos, input_index)  

Creates a color sampler

Parameters:
  • pos (Float2 or list of float) – Point to sample
  • input_index (int) – Index of input to sample from
  • filtering_mode (FilteringEnum) – Filter to use for the sampler
Returns:

Float4

 create_gray_sampler(pos, input_index)  

Creates a gray scale sampler

Parameters:
  • pos (Float2 or list of float) – Point to sample
  • input_index (int) – Index of input to sample from
  • filtering_mode (FilteringEnum) – Filter to use for the sampler
Returns:

Float1

 create_passthrough(src)  

passthrough(src) Create a PassThrough (dot) node function

Parameters:src (Type, any class that inherits Type) – source
Returns:SBSFunction
 normalize(a)  

Normalize a vector

Parameters:a (FloatType or list of float) – Vector to normalize
Returns:FloatType
 autograph.ag_functions.generate_function(fn, doc, fn_node=None, name=None, layout_nodes=True, remove_unused_nodes=True)  

Generates a function by calling back to the generator function

Parameters:
  • fn (Python function, taking as unique parameter a FunctionContext) – Function taking a FunctionContext as input that generates the actual operations
  • doc (SBSDocument) – The document to create the network in
  • fn_node (SBSDynamicValue) – A function node in which the function should be created, must be None if the name is not None
  • name (string) – Name of the function to be created. Must be None if fn_node is not None
  • layout_nodes (bool) – Whether the nodes should be laid out left to right
  • remove_unused_nodes (bool) – Whether nodes not connected to the output node should be removed. Only works if layout_nodes is true
Returns:

function to call to create node

Get help faster and easier

New user?