vtool.util

Class Summary

VetalaHTMLParser()

Initialize and reset this instance.

ControlName()

StopWatch()

Utility to check how long a command takes to run.

VectorBase()

Vector2D([x, y])

Vector([x, y, z])

BoundingBox(btm_corner_vector, top_corner_vector)

Convenience for dealing with bounding boxes

Variable([name])

Simple base class for variables on a node.

Part(name)

FindUniqueString(test_string)

QuickSort(list_of_numbers)

Really fast method for sorting.

Function Summary

get_custom(name[, default])

stop_watch_wrapper(function)

get_code_builtins()

reset_code_builtins([builtins])

setup_code_builtins([builtin])

initialize_env(name)

Initialize a new environment variable.

set_env(name, value)

Set the value of an environment variable.

get_env(name)

Get the value of an environment variable.

append_env(name, value)

Append string value to the end of the environment variable

suggest_env(name, value)

start_temp_log()

record_temp_log(value)

end_temp_log()

get_last_temp_log()

add_to_PYTHONPATH(path)

Add a path to the python path, only if it isn't present in the python path.

profiler_event(frame, event, arg[, indent])

activate_profiler()

Activating the profiler will give extremely detailed information about what functions are running and in what order.

try_pass(function)

Try a function and if it fails pass. Used as a decorator. Usage: @try_pass def myFunction(): do_something.

is_stopped()

is_in_maya()

Check to see if scope is in Maya.

has_shotgun_api()

Check if the shotgun api is available.

has_shotgun_tank()

Check if the shotgun tank api is available.

get_current_maya_location()

Get where maya is currently running from.

is_in_nuke()

Check to see if scope is in Nuke

is_linux()

Check to see if running in linux

is_windows()

Check to see if running in windows

get_maya_version()

Get the version of maya that the scope is running in.

break_signaled()

Check to see if Vetala break was signalled.

vector_multiply(vector, value)

param vector

3 value list

vector_divide(vector, value)

param vector

3 value list

vector_magnitude(vector)

Get the magnitude of a vector.

vector_add(vector1, vector2)

param vector1

3 value list

vector_sub(vector1, vector2)

param vector1

3 value list

vector_cross(vector1, vector2[, normalize])

param vector1

3 value list

rotate_x_at_origin(vector, value[, ...])

Rotate a vector around its x axis.

rotate_y_at_origin(vector, value[, ...])

Rotate a vector around its y axis.

rotate_z_at_origin(vector, value[, ...])

Rotate a vector around its z axis.

get_axis_vector(axis_name[, offset])

Convenience.

fade_sine(percent_value)

fade_cosine(percent_value)

fade_smoothstep(percent_value)

fade_sigmoid(percent_value)

set_percent_range(percent_value, new_min, ...)

lerp(number1, number2[, weight])

interpolate between number1 and number2 based on a 0-1 weight value

remap_value(value, old_min, old_max, ...)

get_distance(vector1, vector2)

Get the distance between two vectors.

get_distance_2D(vector1_2D, vector2_2D)

Get the distance between two 2D vectors.

get_magnitude_2D(vector_2D)

param vector_2D

eg [0,0] vector

get_dot_product(vector1, vector2)

Get the dot product of two vectors.

get_dot_product_2D(vector1_2D, vector2_2D)

Get the dot product of two 2D vectors.

get_average(numbers)

param numbers

A list of floats.

get_midpoint(vector1, vector2)

Get the mid vector between two vectors.

get_inbetween_vector(vector1, vector2[, percent])

Get a vector inbetween vector1 and vector2 at the percent

get_simple_center_vector(list_of_vectors)

is_the_same_number(number1, number2[, tolerance])

convert_to_sequence(variable[, sequence_type])

Easily convert to a sequence.

line_side(start_vector, end_vector, ...)

Find out what side a position_vector is on given a line defined by start_vector and end_vector.

closest_percent_on_line_3D(start_vector, ...)

Get how far a vector is on a line.

closest_percent_on_line_2D(start_vector, ...)

Get how far a vector is on a line.

closest_point_to_line_2D(start_vector, ...)

uv_to_udim(u, v)

convert_number_to_month(month_int)

get_current_time([date_and_time])

get_current_date()

get_first_number(input_string[, as_string])

get_last_number(input_string)

get_last_letter(input_string)

get_end_number(input_string[, as_string])

Get the number at the end of a string.

get_trailing_number(input_string[, ...])

Get the number at the very end of a string.

search_first_number(input_string)

search_last_number(input_string)

Get the last number in a string.

search_last_letter(input_string)

Get the last letter in a string.

replace_last_number(input_string, replace_string)

Replace the last number with something.

increment_first_number(input_string)

increment_last_number(input_string[, padding])

Up the value of the last number by 1.

find_special(pattern, string_value, ...)

param pattern

A regular expression pattern to search for.

replace_string(string_value, replace_string, ...)

replace_string_at_end(line, ...)

replace_string_at_start(line, ...)

clean_file_string(string)

clean_name_string(string_value[, ...])

show_list_to_string(*args)

camel_to_underscore(name)

get_tabs()

get_log_tabs()

show(*args)

warning(*args)

error(*args)

is_left(side)

is_right(side)

is_center(side)

split_side_negative_number(name)

find_possible_combos(names[, sort, ...])

encode(key, clear)

decode(key, enc)

print_python_dir_nicely(python_object)

split_line(line[, splitter, quote_symbol])

This will split a line, ignoring anything inside quotes #re.split(';(?=(?:[^"]*"[^"]*")*[^"]*$)

replace_vtool(path_to_vtool)

Meant to have vtool look at a different path to load

remove_modules_at_path(path)

unload_vtool()

Removed currently sourced modules.

is_str(value)

get_square_bracket_numbers(input_string)

get_custom(name, default='')
stop_watch_wrapper(function)
class VetalaHTMLParser

Initialize and reset this instance.

If convert_charrefs is True (the default), all character references are automatically converted to the corresponding Unicode characters.

handle_starttag(tag, attrs)
handle_endtag(tag)
handle_data(data)
get_body_data()
CDATA_CONTENT_ELEMENTS = ('script', 'style')
check_for_whole_start_tag(i)
clear_cdata_mode()
close()

Handle any buffered data.

error(message)
feed(data)

Feed data to the parser.

Call this as often as you want, with as little or as much text as you want (may include ‘n’).

get_starttag_text()

Return full source of start tag: ‘<…>’.

getpos()

Return current line number and offset.

goahead(end)
handle_charref(name)
handle_comment(data)
handle_decl(decl)
handle_entityref(name)
handle_pi(data)
handle_startendtag(tag, attrs)
parse_bogus_comment(i, report=1)
parse_comment(i, report=1)
parse_declaration(i)
parse_endtag(i)
parse_html_declaration(i)
parse_marked_section(i, report=1)
parse_pi(i)
parse_starttag(i)
reset()

Reset this instance. Loses all unprocessed data.

set_cdata_mode(elem)
unescape(s)
unknown_decl(data)
updatepos(i, j)
class ControlName
CONTROL_ALIAS = 'Control Alias'
DESCRIPTION = 'Description'
NUMBER = 'Number'
SIDE = 'Side'
set_control_alias(alias)
set_left_alias(alias)
set_right_alias(alias)
set_center_alias(alias)
set_uppercase(bool_value)
set_control_order(list_value)
set_number_in_control_name(bool_value)
get_name(description, side=None)
get_code_builtins()
reset_code_builtins(builtins=None)
setup_code_builtins(builtin=None)
initialize_env(name)

Initialize a new environment variable. If the variable already exists, does nothing, no environment variable is initialized.

Parameters

name (str) – Name of the new environment variable.

set_env(name, value)

Set the value of an environment variable.

Parameters
  • name (str) – Name of the environment variable to set.

  • value (str) – If a number is supplied it will automatically be converted to str.

get_env(name)

Get the value of an environment variable.

Parameters

name (str) – Name of an environment variable.

Returns

str:

append_env(name, value)

Append string value to the end of the environment variable

suggest_env(name, value)
start_temp_log()
record_temp_log(value)
end_temp_log()
get_last_temp_log()
add_to_PYTHONPATH(path)

Add a path to the python path, only if it isn’t present in the python path.

Parameters

path (str) – The path to add to the python path.

profiler_event(frame, event, arg, indent=[0])
activate_profiler()

Activating the profiler will give extremely detailed information about what functions are running and in what order.

try_pass(function)

Try a function and if it fails pass. Used as a decorator. Usage: @try_pass def myFunction():

do_something

is_stopped()
is_in_maya()

Check to see if scope is in Maya.

Return type

bool

has_shotgun_api()

Check if the shotgun api is available.

Return type

bool

has_shotgun_tank()

Check if the shotgun tank api is available.

Return type

bool

get_current_maya_location()

Get where maya is currently running from.

is_in_nuke()

Check to see if scope is in Nuke

Return type

bool

is_linux()

Check to see if running in linux

Return type

bool

is_windows()

Check to see if running in windows

Return type

bool

get_maya_version()

Get the version of maya that the scope is running in.

Returns

The date of the Maya version.

Return type

int

break_signaled()

Check to see if Vetala break was signalled.

Return type

bool

class StopWatch

Utility to check how long a command takes to run.

running = 0
watch_list = []
start(description='', feedback=True)
end()
stop()
class VectorBase
class Vector2D(x=1.0, y=1.0)
normalize(in_place=False)
get_vector()
get_magnitude()
get_distance(x=0.0, y=0.0)
class Vector(x=1.0, y=1.0, z=1.0)
get_vector()
list()
class BoundingBox(btm_corner_vector, top_corner_vector)

Convenience for dealing with bounding boxes

Parameters
  • btm_corner_vector (list) – [0,0,0] vector of bounding box’s btm corner.

  • top_corner_vector (list) – [0,0,0] vector of bounding box’s top corner.

get_center()

Get the center of the bounding box in a vector.

Returns

[0,0,0] vector

Return type

list

get_xmin_center()
get_xmax_center()
get_ymax_center()

Get the top center of the bounding box in a vector.

Returns

[0,0,0] vector

Return type

list

get_ymin_center()

Get the btm center of the bounding box in a vector.

Returns

[0,0,0] vector

Return type

list

get_zmin_center()
get_zmax_center()
get_longest_two_axis_vectors()

get the two longest vectors of a single axis This can help when automatically placing joints

get_size()
get_size_no_y()
class Variable(name='empty')

Simple base class for variables on a node.

Parameters

name (str) – The name of the variable.

set_node(node_name)

Set the node to work on.

Parameters

node_name (str) –

set_name(name)

Set the name of the variable.

Parameters

name (str) – The name to give the variable.

set_value(value)

Set the value that the variable holds.

Parameters

value

create(node)
delete(node)
class Part(name)
create()
delete()
vector_multiply(vector, value)
Parameters
  • vector (list) – 3 value list

  • value (float) – value to multiply the vector by

Returns

3 value list

Return type

list

vector_divide(vector, value)
Parameters
  • vector (list) – 3 value list

  • value (float) – value to divide the vector by

Returns

3 value list

Return type

list

vector_magnitude(vector)

Get the magnitude of a vector. Good to see if there is any distance before doing a full distance calculation.

Parameters
  • vector (list) – 3 value list

  • value (float) – value to divide the vector by

Return type

float

vector_add(vector1, vector2)
Parameters
  • vector1 (list) – 3 value list

  • vector2 (list) – 3 value list

Returns

3 value list

Return type

list

vector_sub(vector1, vector2)
Parameters
  • vector1 (list) – 3 value list

  • vector2 (list) – 3 value list

Returns

3 value list

Return type

list

vector_cross(vector1, vector2, normalize=True)
Parameters
  • vector1 (list) – 3 value list

  • vector2 (list) – 3 value list

  • normalize (bool) – make the result a unit vector that has values from 0 - 1

Returns

3 value list

Return type

list

rotate_x_at_origin(vector, value, value_in_radians=False)

Rotate a vector around its x axis.

Parameters
  • vector (list) – 3 value list

  • value (float) – amount to rotate

  • value_in_radians (bool) – If the value is in radians, if not in degrees.

Returns

3 value list that is the result of the rotation.

Return type

list

rotate_y_at_origin(vector, value, value_in_radians=False)

Rotate a vector around its y axis.

Parameters
  • vector (list) – 3 value list

  • value (float) – amount to rotate

  • value_in_radians (bool) – If the value is in radians, if not in degrees.

Returns

3 value list that is the result of the rotation.

Return type

list

rotate_z_at_origin(vector, value, value_in_radians=False)

Rotate a vector around its z axis.

Parameters
  • vector (list) – 3 value list

  • value (float) – amount to rotate

  • value_in_radians (bool) – If the value is in radians, if not in degrees.

Returns

3 value list that is the result of the rotation.

Return type

list

get_axis_vector(axis_name, offset=1)

Convenience. Good for multiplying against a matrix.

Parameters

axis_name (str) – ‘X’ or ‘Y’ or ‘Z’

Returns

vector eg. (1,0,0) for ‘X’, (0,1,0) for ‘Y’ and (0,0,1) for ‘Z’

Return type

tuple

fade_sine(percent_value)
fade_cosine(percent_value)
fade_smoothstep(percent_value)
fade_sigmoid(percent_value)
set_percent_range(percent_value, new_min, new_max)
lerp(number1, number2, weight=0.5)

interpolate between number1 and number2 based on a 0-1 weight value

remap_value(value, old_min, old_max, new_min, new_max)
get_distance(vector1, vector2)

Get the distance between two vectors.

Parameters
  • vector1 (list) – eg. [0,0,0] vector

  • vector2 (list) – eg. [0,0,0] vector

Returns

The distance between the two vectors.

Return type

float

get_distance_2D(vector1_2D, vector2_2D)

Get the distance between two 2D vectors.

Parameters
  • vector1_2D (list) – eg. [0,0] vector

  • vector2_2D (list) – eg. [0,0] vector

Returns

The distance between the two 2D vectors.

Return type

float

get_magnitude_2D(vector_2D)
Parameters

vector_2D (list) – eg [0,0] vector

Returns

The magnitude of the vector.

Return type

float

get_dot_product(vector1, vector2)

Get the dot product of two vectors. Good for calculating angles.

Parameters
  • vector1 (list) – eg. [0,0,0] vector

  • vector2 (list) – eg. [0,0,0] vector

Returns

The dot product between the two vectors.

Return type

float

get_dot_product_2D(vector1_2D, vector2_2D)

Get the dot product of two 2D vectors. Good for calculating angles.

Parameters
  • vector1_2D (list) – eg. [0,0] vector

  • vector2_2D (list) – eg. [0,0] vector

Returns

The dot product between the two 2D vectors.

Return type

float

get_average(numbers)
Parameters

numbers (list) – A list of floats.

Returns

The average of the floats in numbers list.

Return type

float

get_midpoint(vector1, vector2)

Get the mid vector between two vectors.

Parameters
  • vector1 (list) – eg. [0,0,0] vector

  • vector2 (list) – eg. [0,0,0] vector

Returns

eg. [0,0,0] the midpoint vector between vector1 and vector2

Return type

list

get_inbetween_vector(vector1, vector2, percent=0.5)

Get a vector inbetween vector1 and vector2 at the percent

Parameters
  • vector1 (list) – eg. [0,0,0] vector

  • vector2 (list) – eg. [0,0,0] vector

  • percent (float) – The percent the vector should be between vector1 and vector2.

  • vector1. (0 percent will be exactly on) –

  • vector2. (0.5 percent will be exactly the midpoint between vector1 and) –

  • vector2.

Returns

eg. [0,0,0] the vector that represents the vector at the percentage between vector1 and vector2

Return type

list

get_simple_center_vector(list_of_vectors)
is_the_same_number(number1, number2, tolerance=1e-05)
convert_to_sequence(variable, sequence_type=<class 'list'>)

Easily convert to a sequence. If variable is already of sequence_type, pass it through. If variable is a list and sequence_type is tuple, convert to tuple. If variable is a tuple and sequence_type is list, convert to list. If variable is not a list or tuple, than create a sequence of sequence type.

Basically insures that a variable is a list or a tuple.

Parameters
  • variable – Any variable.

  • sequence_type – Can either be python list or python tuple. Needs to be the type ojbect, which means pass it list or tuple not as a string.

Returns

Returns list or tuple depending on the sequence_type.

Return type

list, tuple

line_side(start_vector, end_vector, position_vector)

Find out what side a position_vector is on given a line defined by start_vector and end_vector.

Parameters
  • start_vector (list) – eg. [0,0,0] vector end_vector (list): eg. [0,0,0] vector

  • position_vector (list) – eg. [0,0,0] vector

Returns

If positive it’s on one side of the line, if negative its on the other side.

Return type

float

closest_percent_on_line_3D(start_vector, end_vector, position_vector, clamp=True)

Get how far a vector is on a line. If the vector is on start_vector, return 0. If vector is on end vector, return 1. If vector is half way between start and end return 0.5.

closest_percent_on_line_2D(start_vector, end_vector, position_vector, clamp=True)

Get how far a vector is on a line. If the vector is on start_vector, return 0. If vector is on end vector, return 1. If vector is half way between start and end return 0.5.

closest_point_to_line_2D(start_vector, end_vector, position_vector, clamp=True, return_percent=False)
uv_to_udim(u, v)
convert_number_to_month(month_int)
get_current_time(date_and_time=True)
get_current_date()
class FindUniqueString(test_string)
set_padding(int_value)
get()
get_first_number(input_string, as_string=False)
get_last_number(input_string)
get_last_letter(input_string)
get_end_number(input_string, as_string=False)

Get the number at the end of a string.

Parameters

input_string (str) – The string to search for a number.

Returns

The number at the end of the string.

Return type

int

get_trailing_number(input_string, as_string=False, number_count=- 1)

Get the number at the very end of a string. If number not at the end of the string return None.

search_first_number(input_string)
search_last_number(input_string)

Get the last number in a string.

Parameters

input_string (str) – The string to search for a number.

Returns

The last number in the string.

Return type

int

search_last_letter(input_string)

Get the last letter in a string.

Parameters

input_string (str) – The string to search for a number.

Returns

The last number in the string.

Return type

int

replace_last_number(input_string, replace_string)

Replace the last number with something.

Parameters
  • input_string (str) – A string to search for the last number.

  • replace_string (str) – The string to replace the last number with.

Returns

The new string after replacing.

Return type

str

increment_first_number(input_string)
increment_last_number(input_string, padding=1)

Up the value of the last number by 1.

Parameters

input_string (str) – The string to search for the last number.

Returns

The new string after the last number is incremented.

Return type

str

find_special(pattern, string_value, position_string)
Parameters
  • pattern (str) – A regular expression pattern to search for.

  • string_value (str) – The string to search in.

  • position_string (str) – ‘start’,’end’,’first’,’last’,’inside’ Where the pattern should search.

Returns

(start_int, end_int) The start and end index of the found pattern. Returns (None,None) if nothing found.

Return type

tuple

replace_string(string_value, replace_string, start, end)
replace_string_at_end(line, string_to_replace, replace_string)
replace_string_at_start(line, string_to_replace, replace_string)
clean_file_string(string)
clean_name_string(string_value, clean_chars='_', remove_char='_')
show_list_to_string(*args)
camel_to_underscore(name)
get_tabs()
get_log_tabs()
show(*args)
warning(*args)
error(*args)
is_left(side)
is_right(side)
is_center(side)
split_side_negative_number(name)
find_possible_combos(names, sort=False, one_increment=False)
class QuickSort(list_of_numbers)

Really fast method for sorting.

set_follower_list(list_of_anything)

This list much match the length of the list given when the class was initialized.

run()

If no follower list supplied, return number list sorted: list If follower list supplied, return number list and follower list: (list, list)

encode(key, clear)
decode(key, enc)
print_python_dir_nicely(python_object)
split_line(line, splitter=';', quote_symbol='"')

This will split a line, ignoring anything inside quotes #re.split(‘;(?=(?:[^”]*”[^”]*”)*[^”]*$)

replace_vtool(path_to_vtool)

Meant to have vtool look at a different path to load

remove_modules_at_path(path)
unload_vtool()

Removed currently sourced modules. This allows you to insert a custom path at the start of the sys.path and load vetala from there.

is_str(value)
get_square_bracket_numbers(input_string)