Module index¶
Subpackages¶
- zBuilder.builders package
- zBuilder.nodes package
- Subpackages
- zBuilder.nodes.deformers package
- zBuilder.nodes.utils package
- zBuilder.nodes.ziva package
- Submodules
- zBuilder.nodes.ziva.zAttachment module
- zBuilder.nodes.ziva.zBone module
- zBuilder.nodes.ziva.zCloth module
- zBuilder.nodes.ziva.zEmbedder module
- zBuilder.nodes.ziva.zFiber module
- zBuilder.nodes.ziva.zLineOfAction module
- zBuilder.nodes.ziva.zMaterial module
- zBuilder.nodes.ziva.zSolver module
- zBuilder.nodes.ziva.zSolverTransform module
- zBuilder.nodes.ziva.zTet module
- zBuilder.nodes.ziva.zTissue module
- zBuilder.nodes.ziva.zivaBase module
- Module contents
- Submodules
- zBuilder.nodes.base module
- zBuilder.nodes.deformer module
- zBuilder.nodes.dg_node module
- zBuilder.nodes.transform module
- Module contents
- Subpackages
- zBuilder.parameters package
Submodules¶
zBuilder.IO module¶
-
class
zBuilder.IO.
BaseNodeEncoder
(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, encoding='utf-8', default=None)[source]¶ Bases:
json.encoder.JSONEncoder
-
zBuilder.IO.
check_data
(data)[source]¶ Utility to check data format after loaded from josn. Used to check if data is wrapped in dictionary. If it isn’t it wraps it. Used to deal with older zBuilder files.
Parameters: data – Data to check. Returns: Result of operation.
-
zBuilder.IO.
dump_json
(file_path, json_data)[source]¶ Saves a json file to disk given a file path and data.
Parameters: - file_path – The location to save the json file.
- json_data – The data to save in the json.
Returns: file path if successful.
Raises: IOError
– If not able to write file.
-
zBuilder.IO.
find_class
(module_, type_)[source]¶ Given a module and a type returns class object.
Parameters: - module (
str
) – The module to look for. - type (
str
) – The type to look for.
Returns: class object.
Return type: obj
- module (
-
zBuilder.IO.
load_base_node
(json_object)[source]¶ Loads json objects into proper classes. Serves as object hook for loading json.
Parameters: json_object (obj) – json obj to perform action on Returns: Result of operation Return type: obj
-
zBuilder.IO.
load_json
(file_path)[source]¶ loads a json file from disk given a file path.
Parameters: file_path – The location to save the json file. Returns: json data Raises: IOError
– If not able to read file.
zBuilder.builder module¶
-
class
zBuilder.builder.
Builder
[source]¶ Bases:
object
The main entry point for using zBuilder.
-
get_scene_items
(type_filter=[], name_filter=[], name_regex=None, association_filter=[], association_regex=None, invert_match=False)[source]¶ Gets the scene items from builder for further inspection or modification.
Parameters: - type_filter (
str
orlist
, optional) – filter by parametertype
. Defaults tolist
. - name_filter (
str
orlist
, optional) – filter by parametername
. Defaults tolist
. - name_regex (
str
) – filter by parameter name by regular expression. Defaults toNone
. - association_filter (
str
orlist
, optional) – filter by parameterassociation
. Defaults tolist
. - association_regex (
str
) – filter by parameterassociation
by regular expression. Defaults toNone
. - invert_match (bool) – Invert the sense of matching, to select non-matching items.
Defaults to
False
Returns: List of scene items.
Return type: list
- type_filter (
-
node_factory
(node, parent=None, get_parameters=True)[source]¶ Given a maya node, this checks objType and instantiates the proper zBuilder.node and populates it and returns it.
Parameters: - node (
str
) – Name of maya node. - get_parameters (bool) –
Returns: zBuilder node populated.
Return type: obj
- node (
-
print_
(type_filter=[], name_filter=[])[source]¶ Prints out basic information for each scene item in the Builder. Information is all information that is stored in the __dict__. Useful for trouble shooting.
Parameters: - type_filter (
list
orstr
) – filter by parameter type. Defaults tolist
- name_filter (
list
orstr
) – filter by parameter name. Defaults tolist
- type_filter (
-
retrieve_from_file
(file_path)[source]¶ Reads scene items from a given file. The items get placed in the bundle.
Parameters: file_path ( str
) – The file path to read from disk.
-
stats
()[source]¶ Prints out basic information in Maya script editor. Information is scene item types and counts.
-
string_replace
(search, replace)[source]¶ Searches and replaces with regular expressions scene items in the builder.
Parameters: - search (
str
) – what to search for - replace (
str
) – what to replace it with
Example
replace r_ at front of item with l_:
>>> z.string_replace('^r_','l_')
replace _r at end of line with _l:
>>> z.string_replace('_r$','_l')
- search (
-
write
(file_path, type_filter=[], invert_match=False)[source]¶ Writes out the scene items to a json file given a file path.
Parameters: - file_path (str) – The file path to write to disk.
- type_filter (list, optional) – Types of scene items to write.
- invert_match (bool) – Invert the sense of matching, to select non-matching items.
Defaults to
False
-
zBuilder.bundle module¶
-
class
zBuilder.bundle.
Bundle
[source]¶ Bases:
object
Mixin class to deal with storing node data and component data. meant to be inherited by main.
-
append_scene_item
(scene_item)[source]¶ appends a parameter to the parameter list. Checks if parameter is already in list, if it is it overrides the previous one.
Parameters: scene_item ( obj
) – the parameter to append to collection list.
-
compare
(type_filter=[], name_filter=[])[source]¶ Compares info in memory with that which is in scene.
Parameters: - type_filter (
list
orstr
) – filter by parameter type. Defaults tolist
- name_filter (
list
orstr
) – filter by parameter name. Defaults tolist
- type_filter (
-
get_scene_items
(type_filter=[], name_filter=[], name_regex=None, association_filter=[], association_regex=None, invert_match=False)[source]¶ Gets the scene items from builder for further inspection or modification.
Parameters: - type_filter (
str
orlist
, optional) – filter by parametertype
. Defaults tolist
. - name_filter (
str
orlist
, optional) – filter by parametername
. Defaults tolist
. - name_regex (
str
) – filter by parameter name by regular expression. Defaults toNone
. - association_filter (
str
orlist
, optional) – filter by parameterassociation
. Defaults tolist
. - association_regex (
str
) – filter by parameterassociation
by regular expression. Defaults toNone
. - invert_match (bool) – Invert the sense of matching, to select non-matching items.
Defaults to
False
Returns: List of scene items.
Return type: list
- type_filter (
-
print_
(type_filter=[], name_filter=[])[source]¶ Prints out basic information for each scene item in the Builder. Information is all information that is stored in the __dict__. Useful for trouble shooting.
Parameters: - type_filter (
list
orstr
) – filter by parameter type. Defaults tolist
- name_filter (
list
orstr
) – filter by parameter name. Defaults tolist
- type_filter (
-
remove_scene_item
(scene_item)[source]¶ Removes a scene_item from the bundle list while keeping order. :param scene_item: The scene_item object to remove. :type scene_item:
obj
-
stats
(type_filter='')[source]¶ Prints out basic information in Maya script editor. Information is scene item types and counts.
Parameters: type_filter ( str
) – filter by parameter type. Defaults tostr
-
string_replace
(search, replace)[source]¶ Searches and replaces with regular expressions the scene items in the builder.
Parameters: - search (
str
) – what to search for - replace (
str
) – what to replace it with
Example
replace r_ at front of item with l_:
>>> z.string_replace('^r_','l_')
replace _r at end of line with _l:
>>> z.string_replace('_r$','_l')
- search (
-
zBuilder.util module¶
-
zBuilder.util.
check_map_validity
()[source]¶ This checks the map validity for zAttachments and zFibers. For zAttachments it checks if all the values are zero. If so it failed and turns off the associated zTissue node. For zFibers it checks to make sure there are at least 1 value of 0 and 1 value of .5 within a .1 threshold. If not that fails and turns off the zTissue
Returns: list of offending maps
zBuilder.zMaya module¶
-
zBuilder.zMaya.
ZNODES
= ['zGeo', 'zSolver', 'zSolverTransform', 'zIsoMesh', 'zDelaunayTetMesh', 'zTet', 'zTissue', 'zBone', 'zCloth', 'zSolver', 'zCache', 'zEmbedder', 'zAttachment', 'zMaterial', 'zFiber', 'zCacheTransform']¶ All available ziva nodes to be able to cleanup.
-
zBuilder.zMaya.
build_attr_key_values
(selection, attr_list)[source]¶ Builds a dictionary of attribute key/values. Stores the value, type, and locked status. :param selection: Items to save attrbutes for. :param attr_list: List of attributes to save.
Returns: of attribute values. Return type: dict
-
zBuilder.zMaya.
build_attr_list
(selection, attr_filter=None)[source]¶ Builds a list of attributes to store values for. It is looking at keyable attributes and if they are in channelBox.
Parameters: - attr_filter –
- selection (str) – maya object to find attributes
Returns: list of attributes names
Return type: list
-
zBuilder.zMaya.
check_body_type
(bodies)[source]¶ Checks if given bodies are either zTissue, zCloth and or zBone. Mostly used to see if we can create a zAttachment before we try. Additionally does a check if all objects exist in scene.
Parameters: bodies (list) – List of bodies we want to check type of. Returns: True if all bodies pass test, else False. Return type: (bool)
-
zBuilder.zMaya.
check_map_validity
(map_parameters)[source]¶ This checks the map validity for zAttachments and zFibers. For zAttachments it checks if all the values are zero. If so it failed and turns off the associated zTissue node. For zFibers it checks to make sure there are at least 1 value of 0 and 1 value of .5 within a .1 threshold. If not that fails and turns off the zTissue
Parameters: map_parameters – map parameters to check. Returns: list of offending maps
-
zBuilder.zMaya.
check_mesh_quality
(meshes)[source]¶ Light wrapper around checking mesh quality.
Parameters: meshes (list) – A list of meshes you want to check Raises: StandardError
– If any mesh does not pass mesh check
-
zBuilder.zMaya.
cull_creation_nodes
(parameters, permissive=True)[source]¶ To help speed up the build of a Ziva setup we are creating the bones and the tissues with one command. Given a list of zBuilder nodes this checks if a given node needs to be created in scene. Checks to see if it already exists or if associated mesh is missing. Either case it culls it from list.
Parameters: - permissive (bool) –
- parameters (object) – the zBuilder nodes to check.
Returns: Dictionary of non culled
Return type: dict
-
zBuilder.zMaya.
get_association
(zNode)[source]¶ Gets an association of given zNode
Parameters: zNode (string) – the zNode to find association of.
-
zBuilder.zMaya.
get_fiber_lineofaction
(zFiber)[source]¶ Gets the zLineOfAction node hooked up to a given zFiber in any.
Parameters: zFiber (string) – the zFiber to query. Returns: zLineOfAction Return type: str
-
zBuilder.zMaya.
get_lineOfAction_fiber
(zlineofaction)[source]¶ Gets the zFiber node hooked up to a given zLineOfAction in any.
Parameters: zlineofaction (string) – the zLineOfAction to query. Returns: Name of zFiber hooked up to lineOfAction Return type: str
-
zBuilder.zMaya.
get_mdagpath_from_mesh
(mesh_name)[source]¶ Maya stuff, getting the dagpath from a mesh name
Parameters: mesh_name – The mesh to get dagpath from.
-
zBuilder.zMaya.
get_mesh_connectivity
(mesh_name)[source]¶ Gets mesh connectivity for given mesh.
Parameters: mesh_name – Name of mesh to process. Returns: Dictionary of polygonCounts, polygonConnects, and points. Return type: dict
-
zBuilder.zMaya.
get_name_from_m_object
(m_object, long_name=True)[source]¶ Gets maya scene name from given mObject. :param m_object: The m_object to get name from. :param long_name: Returns long name. Default =
True
Returns: Maya object name. Return type: str
-
zBuilder.zMaya.
get_type
(body)[source]¶ Really light wrapper for getting type of maya node. Ya, I know.
Parameters: body (str) – Maya node to get type of Returns: String of node type. Return type: str
-
zBuilder.zMaya.
get_zAttachments
(bodies)[source]¶ Gets zAttachments in scene. :param body: Maya node to find associated zAttachments.
Returns: string of name of zAttachments.
-
zBuilder.zMaya.
get_zBones
(bodies)[source]¶ Gets zBones in scene. :param body: Maya node to find associated zBones.
Returns: string of name of zBones.
-
zBuilder.zMaya.
get_zCloth
(bodies)[source]¶ Gets zCloth in scene. :param body: Maya node to find associated zCloth.
Returns: string of name of zCloth.
-
zBuilder.zMaya.
get_zFibers
(bodies)[source]¶ Gets zFibers in scene. :param body: Maya node to find associated zFibers.
Returns: string of name of zFibers.
-
zBuilder.zMaya.
get_zMaterials
(bodies)[source]¶ Gets zmaterials in scene. :param body: Maya node to find associated zMaterials.
Returns: string of name of zmaterials.
-
zBuilder.zMaya.
get_zSolver
(body)[source]¶ Gets zSolver in scene. :param body: Maya node to find associated solver.
Returns: returns long name of zSolver.
-
zBuilder.zMaya.
get_zSolverTransform
(body)[source]¶ Gets zSolverTransform in scene. :param body: Maya node to find associated solverTransform.
Returns: returns long name of zSolverTransform.
-
zBuilder.zMaya.
get_zTet_user_mesh
(zTet)[source]¶ Gets the user tet mesh hooked up to a given zTet in any.
Parameters: zTet (string) – the zTet to query. Returns: User tet mesh. Return type: str
-
zBuilder.zMaya.
get_zTets
(bodies)[source]¶ Gets zTets in scene. :param body: Maya node to find associated zTets.
Returns: string of name of zTets.
-
zBuilder.zMaya.
get_zTissues
(bodies)[source]¶ Gets zTissues in scene. :param body: Maya node to find associated zTissues.
Returns: string of name of zTissues.
-
zBuilder.zMaya.
isSolver
(selection)[source]¶ Checks if passed is zSolver or zSolverTransform. :param selection: Item of interest.
Returns: True if it is solver, else false.
-
zBuilder.zMaya.
parse_maya_node_for_selection
(args)[source]¶ This is used to check passed args in a function to see if they are valid maya objects in the current scene. If any of the passed names are not in the it raises a StandardError. If nothing is passed it looks at what is actively selected in scene to get selection. This way it functions like a lot of the maya tools, uses what is passed OR it uses what is selected.
Parameters: args – The args to test Returns: (list) maya selection
-
zBuilder.zMaya.
rename_ziva_nodes
(replace=['_muscle', '_bone'])[source]¶ Renames zNodes based on mesh it’s connected to.
Parameters: replace (list) – subset of mesh name to replace with zNode name - zFiber: <meshName>_zFiber
- zMaterial: <meshName>_zMaterial
- zTet: <meshName>_zTet
- zTissue: <meshName>_zTissue
- zBone: <meshName>_zBone
- zCloth: <meshName>_zCloth
- zAttachment: <sourceMesh>__<destinationMesh>_zAttachment
-
zBuilder.zMaya.
replace_dict_keys
(search, replace, dictionary)[source]¶ Does a search and replace on dictionary keys
Parameters: - search (
str
) – search term - replace (
str
) – replace term - dictionary (
dict
) – the dictionary to do search on
Returns: result of search and replace
Return type: dict
- search (
-
zBuilder.zMaya.
replace_long_name
(search, replace, long_name)[source]¶ does a search and replace on a long name. It splits it up by (‘|’) then performs it on each piece
Parameters: - search (str) – search term
- replace (str) – replace term
- long_name (str) – the long name to perform action on
Returns: result of search and replace
Return type: str