zBuilder.builders package

Submodules

zBuilder.builders.builder module

class zBuilder.builders.builder.Builder[source]

Bases: object

The main entry point for using zBuilder.

get_node_parameters(node, types=None)[source]

Get parameters (e.g. maps and meshes) for the specified node. :param node: zBuilder scene item :type node: zBuilder node :param types: node types to return, e.g. map, mesh. :type types: list, optional :param If None return all types.:

Returns:

list of zBuilder node parameters

get_scene_items(type_filter=None, name_filter=None, name_regex=None, association_filter=None, 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 scene_item type. Defaults to None.

  • name_filter (str or list, optional) – filter by scene_item name. Defaults to None.

  • name_regex (str) – filter by scene_item name by regular expression. Defaults to None.

  • association_filter (str or list, optional) – filter by scene_item association. Defaults to None.

  • association_regex (str) – filter by scene_item 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]
make_node_connections()[source]

This makes connections between this node and any other node in scene_items. The expectations is that this gets run after anytime the scene items get populated.

node_factory(node, parent=None)[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(parameter_type, parameter_args)[source]

This looks for zBuilder objects in sys.modules and instantiates desired one based on arguments.

Parameters:
  • type (str) – The type of parameter to instantiate (map or mesh)

  • names (str or list) – The name of parameter to instantiate. This should be a node in the Maya scene, either a mesh or a map name. Currently sometimes parameter_names could be a list. It is a list when dealing with a map. The second element is the payload whereas the first is the name.

Returns:

zBuilder parameter object, either one created or an existing one that has already been created.

Return type:

object

print_(type_filter=None, name_filter=None)[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 scene_item type. Defaults to None

  • name_filter (list or str) – filter by scene_item name. Defaults to None

remove_scene_item(item_to_remove)[source]

Removes a scene item from the builder while keeping order. :param item_to_remove: The item object to remove. :type item_to_remove: obj

retrieve_from_file(file_path)[source]

Wraps ‘read()’ defined in serialize.py. This is used for backward compatibility.

retrieve_from_scene(*args, **kwargs)[source]

must create a method to inherit this class

stats()[source]

Print scene item types and their 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')
write(file_path, type_filter=None, invert_match=False)[source]

Wraps ‘write()’ defined in serialize.py. This is used for backward compatibility.

zBuilder.builders.builder.find_class(module, obj_type)[source]

Given a module and a type returns class object. If no class objects are found it returns a DGNode class object.

Parameters:
  • module (str) – The module to look for.

  • obj_type (str) – The type to look for.

Returns:

class object.

Return type:

obj

zBuilder.builders.deformers module

class zBuilder.builders.deformers.Deformers(*args, **kwargs)[source]

Bases: Builder

Builder to help serialize and manipulate Maya deformers.

build(interp_maps='auto')[source]

This builds the deformers into the scene.

Parameters:

interp_maps (str) – Option to interpolate maps. True: Yes interpolate False: No auto: Interpolate if it needs it (vert check)

retrieve_from_scene(deformers=None)[source]

This retrieves the deformers from the selected meshes. Supported types are skinCluster, deltaMush, wrap and blendShape. By default it will retrieve all of them.

Parameters:

deformers (list) – List of supported deformers to retrieve from scene. Defaults to None which in turn gets all supported deformers.

zBuilder.builders.serialize module

class zBuilder.builders.serialize.BaseNodeEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: JSONEncoder

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
zBuilder.builders.serialize.get_meta_data()[source]

Meta data for embedding with serialized data

zBuilder.builders.serialize.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.builders.serialize.pack_zbuilder_contents(builder, type_filter, invert_match)[source]

Utility to package the data in a dictionary.

zBuilder.builders.serialize.read(file_path, builder)[source]

Reads scene items from a given file.

Parameters:
  • file_path (str) – The file path to read from disk.

  • builder – builder object

zBuilder.builders.serialize.replace_scene_items_with_string(item)[source]

This method takes a scene item, and replaces each instance with an embedded scene item with the scene item’s name. The reason for this is, scene items are not serializable by themselves. This enables us to “re-apply” the item after it has been loaded from disk.

Parameters:

item – scene item

zBuilder.builders.serialize.unpack_zbuilder_contents(builder, json_data)[source]

Gets data out of json serialization and assigns it to node collection object.

Parameters:

json_data – Data to assign to builder object.

zBuilder.builders.serialize.write(file_path, builder, type_filter=None, 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.

  • builder – builder object

  • 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.builders.skinClusters module

class zBuilder.builders.skinClusters.SkinCluster[source]

Bases: Builder

Capturing Maya skinClusters

build(*args, **kwargs)[source]
retrieve_from_scene(*args, **kwargs)[source]

must create a method to inherit this class

zBuilder.builders.ziva module

class zBuilder.builders.ziva.Ziva[source]

Bases: Builder

To capture a Ziva rig.

build(association_filter=None, interp_maps='auto', solver=True, bones=True, tissues=True, attachments=True, materials=True, fibers=True, embedder=True, cloth=True, fields=True, lineOfActions=True, rivetToBone=True, restShape=True, permissive=True, target_prefix=None, center_prefix=None)[source]

This builds the Ziva rig into the Maya scene. It does not build geometry as the expectation is that the geometry is in the scene.

Parameters:
  • association_filter (str) – filter by node association. Defaults to None

  • interp_maps (str) – Option to interpolate maps. True: Yes interpolate False: No auto: Interpolate if it needs it (vert check)

  • solver (bool) – Build the solver.

  • bones (bool) – Build the bones.

  • tissues (bool) – Build the tissue and tets.

  • attachments (bool) – Build the attachments.

  • materials (bool) – Build the materials.

  • fibers (bool) – Build the fibers.

  • embedder (bool) – Build the embedder.

  • cloth (bool) – Build the cloth.

  • fields (bool) – Build the fields.

  • lineOfActions (bool) – Build the line of actions.

  • rivetToBone (bool) – Build the rivet to bone.

  • restShape (bool) – Build the zRestShape.

  • permissive (bool) – False raises errors if something is wrong. Defaults to True

  • target_prefix (str) – Target prefix used for mirroring. Defaults to None

  • center_prefix (str) – Center prefix used for mirroring. Defaults to None

retrieve_connections()[source]

This retrieves the scene items from the scene based on connections to selection and does not get parameters for speed. This is main call to check scene for loading into a ui.

retrieve_from_scene(*args, **kwargs)[source]

This gets the scene items from the scene for further manipulation or saving. It works on selection or something passed in args. If nothing is selected it looks for a zSolver in the scene. If something is selected or passed it uses that specific solver to retrieve.

Items captured in this case are:

  • All the Ziva nodes. (zTissue, zTet, zAttachment, etc..)

  • Order of the nodes so we can re-create material layers reliably.

  • Attributes and values of the nodes. (Including weight maps)

  • Sub-tissue information.

  • User defined tet mesh reference. (Not the actual mesh)

  • Any embedded mesh reference. (Not the actual mesh)

  • Curve reference to drive zLineOfAction. (Not actual curve)

  • Relevant zSolver for each node.

  • Mesh information used for world space lookup to interpolate maps if needed.

Existing scene items are retained. If this retrieve finds a scene items with the same long name as an existing scene item, it replaces the old one.

retrieve_from_scene_selection(*args, **kwargs)[source]

Gets scene items based on selection.

Parameters:
  • solver (bool) – Gets solver data. Defaults to True

  • bones (bool) – Gets bone data. Defaults to True

  • tissue (bool) – Gets tissue data. Defaults to True

  • attachments (bool) – Gets attachments data. Defaults to True

  • materials (bool) – Gets materials data. Defaults to True

  • fibers (bool) – Gets fibers data. Defaults to True

  • cloth (bool) – Gets cloth data. Defaults to True

  • fields (bool) – Gets field data. Defaults to True

  • lineOfAction (bool) – Gets line of action data. Defaults to True

  • embedder (bool) – Gets embedder data. Defaults to True

setup_tree_hierarchy()[source]

Sets up hierarchy for a tree view. This will look at items and assign the proper children, parent for QT.

zBuilder.builders.ziva.transform_rivet_and_LoA_into_tissue_meshes(selection)[source]

This takes a list of items from a maya scene and if it finds any zLineOfAction or zRivetToBone it replaces that item with the corresponding tissued mesh.

This is until zQuery is re-implemented in python.

Parameters:

selection ([str]) – List of items in mayas scene

Returns:

Selection list with some items replaced.

Return type:

list()

Module contents