Re: [Maya-Python] Re: When to use Logical Indicies over Physical Indicies

2016-10-27 Thread Cedric Bazillou
#So i did a quick test and i post a incorrect answer previously:

import maya.cmds
import maya.OpenMaya 

targetNode = maya.cmds.createNode('transform')
maya.cmds.addAttr(targetNode, ln='input', m=True, v=True)

for index in [12, 13, 16, 23]:
maya.cmds.setAttr('{0}.input[{1}]'.format(targetNode, index), index)

selList = maya.OpenMaya.MSelectionList()
maya.OpenMaya.MGlobal.getSelectionListByName(targetNode,  selList)
depNode = maya.OpenMaya.MObject()
selList.getDependNode(0, depNode) 

depUtils = maya.OpenMaya.MFnDependencyNode(depNode)
inputPlug = depUtils.findPlug('input')

print inputPlug.name()
indices = maya.OpenMaya.MIntArray()
inputPlug.getExistingArrayAttributeIndices(indices)
print indices
print inputPlug.numElements()

indexToRead = 0
print inputPlug.elementByPhysicalIndex(indexToRead).name()

#---
"""
*elementByPhysicalIndex(indexToRead) == indices[indexToRead]*

elementByPhysicalIndex refers to relative index in your array
elementByLogicalIndex will mostly point out to the connection *slot *of the 
attribute ( the element hosting the data )

what is dangerous if you use elementByLogicalIndex is that maya will create 
an input/output element at this connection index if its empty(its the 
standard behavior by the way).
in your datablock it migh be better to avoid using MPlug ( you can do 
everything cleanly with attribute).
"""

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/f143efee-cf80-4cb4-acd1-97ad44656d1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: When to use Logical Indicies over Physical Indicies

2016-10-27 Thread Cedric Bazillou
I dont have maya at work but from what you wrote i think you understood it 
the reverse way your physical index are 12, 13, 26.
Maya when it will process the datablock work on them in a sorted order so 
the logical index 0 will refer to physical index 12  (1 -> 13) and so on.

>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/978997fc-117a-47ad-b405-d63d65e04af0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: When to use Logical Indicies over Physical Indicies

2016-10-26 Thread Dylan Smith
I've used Maya a fair bit, but I've only just started working with the API
and the Node side of things. Before this I've mainly used it for modelling
and UV'ing. Though I've also used Houdini a bunch so I am familiar with
Node based workflows. With your example of the 'inputGeometry' attribute,
from what I've read from the documentation (the specific page I'm referring
to is linked below) it seems like instead of using Logical Indexes 12, 13,
and 26 to access those three plugs, I could simply use Physical Indexes of
0, 1, and 2 instead. From what you're saying I'm guessing this is
incorrect, but I'm not sure why. Would you be able to expand on the
iterator explanation please? I don't quite understand it.

MPlug Reference Page;
http://help.autodesk.com/view/MAYAUL/2017/ENU/?guid=__cpp_ref_class_m_plug_html

On Thu, Oct 27, 2016 at 6:31 AM, Cedric Bazillou 
wrote:

> Its a really robust and flexible mechanism which makes perfect sense in a
> nodal application...
> Array attribute ( vertical one like ouput[0], output[n] ) can potentially
> be sparse : it means no contiguous so inputGeometry[12], inputGeometry[13],
> inputGeometry[26] are perfectly valid
> let say you have an iterator in your deformer what you are interested in
> is process element and not attached to physical index you need to extract
> to access these data.
>
> How much experience do you have with maya ?
>
>
> Le mercredi 26 octobre 2016 04:42:44 UTC-4, Dylan Smith a écrit :
>>
>> Hey Everyone,
>> I was hoping someone could clear up something for me. When would we want
>> to use Logical indexes instead of Physical ones.
>> I've been reading through some documentation and the MPlug Class
>> Reference explains what they are, but not when we should use one or the
>> other.
>> From my understanding of the Maya API, I can't think of a reason to ever
>> use Logical indexes . To me it just seems like an unnecessary source of
>> potential confusion and bugs.
>> If I'm using physical indexes then I know that the second plug will
>> always be index 1. But with logical indexes it could be anything. The
>> physical option seems like the more appealing,
>> but if both options are in there then I assume there's a good reason for
>> it. What am I missing here? I've tried searching the documentation for an
>> answer but am yet to find anything.
>>
>> Thanks in advance for any help :)
>> Dylan
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/python_inside_maya/HPX99HYdGts/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/27b3a353-3f66-4195-8975-
> 0554c8c95d3a%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFxZShr2oJVjQfENfkx88K3EkPmZJR07ew8c8R24HP0hg%3D-%2B%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: When to use Logical Indicies over Physical Indicies

2016-10-26 Thread Cedric Bazillou
Its a really robust and flexible mechanism which makes perfect sense in a 
nodal application...
Array attribute ( vertical one like ouput[0], output[n] ) can potentially 
be sparse : it means no contiguous so inputGeometry[12], inputGeometry[13], 
inputGeometry[26] are perfectly valid
let say you have an iterator in your deformer what you are interested in is 
process element and not attached to physical index you need to extract to 
access these data.

How much experience do you have with maya ?


Le mercredi 26 octobre 2016 04:42:44 UTC-4, Dylan Smith a écrit :
>
> Hey Everyone,
> I was hoping someone could clear up something for me. When would we want 
> to use Logical indexes instead of Physical ones.
> I've been reading through some documentation and the MPlug Class Reference 
> explains what they are, but not when we should use one or the other.
> From my understanding of the Maya API, I can't think of a reason to ever 
> use Logical indexes . To me it just seems like an unnecessary source of 
> potential confusion and bugs. 
> If I'm using physical indexes then I know that the second plug will always 
> be index 1. But with logical indexes it could be anything. The physical 
> option seems like the more appealing,
> but if both options are in there then I assume there's a good reason for 
> it. What am I missing here? I've tried searching the documentation for an 
> answer but am yet to find anything.
>
> Thanks in advance for any help :)
> Dylan
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/27b3a353-3f66-4195-8975-0554c8c95d3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.