1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
|
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>General Utilities — ARTv2 2.0.1 documentation</title>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Interface Utilities" href="interface_utils.html" />
<link rel="prev" title="Error Utilities" href="error_utils.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> ARTv2
</a>
<div class="version">
2.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="installing.html">Installing ARTv2</a></li>
<li class="toctree-l1"><a class="reference internal" href="using_rigging_tools.html">Using the Rigging Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="using_anim_tools.html">Using the Animation Tools</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="technical_documentation.html">Technical Documentation</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="useful_scripting_commands.html">Useful Scripting Commands</a></li>
<li class="toctree-l2"><a class="reference internal" href="sections/tech_docs/components/components.html">Components</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="utilities.html">Utilities</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="component_utils.html">Component Utilities</a></li>
<li class="toctree-l3"><a class="reference internal" href="error_utils.html">Error Utilities</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">General Utilities</a></li>
<li class="toctree-l3"><a class="reference internal" href="interface_utils.html">Interface Utilities</a></li>
<li class="toctree-l3"><a class="reference internal" href="joint_mover_utils.html">Joint Mover Utilities</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">ARTv2</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li><a href="technical_documentation.html">Technical Documentation</a> »</li>
<li><a href="utilities.html">Utilities</a> »</li>
<li>General Utilities</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/general_utils.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="general-utilities">
<h1>General Utilities<a class="headerlink" href="#general-utilities" title="Permalink to this headline">¶</a></h1>
<p><em>Code author: Jeremy Ernst</em></p>
<span class="target" id="module-artv2_utilities.general_utilities"></span><p>This module provides utilities usually for returning information, handling paths, or building strings.</p>
<div class="section" id="functions">
<h2>Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><a class="reference internal" href="#artv2_utilities.general_utilities.convert_to_pynodes" title="artv2_utilities.general_utilities.convert_to_pynodes"><code class="xref py py-func docutils literal notranslate"><span class="pre">convert_to_pynodes</span></code></a></li>
<li><a class="reference internal" href="#artv2_utilities.general_utilities.create_asset" title="artv2_utilities.general_utilities.create_asset"><code class="xref py py-func docutils literal notranslate"><span class="pre">create_asset</span></code></a></li>
<li><a class="reference internal" href="#artv2_utilities.general_utilities.filter_nodes" title="artv2_utilities.general_utilities.filter_nodes"><code class="xref py py-func docutils literal notranslate"><span class="pre">filter_nodes</span></code></a></li>
<li><a class="reference internal" href="#artv2_utilities.general_utilities.get_joints_in_hierarchy" title="artv2_utilities.general_utilities.get_joints_in_hierarchy"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_joints_in_hierarchy</span></code></a></li>
<li><a class="reference internal" href="#artv2_utilities.general_utilities.get_root_joint_of_component" title="artv2_utilities.general_utilities.get_root_joint_of_component"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_root_joint_of_component</span></code></a></li>
<li><a class="reference internal" href="#artv2_utilities.general_utilities.import_file" title="artv2_utilities.general_utilities.import_file"><code class="xref py py-func docutils literal notranslate"><span class="pre">import_file</span></code></a></li>
<li><a class="reference internal" href="#artv2_utilities.general_utilities.parent_object" title="artv2_utilities.general_utilities.parent_object"><code class="xref py py-func docutils literal notranslate"><span class="pre">parent_object</span></code></a></li>
<li><a class="reference internal" href="#artv2_utilities.general_utilities.path_join" title="artv2_utilities.general_utilities.path_join"><code class="xref py py-func docutils literal notranslate"><span class="pre">path_join</span></code></a></li>
<li><a class="reference internal" href="#artv2_utilities.general_utilities.path_unify" title="artv2_utilities.general_utilities.path_unify"><code class="xref py py-func docutils literal notranslate"><span class="pre">path_unify</span></code></a></li>
<li><a class="reference internal" href="#artv2_utilities.general_utilities.rename_object" title="artv2_utilities.general_utilities.rename_object"><code class="xref py py-func docutils literal notranslate"><span class="pre">rename_object</span></code></a></li>
<li><a class="reference internal" href="#artv2_utilities.general_utilities.return_settings" title="artv2_utilities.general_utilities.return_settings"><code class="xref py py-func docutils literal notranslate"><span class="pre">return_settings</span></code></a></li>
<li><a class="reference internal" href="#artv2_utilities.general_utilities.set_attribute" title="artv2_utilities.general_utilities.set_attribute"><code class="xref py py-func docutils literal notranslate"><span class="pre">set_attribute</span></code></a></li>
<li><a class="reference internal" href="#artv2_utilities.general_utilities.strip_name" title="artv2_utilities.general_utilities.strip_name"><code class="xref py py-func docutils literal notranslate"><span class="pre">strip_name</span></code></a></li>
</ul>
<dl class="function">
<dt id="artv2_utilities.general_utilities.convert_to_pynodes">
<code class="descname">convert_to_pynodes</code><span class="sig-paren">(</span><em>nodes</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/artv2_utilities/general_utilities.html#convert_to_pynodes"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#artv2_utilities.general_utilities.convert_to_pynodes" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts the incoming nodes to PyNodes and returns them.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>nodes</strong> – String list of nodes to convert.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">List of PyNodes</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="artv2_utilities.general_utilities.create_asset">
<code class="descname">create_asset</code><span class="sig-paren">(</span><em>asset_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/artv2_utilities/general_utilities.html#create_asset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#artv2_utilities.general_utilities.create_asset" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a container asset with the given asset name and return the created container.
:param asset_name: Name for container.
:return: pyNode of created asset.</p>
</dd></dl>
<dl class="function">
<dt id="artv2_utilities.general_utilities.filter_nodes">
<code class="descname">filter_nodes</code><span class="sig-paren">(</span><em>nodes</em>, <em>filter_by='transform'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/artv2_utilities/general_utilities.html#filter_nodes"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#artv2_utilities.general_utilities.filter_nodes" title="Permalink to this definition">¶</a></dt>
<dd><p>Filters the given nodes by the given type and returns the filtered nodes as a list.
:param nodes: List of nodes to filter.
:param str filter_by: Types of nodes to return.
:return: List of filtered nodes.</p>
</dd></dl>
<dl class="function">
<dt id="artv2_utilities.general_utilities.get_joints_in_hierarchy">
<code class="descname">get_joints_in_hierarchy</code><span class="sig-paren">(</span><em>root=None</em>, <em>as_pynode=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/artv2_utilities/general_utilities.html#get_joints_in_hierarchy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#artv2_utilities.general_utilities.get_joints_in_hierarchy" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the joints in a hierarchy and returns them. If a root joint is given, it will search from there. If not,
it will select everything in the scene and find the joints that way instead.
:param root: (Optional) Name of joint at the top of the hierarchy you wish to search.
:param as_pynode: Bool as whether to return the list as PyNodes or strings.
:return: Returns either a list of PyNodes or strings of the joints in the hierarchy.</p>
</dd></dl>
<dl class="function">
<dt id="artv2_utilities.general_utilities.get_root_joint_of_component">
<code class="descname">get_root_joint_of_component</code><span class="sig-paren">(</span><em>joints</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/artv2_utilities/general_utilities.html#get_root_joint_of_component"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#artv2_utilities.general_utilities.get_root_joint_of_component" title="Permalink to this definition">¶</a></dt>
<dd><p>Finds and returns the top-most joint of a component.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>joints</strong> – List of Pynodes of joints from the component.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Pynode of top-most joint.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="artv2_utilities.general_utilities.import_file">
<code class="descname">import_file</code><span class="sig-paren">(</span><em>path</em>, <em>return_nodes=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/artv2_utilities/general_utilities.html#import_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#artv2_utilities.general_utilities.import_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Imports the given file into Maya.
:param path: Path of file to import
:param return_nodes: Whether or not to return created nodes.
:return: list of imported nodes</p>
</dd></dl>
<dl class="function">
<dt id="artv2_utilities.general_utilities.parent_object">
<code class="descname">parent_object</code><span class="sig-paren">(</span><em>child</em>, <em>parent</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/artv2_utilities/general_utilities.html#parent_object"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#artv2_utilities.general_utilities.parent_object" title="Permalink to this definition">¶</a></dt>
<dd><p>Parents the child to the parent object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>child</strong> (<em>str</em>) – Name of node to be parented.</li>
<li><strong>parent</strong> (<em>str</em>) – Name of node that will be the parent.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="artv2_utilities.general_utilities.path_join">
<code class="descname">path_join</code><span class="sig-paren">(</span><em>path_base</em>, <em>path_tail</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/artv2_utilities/general_utilities.html#path_join"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#artv2_utilities.general_utilities.path_join" title="Permalink to this definition">¶</a></dt>
<dd><p>Take the incoming path and file and use os.path.join to create a new file path. Then replace all
back slashes with forward slashes.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>path_base</strong> (<em>str</em>) – First part of path to join.</li>
<li><strong>path_tail</strong> (<em>str</em>) – Second part of path to join.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Joined path with proper separators.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="artv2_utilities.general_utilities.path_unify">
<code class="descname">path_unify</code><span class="sig-paren">(</span><em>path</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/artv2_utilities/general_utilities.html#path_unify"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#artv2_utilities.general_utilities.path_unify" title="Permalink to this definition">¶</a></dt>
<dd><p>Take the incoming path and replace back slashes with forward slashes.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path</strong> (<em>str</em>) – Incoming path to manipulate.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Corrected path with correct separators.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="artv2_utilities.general_utilities.rename_object">
<code class="descname">rename_object</code><span class="sig-paren">(</span><em>pynode</em>, <em>new_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/artv2_utilities/general_utilities.html#rename_object"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#artv2_utilities.general_utilities.rename_object" title="Permalink to this definition">¶</a></dt>
<dd><p>Renames the incoming PyNode with the given new name.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>pynode</strong> (<em>pymel.core.PyNode</em>) – PyNode that represents the object to rename.</li>
<li><strong>new_name</strong> (<em>str</em>) – The new name for the node.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="artv2_utilities.general_utilities.return_settings">
<code class="descname">return_settings</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/artv2_utilities/general_utilities.html#return_settings"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#artv2_utilities.general_utilities.return_settings" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns ARTv2 settings for the paths to various needed directories.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array of path names to directories needed by the tools.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str, []</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="artv2_utilities.general_utilities.set_attribute">
<code class="descname">set_attribute</code><span class="sig-paren">(</span><em>node</em>, <em>attr</em>, <em>value</em>, <em>attr_type=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/artv2_utilities/general_utilities.html#set_attribute"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#artv2_utilities.general_utilities.set_attribute" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets an attribute on the given node to the given value. Ensures node and attribute is unlocked before doing so, and
re-locks them after.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>node</strong> (<em>pm.PyNode</em>) – Node to set attribute on.</li>
<li><strong>attr</strong> (<em>str</em>) – Attribute on node to set.</li>
<li><strong>value</strong> (<em>float</em><em>, </em><em>int</em><em>, </em><em>bool</em><em>, </em><em>string</em>) – Value to set attribute to.</li>
<li><strong>attr_type</strong> (<em>str</em>) – Whether or not a special type needs to be defined (string, bool, etc)</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="artv2_utilities.general_utilities.strip_name">
<code class="descname">strip_name</code><span class="sig-paren">(</span><em>name_to_strip</em>, <em>prefix</em>, <em>base_name</em>, <em>suffix</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/artv2_utilities/general_utilities.html#strip_name"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#artv2_utilities.general_utilities.strip_name" title="Permalink to this definition">¶</a></dt>
<dd><p>Strip a name down to whatever is left after removing the prefix, base name, and suffix.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>name_to_strip</strong> (<em>str</em>) – The name to tokenize.</li>
<li><strong>prefix</strong> (<em>str</em>) – The prefix to remove from the name.</li>
<li><strong>base_name</strong> (<em>str</em><em>, </em><em>None</em>) – The base name of the component to remove from the name.</li>
<li><strong>suffix</strong> (<em>str</em>) – The suffix to remove from the name.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The name with the prefix, suffix, and base name removed.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="interface_utils.html" class="btn btn-neutral float-right" title="Interface Utilities" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="error_utils.html" class="btn btn-neutral float-left" title="Error Utilities" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2018, Jeremy Ernst
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>
|