pymel does it with two queries using cmds.listConnections as well, plus a
bunch of other stuff wrapped around it to sort, split, convert, etc.


On Tue, Dec 11, 2012 at 11:19 AM, Jesse Capper <jesse.cap...@gmail.com>wrote:

> As a bit of an aside, I wish cmds.listConnections had an option to return
> connections in source/destination pairs or ordering like pymel does. Is
> there a better way to handle disconnecting attributes with an unknown
> direction than querying twice like so?
>
> for attr in attrs:
>     src_conns = cmds.listConnections(attr, d=False, p=True) or []
>     for conn in src_conns:
>         cmds.disconnectAttr(conn, attr)
>     dst_conns = cmds.listConnections(attr, s=False, p=True) or []
>     for conn in dst_conns:
>         cmds.disconnectAttr(attr, conn)
>
> On Tuesday, December 11, 2012 9:05:46 AM UTC-8, Justin Israel wrote:
> > If you have a list of material attributes like this:
> >
> > mats = ['material1.color', 'material2.color']
> >
> >
> > Then you can loop over it and disconnect like this:
> >
> >
> > for mat in mats:
> >     conns = cmds.listConnections(mat, p=True) or []
> >     for conn in conns:
> >         cmds.disconnectAttr(conn, mat)
> >
> >
> > If I missed your question, can you post an example of what you have so
> far so I can see what is not working?
> >
> >
> >
> >
> >
> >
> >
> > On Dec 11, 2012, at 5:51 AM, Daz wrote:
> >
> > Heya
> >
> > Right, that do gives me what I want thanks ! I had a feeling its one of
> settings I just failed to understand it properly...
> >
> > Anyway since I'm writing here got 1 more question.
> >
> > I have a list of materials and then a list of specific connections to
> those materials.
> >
> > Is there a way to disconnect those connection from those materials?
> >
> > My test fail somehow because(I think) every time I go through loop I end
> up trying to disconnect wrong nodes from wrong materials, since it goes one
> by one over list...
> >
> > Not sure if I can match up list somehow or tell it to pick 1 mat, get
> its connections, break them, move to next node
> >
> > Is there a way to do it ? Must be I guess I just didn't find out the
> proper command or how to name it...
> >
> > Thanks, bye.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Python Programming for Autodesk Maya" group.
> > To post to this group, send email to python_in...@googlegroups.com.
> > To unsubscribe from this group, send email to
> python_inside_maya+unsubscr...@googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To post to this group, send email to python_inside_maya@googlegroups.com.
> To unsubscribe from this group, send email to
> python_inside_maya+unsubscr...@googlegroups.com.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To post to this group, send email to python_inside_maya@googlegroups.com.
To unsubscribe from this group, send email to 
python_inside_maya+unsubscr...@googlegroups.com.


Reply via email to