Thanks, all!

This steered me own the right path and I ended up... feeling like an
idiot.  Fundamentally, self.name() is what I needed. Thank you!

On Oct 19, 9:02 am, Paul Molodowitch <elron...@gmail.com> wrote:
> Try this code:
>
> def getInputName(plug):
>         plugArray = api.MPlugArray()
>         plug.connectedTo(plugArray, True, False)
>         # Should only have one input connection!
>         if plugArray.length() == 0:
>                 return None
>         elif plugArray.length() == 1:
>                 return plugArray[0].name()
>         else:
>                 # For an input plug, should only be 0 or 1
>                 # connections!
>                 raise RuntimeError
>
> If you want to get all the input connections to an array plug, you
> would loop through
> the element plugs with something like:
>
> arrayInputs = {}
> for i in xrange(arrayPlug.numElements()):
>         elementPlug = arrayPlug[i];
>         arrayInputs[elementPlug.logicalIndex()] = getInputName(elementPlug)
>
> - Paul
>
> On Mon, Oct 19, 2009 at 8:46 AM, Paul Molodowitch <elron...@gmail.com> wrote:
> > Have you already looked into MPlug.connectedTo, followed by
> > MPlug.name()?  (I guess in your case you might also have to first do
> > MPlug.elementByLogicalIndex(0), if you are given the plug for
> > myNode.in, and want to see what's connected to myNode.in[0]...)
>
> > - Paul
>
> > On Mon, Oct 19, 2009 at 1:40 AM, Olivier Georges
> > <olivier.georges.h...@gmail.com> wrote:
> >> perhaps you can use MPlug:: info that will return a MString or perhaps
> >> MPlug:: getSetAttrCmds  too.
> >> I don't use python for the API yet, but with the c++ API, it will be what
> >> I'd tried...
>
> >> Olivier.
>
> >> 2009/10/19 jasonosipa <jason.os...@gmail.com>
>
> >>> I need to retrieve the obj.attr *string* of a connection into my
> >>> plugin node as a usable string inside my compute function.
>
> >>> For example, if I have pCube1.tx connected into myNode.in[0], I want
> >>> to be able to access the string "pCube1.tx".  I can get at the *data*
> >>> from that connection no problem,  but for my particular uses, what I
> >>> am after is that string "pCube1.tx".  I've poked around most of today,
> >>> but am not really coming up with anything that works.  Ideas?  Is
> >>> there someway to get at that?
>
> >>> My first thought was there was a way to do it directly, but can't seem
> >>> to find a way, so now my fallback seems to be to find a way to get the
> >>> current instance of myNode as a scene object (which I'm not sure how
> >>> to do) and do a listConnections from myNode.in[0] to figure it out
> >>> from there. Either way, haven't been able to make this work just yet.
>
> >>> I know this sounds like I am probably going about something the wrong
> >>> way, but it is in fact quite critical to my goal to get the string,
> >>> and not just the attr data.
>
> >>> Thank you in advance!  You guys here always sort me out and I
> >>> appreciate it!
>
>
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to