Module index

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

default(obj)[source]
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

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.IO.update_json(json_object)[source]

This takes the json_object and updates it to work with zBuilder 1.0.0

Returns:modified json_object
zBuilder.IO.wrap_data(data, type_)[source]

Utility wrapper to identify data.

Parameters:
  • data
  • type (str) – The type of data it is.

zBuilder.builder module

class zBuilder.builder.Builder[source]

Bases: object

The main entry point for using zBuilder.

build(*args, **kwargs)[source]
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 or list, optional) – filter by parameter type. Defaults to list.
  • name_filter (str or list, optional) – filter by parameter name. Defaults to list.
  • name_regex (str) – filter by parameter name by regular expression. Defaults to None.
  • association_filter (str or list, optional) – filter by parameter association. Defaults to list.
  • association_regex (str) – filter by parameter association by regular expression. Defaults to None.
  • invert_match (bool) – Invert the sense of matching, to select non-matching items. Defaults to False
Returns:

List of scene items.

Return type:

list

log()[source]
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

parameter_factory(type_, stuff)[source]
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 or str) – filter by parameter type. Defaults to list
  • name_filter (list or str) – filter by parameter name. Defaults to list
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.
retrieve_from_scene(*args, **kwargs)[source]

must create a method to inherit this class

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')
static time_this(original_function)[source]

A decorator to time functions.

view()[source]
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 or str) – filter by parameter type. Defaults to list
  • name_filter (list or str) – filter by parameter name. Defaults to list
extend_scene_items(scene_items)[source]
Parameters:scene_items

Returns:

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 or list, optional) – filter by parameter type. Defaults to list.
  • name_filter (str or list, optional) – filter by parameter name. Defaults to list.
  • name_regex (str) – filter by parameter name by regular expression. Defaults to None.
  • association_filter (str or list, optional) – filter by parameter association. Defaults to list.
  • association_regex (str) – filter by parameter association by regular expression. Defaults to None.
  • invert_match (bool) – Invert the sense of matching, to select non-matching items. Defaults to False
Returns:

List of scene items.

Return type:

list

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 or str) – filter by parameter type. Defaults to list
  • name_filter (list or str) – filter by parameter name. Defaults to list
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 to str
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')

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.util.copy_paste(*args, **kwargs)[source]

A utility wrapper for copying and pasting a tissue

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_maya_node(maya_node)[source]
Parameters:maya_node

Returns:

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.clean_scene()[source]

Deletes all ziva nodes in scene. Effectively cleaning it up.

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

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

zBuilder.zMaya.select_tissue_meshes()[source]

Selects all zTissues in scene

Module contents