Skip to content

Commit

Permalink
Implemented Transform.create()
Browse files Browse the repository at this point in the history
  • Loading branch information
kimonmatara committed Jun 23, 2022
1 parent 1af1ed4 commit 3bfa91a
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ for attribute (including subtype), component and data types with true inheritanc

* Improvements to name management and plug setting

See `here <https://kimonmatara.github.io/paya/>`_ for full documentation.
* And `more <https://kimonmatara.github.io/paya/whats_new.html>`_!


Full documentation can be found `here <https://kimonmatara.github.io/paya/>`_.
Binary file modified datatypes/__pycache__/matrix.cpython-37.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ for attribute (including subtype), component and data types with true inheritanc

See :doc:`here <whats_new>` for the full list.


Example: Rigging a Radial Repulsor
----------------------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/_sources/package_config.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ keyword arguments and reverted on block exit:
# eye_joint
To make permanent changes to the Paya configuration, edit ``paya/config.json`` directly and restart Maya. For more
information on customising node naming behaviour, see `Node Names <naming_nodes>`.
information on customising node naming behaviour, see :doc:`Node Names <naming_nodes>`.
24 changes: 24 additions & 0 deletions docs/_sources/paya/nodetypes/transform.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@ paya.nodetypes.transform.Transform
.. py:class:: Transform(*args, **kwargs)
.. py:classmethod:: create(dagPath=None, name=None, under=None, displayLocalAxis=False, rotateOrder='xyz', worldMatrix=None)
Creates transform nodes.

:param dagPath/dp: an explicit DAG path; defaults to None
:type dagPath/dp: None, str
:param name/n: one or more name elements; ignored if ``dagPath`` is
provided; defaults to None
:type name/n: int, str, list, tuple or None
:param under/u: an optional parent for the transform; if this is
combined with ``dagPath``, then this node's DAG path will be
prepended; defaults to None
:type under/u: None, str, :class:`~paya.nodetypes.transform.Transform`
:param bool displayLocalAxis/dla: display the transform's local axes;
defaults to False
:param rotateOrder/ro: the transform's rotate order; defaults to 'xyz'
:type rotateOrder/ro: int, str or None
:param worldMatrix/wm: an optional world matrix for the transform,
applied to the SRT channels; defaults to None
:type worldMatrix/wm: None, list, tuple or
:class:`~paya.datatypes.matrix.Matrix`
:return: The transform.
:rtype: :class:`~paya.nodetypes.transform.Transform`

.. py:method:: releaseSRT()
Unlocks and disconnects every SRT channel, recursively.
Expand Down
2 changes: 2 additions & 0 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ <h2 id="C">C</h2>

<ul>
<li><a href="paya/nodetypes/joint.html#paya.nodetypes.joint.Joint.create">(Joint class method)</a>
</li>
<li><a href="paya/nodetypes/transform.html#paya.nodetypes.transform.Transform.create">(Transform class method)</a>
</li>
</ul></li>
<li><a href="paya/lib/skel.html#paya.lib.skel.Chain.createFromCurve">createFromCurve() (Chain class method)</a>
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/package_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h1>Package Configuration<a class="headerlink" href="#package-configuration" tit
</pre></div>
</div>
<p>To make permanent changes to the Paya configuration, edit <code class="docutils literal notranslate"><span class="pre">paya/config.json</span></code> directly and restart Maya. For more
information on customising node naming behaviour, see <cite>Node Names &lt;naming_nodes&gt;</cite>.</p>
information on customising node naming behaviour, see <a class="reference internal" href="naming_nodes.html"><span class="doc">Node Names</span></a>.</p>
</section>


Expand Down
30 changes: 30 additions & 0 deletions docs/paya/nodetypes/transform.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,36 @@
<dt class="sig sig-object py" id="paya.nodetypes.transform.Transform">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">Transform</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#paya.nodetypes.transform.Transform" title="Permalink to this definition"></a></dt>
<dd><dl class="py method">
<dt class="sig sig-object py" id="paya.nodetypes.transform.Transform.create">
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">create</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dagPath</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">under</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">displayLocalAxis</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rotateOrder</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'xyz'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">worldMatrix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#paya.nodetypes.transform.Transform.create" title="Permalink to this definition"></a></dt>
<dd><p>Creates transform nodes.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dagPath/dp</strong> (<em>None</em><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a>) – an explicit DAG path; defaults to None</p></li>
<li><p><strong>name/n</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.10)"><em>list</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.10)"><em>tuple</em></a><em> or </em><em>None</em>) – one or more name elements; ignored if <code class="docutils literal notranslate"><span class="pre">dagPath</span></code> is
provided; defaults to None</p></li>
<li><p><strong>under/u</strong> (None, str, <a class="reference internal" href="#paya.nodetypes.transform.Transform" title="paya.nodetypes.transform.Transform"><code class="xref py py-class docutils literal notranslate"><span class="pre">Transform</span></code></a>) – an optional parent for the transform; if this is
combined with <code class="docutils literal notranslate"><span class="pre">dagPath</span></code>, then this node’s DAG path will be
prepended; defaults to None</p></li>
<li><p><strong>displayLocalAxis/dla</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.10)"><em>bool</em></a>) – display the transform’s local axes;
defaults to False</p></li>
<li><p><strong>rotateOrder/ro</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.10)"><em>int</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.10)"><em>str</em></a><em> or </em><em>None</em>) – the transform’s rotate order; defaults to ‘xyz’</p></li>
<li><p><strong>worldMatrix/wm</strong> (None, list, tuple or
<a class="reference internal" href="../datatypes/matrix.html#paya.datatypes.matrix.Matrix" title="paya.datatypes.matrix.Matrix"><code class="xref py py-class docutils literal notranslate"><span class="pre">Matrix</span></code></a>) – an optional world matrix for the transform,
applied to the SRT channels; defaults to None</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The transform.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#paya.nodetypes.transform.Transform" title="paya.nodetypes.transform.Transform"><code class="xref py py-class docutils literal notranslate"><span class="pre">Transform</span></code></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paya.nodetypes.transform.Transform.releaseSRT">
<span class="sig-name descname"><span class="pre">releaseSRT</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#paya.nodetypes.transform.Transform.releaseSRT" title="Permalink to this definition"></a></dt>
<dd><p>Unlocks and disconnects every SRT channel, recursively.</p>
Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

Binary file modified nodetypes/__pycache__/transform.cpython-37.pyc
Binary file not shown.
101 changes: 101 additions & 0 deletions nodetypes/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,107 @@

class Transform:

#--------------------------------------------------------| Constructor

@classmethod
@short(
dagPath='dp',
name='n',
rotateOrder='ro',
worldMatrix='wm'
)
def create(
cls,
dagPath=None,
name=None,
under=None,
displayLocalAxis=False,
rotateOrder='xyz',
worldMatrix=None
):
"""
Creates transform nodes.
:param dagPath/dp: an explicit DAG path; defaults to None
:type dagPath/dp: None, str
:param name/n: one or more name elements; ignored if ``dagPath`` is
provided; defaults to None
:type name/n: int, str, list, tuple or None
:param under/u: an optional parent for the transform; if this is
combined with ``dagPath``, then this node's DAG path will be
prepended; defaults to None
:type under/u: None, str, :class:`~paya.nodetypes.transform.Transform`
:param bool displayLocalAxis/dla: display the transform's local axes;
defaults to False
:param rotateOrder/ro: the transform's rotate order; defaults to 'xyz'
:type rotateOrder/ro: int, str or None
:param worldMatrix/wm: an optional world matrix for the transform,
applied to the SRT channels; defaults to None
:type worldMatrix/wm: None, list, tuple or
:class:`~paya.datatypes.matrix.Matrix`
:return: The transform.
:rtype: :class:`~paya.nodetypes.transform.Transform`
"""
if dagPath:
fromRoot = dagPath.startswith('|')
dagPath = dagPath.strip('|')

if under:
under = r.PyNode(under)
head = under.name(long=True)

if dagPath.startswith('|'):
dagPath = dagPath[1:]

dagPath = head + dagPath

elems = dagPath.split('|')
num = len(elems)

group = None
coveredDepth = 0

for i in reversed(range(num)):
theseElems = elems[:i+1]
thisDagPath = '|'.join(theseElems)

if fromRoot:
thisDagPath = '|' + thisDagPath

matches = r.ls(thisDagPath)

if matches:
group = matches[0]
coveredDepth = i+1
break

for i in range(coveredDepth, num):
requiredElem = elems[i]

kwargs = {}

if group:
kwargs['parent'] = group

group = r.group(empty=True, name=requiredElem, **kwargs)

else:
name = cls.makeName(n=name)
group = r.group(empty=True, n=name)

if worldMatrix:
group.setMatrix(worldMatrix)

if under:
group.setParent(under)

if displayLocalAxis:
group.attr('displayLocalAxis').set(True)

group.attr('ro').set(rotateOrder)

return group

#--------------------------------------------------------| Attr management

def releaseSRT(self):
Expand Down
Binary file modified plugtypes/__pycache__/matrix.cpython-37.pyc
Binary file not shown.

0 comments on commit 3bfa91a

Please sign in to comment.