zBuilder package


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


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):
        iterable = iter(o)
    except TypeError:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)

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.

  • file_path – The location to save the json file.
  • json_data – The data to save in the json.

file path if successful.


IOError – If not able to write file.

zBuilder.IO.find_class(module_, type_)[source]

Given a module and a type returns class object.

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

class object.

Return type:



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

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.

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.

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

zBuilder.builder module

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.


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.

  • type_filter (list or str) – filter by parameter type. Defaults to list
  • name_filter (list or str) – filter by parameter name. Defaults to list


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.

  • 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

List of scene items.

Return type:


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.

  • type_filter (list or str) – filter by parameter type. Defaults to list
  • name_filter (list or str) – filter by parameter name. Defaults to list

Removes a scene_item from the bundle list while keeping order. :param scene_item: The scene_item object to remove. :type scene_item: obj


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.

  • search (str) – what to search for
  • replace (str) – what to replace it with


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.zMaya module

Module contents