Textures

textures

createFileTexture(name='file', colorSpace='sRGB', imagePath='', ignoreColorSpace=False)

creates a file (texture) node with the place2dTextureNode and all connections

Parameters:
  • name (str) – The name of the file node, the place2dTextureNode is suffixed with “_place3dTex”

  • colorSpace (str) – the default color space of the file node “sRGB”, “Raw” etc

  • imagePath (str) – the optional image path for the texture, not yet connected

  • ignoreColorSpace (bool) – Ignores colour space warning, useful for Raw which always complains if using tif ect.

Return fileNode:

the name of the created file node

Rtype fileNode:

str

Return place2dTextureNode:

the name of the created place2dTextureNode

Rtype place2dTextureNode:

str

getTextureFileAttributeName(nodeType)

returns the attribute name for setting the file texture path of the given nodeType Searches through all supported shaders in a dict and returns the corresponding attribute

Parameters:

nodeType (str) – the type of a supported texture node

Return attributeName:

the attribute name for the disk file path texture

Return type:

str

getTexureNodeType(node)

Returns the texture node type, will be None if it’s not a recognised texture node

Parameters:

node (str) – a maya node name

Returns:

the type of texture node, or None if it’s not a legimate texture node

Return type:

getTexturePathCheckNode(textureNode)

Gets the texture path from a given texture node. Checks if the node type is a correct texture node Supports texture nodes from TEXTURENODEDICT If the node is not legitimate return None, note a legitimate return is an empty string

Parameters:

textureNode (str) – maya node name, should be a texture node recognised by the dict TEXTURENODEDICT

Return filePath:

the full filepath from the texture

Rtype filePath:

str

getFileTextureNameFromAttr(nodeName, attributeName)

Finds the texturePath of a texture node from a given attribute ie “file1.color” Is compatible with texture nodes in TEXTURENODEDICT Checks the node type to be a legitimate texture

Parameters:
  • nodeName (str) – maya node name, should be a texture node recognised by the dict TEXTURENODEDICT

  • attributeName (str) – the attribute name that the node is connected to a texture node

Return filePath:

Rtype filePath:

setTexturePath(textureNode, nodeType, texturePath)

If the textureNode and nodeType is known set the texturePath Works on any supported texture

Parameters:
  • textureNode (str) – the texture node’s name

  • nodeType (str) – the texture nodes type

  • texturePath (str) – the full file path of the texture on disk

Return attributeName:

the attribute name set

Rtype attributeName:

str

setTexturePathCheckNode(textureNode, texturePath)

Smart function that checks the node and assigns a texture file path to the node. Returns None if no legit nodes found

Parameters:
  • textureNode (str) – the texture node’s name

  • texturePath (str) – the full file path of the texture on disk

Return fileTextureName:

the attribute name set, None if not found

Rtype fileTextureName:

str

setFileTextureFromAttr(nodeName, attributeName, texturePath)

From a given current node and current node attribute ie plasticShader.color, find a connected texture node and set a new texture file path on disk.

Parameters:
  • nodeName (str) – the name of the node to search from, eg “plasticShader”

  • attributeName (str) – the attribute name to search from eg “color”

Return fileTextureName:

If found the connected texture node name, None if no node was found

Rtype fileTextureName:

str

buildConnectTextureNodeAttribute(nodeName, nodeAttribute, textureNodeName='fileText', nodeType='file', texturePath=None, colorSpace='sRGB', asAlpha=False)

Builds a texture node and connects from the given nodeName and nodeAttribute eg plasticShader.color > new created texture node Can assign a texture path Node types can be any supported nodes from TEXTURENODES list Texture can be multiple channels (color) asAlpha=False or single channel asAlpha=True (scalar)

Parameters:
  • nodeName (str) – current maya node’s name, this node will connect to the new texture node

  • nodeAttribute (str) – attribute of the current maya node to connect to the new texture

  • textureNodeName (str) – the name of the texture node to be created

  • nodeType (str) – the type of node to be created, eg “file”

  • texturePath (str) – the disk texture path of the texture to be assigned, None if none.

  • colorSpace (str) – the color space of the texture “sRGB” linear etc.

  • asAlpha (bool) – if True then connect as a single channel not as color (multiple channels)

Return createNodes:

the created node list

Return type:

list

setOrCreateFileTexturePath(nodeName, attributeName, texturePath, textureNodeName='fileText', nodeType='file', colorSpace='sRGB', asAlpha=False)

Sets the texture file path from a given node.attribute, usually a shader eg. shader plasticShader.color This function finds the connected texture node, if it’s supported sets the texture If no texture node is found. The function creates a texture node of the given type and sets the texture path returns a warning (if True could not set the connected node) and created nodes if nodes were created Node types can be any supported nodes from TEXTURENODES list Texture can be multiple channels (color) asAlpha=False or single channel asAlpha=True (scalar)

Parameters:
  • nodeName (str) – current maya node’s name, this node will connect to the new texture node

  • attributeName (str) – attribute of the current maya node to connect to the new texture

  • texturePath (str) – the disk texture path of the texture to be assigned, None if none.

  • textureNodeName (str) – the name of the texture node to be created

  • nodeType (str) – If a texture needs to be created this is the type of texture node to create

  • colorSpace (str) – the color space of the texture “sRGB” “Raw” etc.

  • asAlpha (bool) – if True then connect as a single channel not as color (multiple channels)

Return warning:

a warning, if True something is connected but it’s not a fileTexture

Rtype warning:

bool

Return createdNodes:

the created nodes as a list if any were created

Rtype createdNodes:

list