vtool.maya_lib.core

Class Summary

FindUniqueName(test_string)

This class is intended to find a name that doesn't clash with other names in the Maya scene.

TrackNodes()

This helps track new nodes that get added to a scene after a function runs.

ProgressBar([title, count, begin])

Manipulate the maya progress bar.

StoreDisplaySettings()

ManageNodeEditors()

Function Summary

get_current_camera()

set_current_camera(camera_name)

undo_off(function)

undo_chunk(function)

viewport_off(function)

refresh()

is_batch()

returns

True if Maya is in batch mode.

is_transform(node)

Is the node a transform.

is_a_shape(node)

Test whether the node is a shape.

is_referenced(node)

param node

Name of a node in maya. Check to see if it is referenced.

is_empty(node)

is_undeletable(node)

is_unique(name)

is_namespace(namespace)

inc_name(name[, inc_last_number])

Finds a unique name by adding a number to the end.

prefix_name(node, prefix, name[, separator])

Convenience to quickly rename a Maya node.

get_node_name(node_type, description)

create_node(node_type, description)

rename_node(node, description)

prefix_hierarchy(top_group, prefix)

Prefix all the names in a hierarchy.

pad_number(name)

Add a number to a name.

get_outliner_sets([include_nested])

Get the sets found in the outliner.

delete_outliner_sets()

Delete objectSets that usually appear in the outliner

get_top_dag_nodes([exclude_cameras, namespace])

Get transforms that sit at the very top of the hierarchy.

get_top_dag_nodes_in_list(list_of_transforms)

Given a list of transforms, return only the ones at the top of the hierarchy

get_first_shape(transform)

returns first active shape

get_shapes(transform[, shape_type, ...])

Get all the shapes under a transform.

get_shape_node_type(node)

get_node_types(nodes[, return_shape_type])

Get the maya node types for the nodes supplied.

get_transforms_with_shape_of_type(shape_type)

get_basename(name[, remove_namespace, ...])

Get the basename in a hierarchy name.

get_namespace(name)

get_dg_nodes()

remove_namespace_from_string(name)

get_characters()

delete_unknown_nodes()

This will find all unknown nodes.

rename_shapes(transform)

Rename all the shapes under a transform.

get_shapes_in_hierarchy(transform[, ...])

Get all the shapes in the child hierarchy excluding intermediates.

has_shape_of_type(node, maya_type)

Test whether the node has a shape of the supplied type.

get_orig_nodes([parent])

Get all the orig nodes in a scene, or just the ones under the parent.

get_active_orig_node(transform)

get_component_count(transform)

Get the number of components under a transform.

get_components(transform)

Get the name of the components under a transform.

get_components_in_hierarchy(transform)

Get the components in the hierarchy.

get_components_from_shapes([shapes])

Get the components from the a list of shapes.

create_group(name[, parent])

create_display_layer(name, nodes[, ...])

Create a display layer containing the supplied nodes.

delete_display_layers()

Deletes all display layers.

print_help(string_value)

print_warning(string_value)

print_error(string_value)

delete_set_contents(set_name)

delete_set(set_name)

add_to_set(nodes, set_name)

get_set_children(set_name)

load_plugin(plugin_name)

remove_non_existent(list_value)

remove_referenced_in_list(list_value)

get_hierarchy_by_depth(transforms)

Gets a hierarchy in order of depth.

get_hierarchy(transform)

get_scene_file([directory])

start_new_scene()

open_file(filepath)

import_file(filepath)

Import a maya file in a generic vtool way.

import_usd_file(filepath)

save(filepath)

get_reference_namespace(filepath)

reference_file(filepath[, namespace])

Reference a maya file in a generic vtool way.

reference_usd_file(filepath[, namespace])

replace_reference(reference_node, new_path)

Not tested

reload_reference(reference_node)

get_reference_filepath(reference_node)

get_reference_node_from_namespace(namespace)

remove_reference(reference_node)

get_tool()

set_tool_to_select()

set_tool(context)

get_progress_bar()

get_node_editors()

get_under_cursor([use_qt])

Get what is currently under the cursor using qt or not.

get_visible_hud_displays()

Get viewport hud displays.

set_hud_visibility(bool_value[, displays])

Set the viewport hud display visibility.

set_hud_lines(lines, name)

Set the viewport hud text for the named hud.

show_channel_box()

Makes the channel box visible.

add_to_isolate_select(nodes)

Add the specified nodes into every viewport's isolate select.

get_model_panels()

Good to use when editing viewports.

get_current_audio_node()

Get the current audio node.

xray_joints([bool_value])

display_textures([bool_value])

auto_focus_view([selection])

fix_camera()

remove_unused_plugins()

delete_turtle_nodes()

delete_nodes_of_type(node_type)

Delete all the nodes of type.

delete_garbage()

delete_empty_orig_nodes()

delete_empty_nodes()

get_empty_groups()

get_empty_nodes()

get_empty_orig_nodes()

get_empty_reference_nodes()

get_non_unique_names()

is_hidden(transform[, skip_connected, shape])

is_parent_hidden(transform[, skip_connected])

Searches the parent hierarchy to find one parent that is hidden.

class FindUniqueName(test_string)

This class is intended to find a name that doesn’t clash with other names in the Maya scene. It will increment the last number in the name. If no number is found it will append a 1 to the end of the name.

get_last_number(bool_value)
get()
set_padding(int_value)
class TrackNodes

This helps track new nodes that get added to a scene after a function runs.

Usage: track_nodes = TrackNodes() track_nodes.load() my_function() new_nodes = track_nodes.get_delta()

load(node_type=None)

node_type corresponds to the maya node type. For example, you can give node_type the string “animCurve” to load only keyframes. When after running get_delta(), the delta will only contain keyframes.

Parameters

node_type (str) – Maya named type, ie animCurve, transform, joint, etc

Returns

None

get_delta()

Get the new nodes in the Maya scene created after load() was executed. The load() node_type variable is stored in the class and used when getting the delta.

Returns

list of new nodes.

Return type

list

class ProgressBar(title='', count=None, begin=True)

Manipulate the maya progress bar.

Parameters
  • title (str) – The name of the progress bar.

  • count (int) – The number of items to iterate in the progress bar.

inc_value = 0
set_count(int_value)
get_count()
get_current_inc()
inc(inc=1)

Set the current increment.

next()
end()

End the progress bar.

status(status_string)

Set that status string of the progress bar.

break_signaled()

break the progress bar loop so that it stops and disappears.

get_current_camera()
set_current_camera(camera_name)
class StoreDisplaySettings
store()
restore()
class ManageNodeEditors
turn_off_add_new_nodes()
restore_add_new_nodes()
undo_off(function)
undo_chunk(function)
viewport_off(function)
refresh()
is_batch()
Returns

True if Maya is in batch mode.

Return type

bool

is_transform(node)

Is the node a transform.

Parameters

node (str) – The name of the node to test.

Returns

bool

is_a_shape(node)

Test whether the node is a shape.

Parameters

node (str) – The name of a node.

Returns

bool

is_referenced(node)
Parameters

node (str) – Name of a node in maya. Check to see if it is referenced.

Returns

bool

is_empty(node)
is_undeletable(node)
is_unique(name)
is_namespace(namespace)
inc_name(name, inc_last_number=True)

Finds a unique name by adding a number to the end.

Parameters

name (str) – Name to start from.

Returns

Modified name, number added if not unique..

Return type

str

prefix_name(node, prefix, name, separator='_')

Convenience to quickly rename a Maya node.

Parameters
  • node (str) – Name of a node in maya to rename.

  • prefix (str) –

  • name (str) –

  • separator (str) –

Returns

prefix + separator + name

Return type

str

get_node_name(node_type, description)
create_node(node_type, description)
rename_node(node, description)
prefix_hierarchy(top_group, prefix)

Prefix all the names in a hierarchy.

Parameters
  • top_group (str) – Name of the top node of a hierarchy.

  • prefix (str) – Prefix to add in front of top_group and all children.

Returns

The renamed hierarchy including top_group.

Return type

list

pad_number(name)

Add a number to a name.

get_outliner_sets(include_nested=False)

Get the sets found in the outliner.

Returns

List of sets in the outliner.

Return type

list

delete_outliner_sets()

Delete objectSets that usually appear in the outliner

get_top_dag_nodes(exclude_cameras=True, namespace=None)

Get transforms that sit at the very top of the hierarchy.

Returns

list

get_top_dag_nodes_in_list(list_of_transforms)

Given a list of transforms, return only the ones at the top of the hierarchy

get_first_shape(transform)

returns first active shape

get_shapes(transform, shape_type=None, no_intermediate=False)

Get all the shapes under a transform.

Parameters

transform (str) – The name of a transform.

Returns

The names of shapes under the transform

Return type

list

get_shape_node_type(node)
get_node_types(nodes, return_shape_type=True)

Get the maya node types for the nodes supplied.

Returns

dict[node_type_name] node dict of matching nodes

Return type

dict

get_transforms_with_shape_of_type(shape_type)
get_basename(name, remove_namespace=True, remove_attribute=False)

Get the basename in a hierarchy name. If top|model|face is supplied, face will be returned.

get_namespace(name)
get_dg_nodes()
remove_namespace_from_string(name)
get_characters()
delete_unknown_nodes()

This will find all unknown nodes. Unlock and delete them.

rename_shapes(transform)

Rename all the shapes under a transform. Renames them to match the name of the transform.

Parameters

transform (str) – The name of a transform.

get_shapes_in_hierarchy(transform, shape_type='', return_parent=False, skip_first_relative=False)

Get all the shapes in the child hierarchy excluding intermediates. This is good when calculating bounding box of a group.

Parameters

transform (str) – The name of a transform.

Returns

The list of shape nodes.

Return type

list

has_shape_of_type(node, maya_type)

Test whether the node has a shape of the supplied type.

Parameters
  • node (str) – The name of a node.

  • maya_type (str) – Can be a mesh, nurbsCurve, or any maya shape type.

Returns

bool

get_orig_nodes(parent=None)

Get all the orig nodes in a scene, or just the ones under the parent.

get_active_orig_node(transform)
get_component_count(transform)

Get the number of components under a transform. This does not include hierarchy.

Parameters

transform (str) – The name of a transform.

Returns

The number of components under transform, eg. verts, cvs, etc.

Return type

int

get_components(transform)

Get the name of the components under a transform. This does not include hierarchy.

Parameters

transform (str) – The name of a transform.

Returns

The name of all components under transform, eg verts, cvs, etc.

Return type

list

get_components_in_hierarchy(transform)

Get the components in the hierarchy. This includes all transforms with shapes parented under the transform.

Parameters

transform (str) – The name of a transform.

Returns

The name of all components under transform, eg verts, cvs, etc.

Return type

list

get_components_from_shapes(shapes=None)

Get the components from the a list of shapes. Curntly supports cv and vtx components

Parameters

shapes (list) – List of shape names.

Returns

The components of the supplied shapes.

Return type

list

create_group(name, parent=None)
create_display_layer(name, nodes, display_type=2, recursive_add=False)

Create a display layer containing the supplied nodes.

Parameters
  • name (str) – The name to give the display layer.

  • nodes (str) – The nodes that should be in the display layer.

delete_display_layers()

Deletes all display layers.

print_help(string_value)
print_warning(string_value)
print_error(string_value)
delete_set_contents(set_name)
delete_set(set_name)
add_to_set(nodes, set_name)
get_set_children(set_name)
load_plugin(plugin_name)
remove_non_existent(list_value)
remove_referenced_in_list(list_value)
get_hierarchy_by_depth(transforms)

Gets a hierarchy in order of depth. Least deep first

get_hierarchy(transform)
get_scene_file(directory=False)
start_new_scene()
open_file(filepath)
import_file(filepath)

Import a maya file in a generic vtool way.

import_usd_file(filepath)
save(filepath)
get_reference_namespace(filepath)
reference_file(filepath, namespace=None)

Reference a maya file in a generic vtool way.

Parameters
  • filepath (str) – The full path and filename.

  • namespace (str) – The namespace to add to the nodes in maya. Default is the name of the file.

reference_usd_file(filepath, namespace=None)
replace_reference(reference_node, new_path)

Not tested

reload_reference(reference_node)
get_reference_filepath(reference_node)
get_reference_node_from_namespace(namespace)
remove_reference(reference_node)
get_tool()
set_tool_to_select()
set_tool(context)
get_progress_bar()
get_node_editors()
get_under_cursor(use_qt=True)

Get what is currently under the cursor using qt or not. When not using qt it is more of a hack.

get_visible_hud_displays()

Get viewport hud displays.

Returns

List of names of heads up displays.

Return type

list

set_hud_visibility(bool_value, displays=None)

Set the viewport hud display visibility.

Parameters
  • bool_value (bool) – True turns visiliblity on, False turns it off.

  • displays (list) – List of heads up displays by name.

set_hud_lines(lines, name)

Set the viewport hud text for the named hud.

Parameters
  • lines (list) – Each entry in the list is a new text line in the display.

  • name (str) – The name of the heads up display to work on.

show_channel_box()

Makes the channel box visible.

add_to_isolate_select(nodes)

Add the specified nodes into every viewport’s isolate select. This will only work on viewports that have isolate select turned on. Use when nodes are not being evaluated because isolate select causes them to be invisible.

Parameters

nodes (list) – The nodes to add to isolate select.

get_model_panels()

Good to use when editing viewports.

get_current_audio_node()

Get the current audio node. Important when getting sound in a playblast.

Returns

Name of the audio node.

Return type

str

xray_joints(bool_value=True)
display_textures(bool_value=True)
auto_focus_view(selection=False)
fix_camera()
remove_unused_plugins()
delete_turtle_nodes()
delete_nodes_of_type(node_type)

Delete all the nodes of type. Good for cleaning up scenes.

Parameters

node_type (str) – The name of a node type. Eg. hyperView, ilrBakeLayouerManger, etc

delete_garbage()
delete_empty_orig_nodes()
delete_empty_nodes()
get_empty_groups()
get_empty_nodes()
get_empty_orig_nodes()
get_empty_reference_nodes()
get_non_unique_names()
is_hidden(transform, skip_connected=True, shape=True)
is_parent_hidden(transform, skip_connected=True)

Searches the parent hierarchy to find one parent that is hidden.