Assets

Assetsimportexport

Zoo Asset Code

Todo

  • List assets in the scene just print is ok for starters.

  • Add asset list to “manage asset in scene”, should be a selectable list.

  • Delete ibl textures.

  • Lights won’t delete hdri textures for arnold and deleting shaders won’t delete any textures assigned should fix in.

light manager then return the nodes here for the assets

getPluginAbcLoaded()

Returns the state of the two plugins, AbcImport and AbcExport

:return abcImportLoaded, abcExportLoaded, The state, True/False of the abcImport and abcExport plugin. :rtype tuple[bool, bool]

loadAbcPlugin(message=True)

Loads the AbcImport and AbcExport plugins

Parameters:

message (bool) – return the message to the user

getAssetNode(objList)

Returns a list of asset nodes from the given objects for each object find if it has an asset node attached

Parameters:

objList (str) – list of maya object names.

Returns:

list of unique asset nodes connected to the objects.

Return type:

list[str]

getAssetFromSelection()

returns a list of asset nodes from the selected objects

Return assetNodes:

list of unique asset nodes connected to the objects

Rtype assetNodes:

list

getAssetFromSelectionOrUI(uiSelectedName='', message=True)

returns a list of asset nodes from the selected objects If none found then tries to find based off a UI selection name For each object find if it has a asset node attached

Parameters:
  • uiSelectedName (str) – the name of the package asset usually selected in the UI

  • message (bool) – report the message to the user?

Return assetNodes:

list of unique asset nodes connected to the objects

Rtype assetNodes:

list

removeAssetNodeSelected()

deletes asset nodes from assets, these network nodes are what tracks the characters

Return assetNodes:

The asset nodes (Network Nodes) in the scene that were deleted

Rtype assetNodes:

getAssetGroup(assetNodes)

returns an asset group list given the asset node list

Parameters:

assetNodes (list) – list of unique asset nodes

Return assetGrps:

list of unique asset group names connected to the given assetNodes

Rtype assetGrps:

list

getAssetGrpsSelected()

returns an asset group list from selected objs

Return assetGrps:

list of unique asset group names connected to the given selected objs

Rtype assetGrps:

list

findAssetGrpsSelectedOrUI(uiSelectedName='', message=True)

Finds assets grps with priority to the selected objects (getAssetGrpsSelected()) If none are selected or found then try from the uiSelectedName which is usually the name of the package selected in the browser UI

Parameters:
  • uiSelectedName (str) – the name of the package asset usually selected in the UI

  • message (bool) – report the message to the user

Return assetGrps:

list of maya objects, usually grp transform names

Rtype assetGrps:

list

createAssetGrps(assetName)

creates the asset groups, one scene asset grp if it doesn’t exist and the other custom named asset grp

Parameters:

assetName (str) – the prefix of the asset group name

Return assetGrpLongName:

the long name of the asset group, no need to pass the other group as its ZOOSCENEGRPNAME

Rtype assetGrpLongName:

str

createAssetFromSelection(newAssetName, message=True)

Creates a new asset from selection, creates a new asset grp from the name given and copies it to the ZOOSCENEGRPNAME creates a network node that connects to all the children and grandchildren of selected and shaders

Parameters:
  • newAssetName (str) – the name of the new asset, may be in use and will be unique

  • message (True) – Would you like the user to see the message in Maya

Return allObjects:

all nodes connected to the networkNodeName

Rtype allObjects:

list

Return networkNodeName:

the network asset node name that connects to all asset objects and nodes

Rtype networkNodeName:

str

loopAbcMeshSelection(cycleInt=1)

from the current selection set the alembic cache/s to the cycle type

Parameters:

cycleInt (int) – the integer of the attribute cycleType 0 Hold 1 is Loop 2 is Reverse 3 is Bounce

Return alembicNodeList:

the alembic nodes changed

Rtype alembicNodeList:

list

loopAbcSelectedAsset(cycleInt=1, uiSelectedName='', message=True)

Loops a selected alembic node from the asset nodes, or the given cycle type

Parameters:
  • cycleInt (int) – the integer of the attribute cycleType 0 Hold 1 is Loop 2 is Reverse 3 is Bounce

  • uiSelectedName (str) – the name of the package asset usually selected in the UI

  • message (bool) – report the message to the user?

Return alembicNodeList:

the alembic nodes changed

Rtype alembicNodeList:

list

scaleRotateAssetSelected(scaleValue, rotYValue, uiSelectedName='', message=True)

Scales the selected package asset’s grp to the scale and rotY value

Parameters:
  • scaleValue (float) – the scale value of the asset package grp on x y and z

  • rotYValue (float) – the rot y value of the asset package grp

  • uiSelectedName (str) – the name of the asset grp to try if the selection method fails

  • message (bool) – show the success message to the user?

createTurntableAssetSelected(startFrame=0, endFrame=200, angleOffset=0, setTimerange=True, uiSelectedName='', reverse=False, message=True)

Creates a turntable on an asset from object selection, auto finds the asset group and animates it

Parameters:
  • startFrame (float) – the start frame of the turntable

  • endFrame (float) – the end frame of the turntable

  • angleOffset (float) – the angle offset of the keyframes in degrees, will change the start rotation of the asset

  • setTimerange (bool) – will change mayas timerange to match to the start and end frames

  • uiSelectedName (str) – the name of the asset grp to try if the selection method fails

  • reverse (bool) – reverses the spin direction

  • message (bool) – report the messages to the user in Maya?

Return assetGrps:

the group/s now with animation

Rtype assetGrps:

list

deleteTurntableAssetSelected(attr='rotateY', message=True, returnToZeroRot=True, uiSelectedName='')

Deletes a turntable anim of an asset. auto finds the asset group and deletes the anim on rot y

Parameters:
  • attr (str) – the attribute to delete all keys

  • message (bool) – report the messages to the user in Maya?

  • returnToZeroRot (bool) – return the object to default zero?

  • uiSelectedName (str) – the name of the asset grp to try if the selection method fails

Return assetGrps:

the group/s now with animation

Rtype assetGrps:

list

deleteAssetNodeList(zooAssetNodeList)

For the Maya scene deletes multiple package asset nodes and their connections

Parameters:

zooAssetNodeList – a list of asset nodes who’s connections need to be deleted

deleteZooAssetObjList(objList)

Deletes (in the Maya scene) package assets that are connected to the asset nodes of the objList

Parameters:

objList (list) – list of Maya objects

Return assetNodes:

list of asset nodes (all their connections will be deleted)

Rtype assetNodes:

list

selectZooAssetGrps(message=True, uiSelectedName='')

Selects all package asset grps from selected, if none found then tries from the UI selection

Parameters:
  • message (bool) – report the message to the user?

  • uiSelectedName (str) – the name of the package asset usually selected in the UI

Return assetGrps:

The asset grps selected

Rtype assetGrps:

deleteZooAssetSelected(uiSelectedName='', message=True)

Deletes (in the Maya scene) package assets that are connected to the asset nodes of the selected objects/UI First it tries to find asset grps from selected, then tries from the wildcard uiSelectedName_package_grp* If finds the grps then deletes everything in all the connected package assets

Parameters:
  • message (bool) – report the message to the user?

  • uiSelectedName (str) – the name of the package asset usually selected in the UI

Return assetNodes:

list of asset nodes (all their connections will be deleted)

Rtype assetNodes:

list

deleteZooAssets(onlyInAssetsGrp=False)

Deletes all package asset nodes and their connections in a scene Or if onlyInAssetsGrp then delete only assets in that grp

Parameters:

onlyInAssetsGrp (bool) – keep assets outside of the main asset grp

Return deleteAssetNodeList:

list of asset nodes who’s connections have been deleted

Rtype deleteAssetNodeList:

list

tagAssetAsType(assetNode, assetType)

tags an asset node and sets the assetType attibute with a string

Parameters:
  • assetNode (str) – the network asset node that connects to assets in the scene

  • assetType (str) – The type of asset as per the list ASSETTYPES… “Not Specified”, “Hero Model”, “Prop Model” etc

tagAssetAsTypeObjectList(objectList, assetType)

tags the asset nodes of an object list to the assetType

Parameters:
  • objectList (list) – the maya object name list

  • assetType (str) – The type of asset as per the list ASSETTYPES… “Not Specified”, “Hero Model”, “Prop Model” etc

Return assetNodes:

the assetNodes now tagged

Rtype assetNodes:

list

tagAssetAsTypeSelection(assetType, message=True)

tags the asset nodes of selected objects and sets them to the assetType

Parameters:
  • assetType (str) – The type of asset as per the list ASSETTYPES… “Not Specified”, “Hero Model”, “Prop Model” etc

  • message (bool) – report the message to the user?

Return assetNodes:

the assetNodes now tagged

Rtype assetNodes:

list

getAssetTypeFile(filePathZooScene)

gets the asset type from a zooScene file, will auto find the .zooInfo file

Parameters:

filePathZooScene (str) – full path to the zooscene file

Return assetType:

The type of asset as per the list ASSETTYPES… “Not Specified”, “Hero Model”, “Prop Model” etc

Rtype assetType:

str

getAllAssetNamesInTheScene()

gets all the asset names in the scene by finding the network asset nodes and getting their grp and removing the suffix

Return zooAssetNames:

current asset names in the scene

Rtype zooAssetNames:

list

getAllAssetsInSceneOfType(assetType)

Gets all asset network nodes in the scene of this assetType, get this from an attribute on the node Some assets may have no attribute and are therefor the type “Not Specified”

Parameters:

assetType (str) – The type of asset as per the list ASSETTYPES… “Not Specified”, “Hero Model”, “Prop Model” etc

Return assetNodeOfTypeList:

list of network nodes that are of the given type

Rtype assetNodeOfTypeList:

list

importZooSceneNoParent(filePathZooScene, rendererNiceName, assetName, importShaders=True, importLights=True, importAbc=True, replaceShaders=True, addShaderSuffix=True, importSubDInfo=True, replaceRoots=False)

Imports the asset without parenting to the asset group

Parameters:
  • filePathZooScene (str) – full path to the zooscene file

  • rendererNiceName (str) – the renderer nice name “Arnold”

  • assetName (str) – the name of the asset for the network node name

  • importShaders (bool) – import shaders into the scene?

  • importLights (bool) – import lights into the scene?

  • importAbc (bool) – import alembic into the scene?

  • replaceShaders (bool) – replace/overwrite existing shaders?

  • addShaderSuffix (bool) – add a shader suffix to the end of each shader and light to match the renderer?

  • importSubDInfo (bool?) – import the subd settings which isn’t contained in the alembic and auto apply after import

  • replaceRoots (bool) – replace the root/base hierarchy objects in maya, will delete and remake the root objects.

Return allNodes:

all nodes built, not the network node

Return type:

list

Return networkNodeName:

the node network name created

Return type:

str

importZooSceneAsAsset(filePathZooScene, rendererNiceName, replaceAssets=True, importAbc=True, importShaders=True, importLights=False, replaceShaders=True, addShaderSuffix=True, importSubDInfo=True, replaceRoots=True, turnStart=0, turnEnd=0, turnOffset=0, loopAbc=False, replaceByType=False, scaleOffset=1.0, rotYOffset=0.0)

Imports a .zoo scene with checks and replace options, and auto group creation for zooAssets.

Parameters:
  • filePathZooScene (str) – full path to the zooscene file

  • rendererNiceName (str) – the renderer nice name “Arnold”

  • replaceAssets

  • importShaders (bool) – import shaders into the scene?

  • importLights (bool) – import lights into the scene?

  • importAbc (bool) – import alembic into the scene?

  • replaceShaders (bool) – replace/overwrite existing shaders?

  • addShaderSuffix (bool) – add a shader suffix to the end of each shader and light to match the renderer?

  • importSubDInfo (bool?) – import the subd settings which isn’t contained in the alembic and auto apply after import

  • replaceRoots (bool) – replace the root/base hierarchy objects in maya, will delete and remake the root objects.

  • turnStart (int) – The start frame for a spinning animated turntable

  • turnEnd (int) – The end frame for a spinning animated turntable

  • turnOffset (float) – The angle offset for the start of the turntable in degrees

  • replaceByType (bool) – deletes existing assets which match the type stored in the info file

  • scaleOffset (float) – the scale value of the asset package grp on x y and z

  • rotYOffset (float) – the rot y value of the asset package grp

Return allNodes:

all nodes built, including the network node

Return type:

list

getAssetRoots()

Gets all the asset groups in a scene and return them as a long name list.

Returns:

A list of asset root objects, zooAsset_grp and “*_asset_grp” with long names.

Return type:

list[str]

removeAssetRootsFromAlembicRoots(alembicRoots)

Removes the asset nodes the organising groups from being exported automatically. The groups are the zooAssets grp and each asset grp Finds the asset nodes in the scene and if they are scene roots find legitimate children to export instead.

Parameters:

alembicRoots (list) – roots of the alembic export as specified by the user

Returns:

roots of the alembic export actually exported ignoring asset folders

Return type:

list[str]

saveAsset(fullFilePath, rendererNiceName, exportSelected=False, exportShaders=True, exportLights=True, exportAbc=True, noMayaDefaultCams=True, exportGeo=True, exportCams=True, exportAll=False, dataFormat='ogawa', frameRange='', visibility=True, creases=True, uvSets=True, exportSubD=True)

same as exportAbcGenericShaderLights only this function checks for asset node grps and tries to auto filter them out.

getAssetPresetDict(filename='assetspresets.json')

Retrieves the .zooScene preset dictionary from the .json file The preset dictionary only contains the file paths of the .zooScene assets

Parameters:

filename (str) – the name of the assetsPreset.json file

Return presetAssetFilePathDict:

The asset preset dictionary, contains mostly the file path info of files

Rtype presetAssetFilePathDict:

dict

writeAssetPresetDict(presetAssetFilePathDict)

Writes the selected asset to a zooScene .zooScene file and also Alembic .abc

Parameters:

presetAssetFilePathDict (dict) – The incoming .json dictionary with file path info, directories etc

listFileQuickDir()

Lists all the json files inside of the “fileQuickDir”

Return fileList:

List of the assets inside of the assetQuickDir

Rtype fileList:

list

Return fileQuickDir:

The file path of the asset directory

Rtype fileQuickDir:

str

deleteQuickDirZooScene(filePath)

Deletes a zooscene file

Return filesFullPathDeleted:

a list of the files deleted full file path

Rtype filesFullPathDeleted:

list

Assetspresets

Sets the Default Directories for the assetPresets.json

Defaultassets

Module related to default internal assets included withing the Zoo Tools Pro scripts folder. Light Presets, HDRI skydome texture paths, control curves etc.

from zoo.libs.maya.cmds.assets import defaultassets
defaultassets.importLightPresetAutoRenderer()

Author Andrew Silke

importZooSceneDefault(fullPath, renderer, replaceByType=False)

Imports a zoo scene file with default settings for the current renderer

Parameters:
  • fullPath (str) – The fullpath to the .zooScene file

  • renderer (str) – The renderer nicename to set the lights and shaders for

  • replaceByType (str) – Will replace assets by type and delete previous shaders of the same name

renderStatsAttrs(geoShape, castsShadows=None, receiveShadows=True, holdOut=None, motionBlur=None, primaryVisibility=None, smoothShading=None, visibleInReflections=None, visibleInRefractions=None, doubleSided=None, opposite=None)

Sets attribute values for the render stats on an object’s shape node

Parameters:

geoShape (list(str)) – A geometry shape node name

renderStatsAttrsList(geoShapeList, castsShadows=None, receiveShadows=True, holdOut=None, motionBlur=None, primaryVisibility=None, smoothShading=None, visibleInReflections=None, visibleInRefractions=None, doubleSided=None, opposite=None)

Sets attribute values for the render stats on an object’s shape node

Parameters:

geoShapeList (list(str)) – A list of geometry shape nodes

createDefaultCamera(type='default')

Creates a default camera for scenes based on the type

type:

CAMTYPE_DEFAULT = “default” CAMTYPE_HDR = “hdr” CAMTYPE_CONTROL = “control”

Parameters:

type (str) – The type of asset the camera is for, “default”, “hdr”, “control”

Return cameraTransform:

The camera transform node name

Rtype cameraTransform:

str

Return cameraShape:

The camera shape node name

Rtype cameraShape:

str

setCameraResolution(cameraShape='cameraShape1', width=520, height=520, clipPlanes=(0.9, 5000.0), antiAlias=True, grid=False, setRes=True)

Sets the camera film gate and scene resolution (render globals render image width height)

Also sets up the display of the camera clip planes and anti aliasing

Parameters:
  • cameraShape (str) – The name of the camera shape node

  • width (int) – The width in pixels of the render globals render image size

  • height (int) – The height in pixels of the render globals render image size

  • clipPlanes (tuple(int)) – The viewport display clipping planes

  • antiAlias (bool) – Anti alias the viewport?

  • grid (bool) – Show the grid in the viewport?

importLightPreset(renderer='Arnold', lightPresetPath='E:\\code\\python\\personal\\zootoolspro\\install\\packages\\zoo_maya\\1.7.40\\preferences\\assets\\light_suite_light_presets\\fPumps.zooScene', hdrImage='factPumps_g.hdr', showIbl=False, hdrIntMult=1.0, hdrRotOffset=0.0, message=False)

Import a light preset from a folder path and image with basic kwargs.

Parameters:
  • renderer (str) – The renderer nicename to set the lights and shaders for

  • lightPresetPath (str) – The full path to the folder of the light presets

  • hdrImage (str) – The HDR Image name with extension

  • showIbl (bool) – Render the Skydome in the background?

importLightPresetAutoRenderer(internalLightDict={'hdriPath': 'E:\\code\\python\\personal\\zootoolspro\\install\\packages\\zoo_maya\\1.7.40\\preferences\\assets\\light_suite_ibl_skydomes\\factPumps_g.hdr', 'intMult': 4.0, 'path': 'E:\\code\\python\\personal\\zootoolspro\\install\\packages\\zoo_maya\\1.7.40\\preferences\\assets\\light_suite_light_presets\\aDflt.zooScene', 'rotOffset': 154.1}, showIbl=False, message=True)

Import a light preset from a folder path and image with basic kwargs. Automatically uses the Zoo set renderer

multirenderersettings.currentRenderer()

Parameters:
  • internalLightDict (dict) – The full path to the folder of the light presets,see assetsconstants.PRESET_DEFAULT

  • showIbl (bool) – Render the Skydome in the background?

  • message (bool) – Report a message to the user

buildDefaultLightSceneCyc(renderer='Arnold', lightPresetPath='E:\\code\\python\\personal\\zootoolspro\\install\\packages\\zoo_maya\\1.7.40\\preferences\\assets\\light_suite_light_presets\\fPumps.zooScene', message=True)

Builds a default Light Presets scene for thumbnail rendering

Parameters:
  • renderer (str) – The renderer nicename to set the lights and shaders for

  • lightPresetPath – The full path to the .zooScene file

  • message (bool) – Report messages to the user?

buildDefaultHDRIScene(renderer='Arnold', message=True)

Builds a default HDRI Skydome scene for thumbnail rendering

Parameters:
  • renderer (str) – The renderer nicename to set the lights and shaders for

  • message (bool) – Report messages to the user?

buildDefaultAssetsSceneCyc(renderer='Arnold', assetDirPath='E:\\code\\python\\personal\\zootoolspro\\install\\packages\\zoo_maya\\1.7.40\\preferences\\assets\\model_assets', assetZooScene='bgCycDrk.zooScene', lightPresetPath='E:\\code\\python\\personal\\zootoolspro\\install\\packages\\zoo_maya\\1.7.40\\preferences\\assets\\light_suite_light_presets\\aDflt.zooScene', hdrImage='factPumps_g.hdr', hdrIntMult=1.0, hdrRotOffset=0.0, buildCamera=True, buildBot=False, setRes=True, replaceByType=False, setDefaultRenderSet=True, darkShader=True, message=True)

Builds a default Model Assets scene for thumbnail rendering

Parameters:
  • renderer (str) – The renderer nicename to set the lights and shaders for

  • message (bool) – Report messages to the user?

buildDefaultShaderSceneCyc(renderer='Arnold', message=True)

Builds a default Shader Preset scene for thumbnail rendering

Parameters:
  • renderer (str) – The renderer nicename to set the lights and shaders for

  • message (bool) – Report messages to the user?

buildDefaultControlsScene(message=True)

Builds a default Control Shape scene for thumbnail rendering

Parameters:

message (bool) – Report messages to the user?