Shapelib¶
This module holds utility methods for dealing with nurbscurves
- exception MissingShapeFromLibrary¶
Bases:
Exception
- clearShapeCache()¶
- iterShapeRootPaths()¶
Generator function which iterates the root location based on the environment variable “ZOO_LIB_PATH”
- Returns
Each absolute path to each shape root directory.
- Return type
generator(str)
- iterShapePaths()¶
Iterator function which loops all the *.shape paths.
- Returns
Generator with each element == absolute path.shape
- Return type
generator(str)
- iterAvailableShapesNames()¶
Generator function for looping over all available shape names
Shapes are sourced from all the set root locations specified by the “ZOO_LIB_PATH” environment variable
- Returns
An Iterate which returns each shape Name
- Return type
Generator(str)
- shapeNames()¶
List all the curve shapes (design/patterns) available.
Shapes are sourced from all the set root locations specified by the “ZOO_LIB_PATH” environment variable
- Return shapeNames
a list of curve designs (strings) available
- Rtype shapeNames
list(str)
- findShapePathByName(shapeName)¶
Find’s the absolute shape path based on the shape name
..code-block: python
shapePath = findShapePathByName(“cube”) # result: rootFolderzoolibsshapelib__init__.py
- loadFromLib(shapeName)¶
Loads the data for the given shape Name
- Parameters
shapeName (str) – The shape name from the library, excluding the extension, see shapeNames()
- Returns
A 2 tuple the first element is the MObject of the parent and the second is a list of mobjects represents the shapes created.
- Return type
tuple[
om2.MObject, list(:class:`om2.MObject
))- Raises
ValueError
- loadAndCreateFromLib(shapeName, parent=None, mod=None)¶
Load’s and create’s the nurbscurve from the shapelib. If parent will shape node parent to the given object
TODO: should combine zoo_preferences and zoo internal directories
- Parameters
shapeName (str) – the shape library name.
parent (maya.api.OpenMaya.MObject) – the parent for the nurbscurve default is None.
- Returns
A 2 tuple the first element is the MObject of the parent and the second is a list of mobjects represents the shapes created
- Return type
tuple(MObject, list(MObject))
- loadShape(shapeName, folderPath)¶
Loads the shape with the provided shapeName and folderPath.
- loadAndCreateFromPath(shapeName, folderPath, parent=None)¶
Load’s and creates the nurbs curve from the design name and specific folder path. If parent will shape node parent to the given object
TODO: should combine zoo_preferences and zoo internal directories
- Parameters
- Returns
A 2 tuple the first element is the MObject of the parent and the second is a list of mobjects represents the shapes created
- Return type
tuple(MObject, list(MObject))
- saveToLib(node, name, override=True, saveMatrix=False)¶
Save’s the current transform node shapes to the zoo library Uses the default first SHAPE_LIB_ENV location as the directory:
- Parameters
node (MObject) – The MObject to the transform that you want to save
name (str) – The name of the file to create, if not specified the node name will be used, usually the design name
override (bool) – Whether to force override the library shape file if it exists.
saveMatrix (bool) – If True save the matrix information. On import can override matching, usually matrix not wanted.
- Returns
The file path to the newly created shape file
- Return type
- saveToDirectory(node, name, directory, override=True, saveMatrix=False)¶
Saves the current transform node shapes to a directory path
- Parameters
node (MObject) – The MObject to the transform that you want to save
name (str) – The name of the file to create, if not specified the node name will be used, usually the design name
directory (str) – The directory folder to save into
saveMatrix (bool) – If True save the matrix information. On import can override matching, usually matrix not wanted.
- Returns
The file path to the newly created shape file
- Return type
nurbsCurve = cmds.circle()[0] # requires an MObject of the shape node data, path = saveToDirectory(api.asMObject(nurbsCurve))
- deleteShapeFromLib(shapeName, message=True)¶
Deletes a shape from the internal zoo library. Deletes the file on disk.
TODO: replace maya displayMessages with logging and create a maya log handler
- renameLibraryShape(shapeName, newName, message=True)¶
Renames a shape from the internal zoo library. Renames the file on disk.
TODO: replace messages with a maya log handler
- Parameters
- Return newPath
the full path of the file now renamed. Empty string if could not be renamed
- Rtype newPath
str