attrs=["constructionHistory",
"gravity",
"gravityY",
"gravityZ",
"nodeState",
"offset",
"pivot"]
pm.polyExtrudeFacet(*attrs)
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c846f255-057e-4c39-ad35-f60f23c899ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You want to pass a value of 1 for each attr in the list as a key? You can convert it to a dict and then use unpacking
kw = dict((a, 1) for a in attrs)
pm.polyExtrudeFacet(extrusion, q=1, **kw)
--
After a second, and Justin’s read it occurred to me that though my example answers your question on how to pass flags via a list, it doesn’t work. You would have to either do it the way Justin said, or use a dictionary and the double-star.
attrs = {"constructionHistory": True,
"gravity": True,
"gravityY": True,
"gravityZ": True
}
pm.polyExtrudeFacet(**attrs)
A single star will “expand” a list into individual arguments, whereas the double-star will expand a dictionary into keyword-arguments.
Expanded, it would look like this:
pm.polyExtrudeFacet(constructionHistory=True, gravity=True, ...)
Whereas the expanded list above looks like this:
pm.polyExtrudeFacet('constructionHistory', 'gravity', 'gravityY', ...)
Which is why it wouldn’t work. :)
Best,
Marcus
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2bcc0f3b-352c-4144-8ca6-86d3dc4b607b%40googlegroups.com.
On 19/10/2014 7:29 AM, "Sam555" <samit...@gmail.com> wrote:
>
> Hello guys,
>
> i'am still stuck with this one, i can't get a for loop working with the dict unpacking, i t is not iterating on the key:value pair....as i surely not using the good way to iterate with dict:
>
> attrs = {"offset": True,
> "smoothingAngle": True,
> "localTranslateZ": True,
> "localScaleX": True}
>
>
> for attr in attrs:
> print(pm.polyExtrudeFacet(extrusion, q=1, **attrs))
>
It doesn't make any sense to do this. What you are doing is looping over each key in the dict, not using it, and calling the same command each time, with the ordinal key/value pairs from the attrs dict. Seems like you want to ditch the loop altogether and call this once.
> it's giving me the same value each time.
> What am i doing wrong ?
>
> Thank you for your help !
>
> --
> 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_m...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8a8b11a7-ab7d-4d1a-b626-785b8280dc68%40googlegroups.com.
for attr in attrs: print(pm.polyExtrudeFacet(extrusion, q=1, **attrs))
Yes, that is quite the nonsensical command. :)
You use it like this:
attrs = {"query": True,
"offset": True,
"smoothingAngle": True,
"localTranslateZ": True,
"localScaleX": True}
pm.polyExtrudeFacet(**attrs)
Which is the same thing as doing this:
pm.polyExtruceFacet(query=True,
offset=True,
smoothingAngle=True,
localTranslateZ=True,
localScaleX=True)
Though I don’t know where you’re getting extrusion from.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1Q3t7nfKR03oMVMSO8C%3DJu3SAoMzrfWoNvjujBguGADw%40mail.gmail.com.
# get the mesh
sel=pm.selected()[0]
# get the shape
shapeNode = sel.getShapes()[0]
# get the extrudes nodes extNodes = sorted([node for connection in shapeNode.connections(c=1) for node in connection if pm.nodeType(node)=='polyExtrudeFace'])
# node attributes (shortened for demonstration)
attrs = {"offset": True, "smoothingAngle": True, "localTranslateZ": True, "localScaleX": True}
# list all the attributes value for say the first extrude node :
extAttrValues = pm.polyExtrudeFacet(extNodes [0], q=1, **attrs)
Aah, now I see what you’re trying to achieve. How about this.
for attr in ["offset",
"smoothingAngle",
"localTranslateZ",
"localScaleX"]:
kwargs = {attr: True, "query": True}
print pm.polyExtrudeFacet(extNodes[0], **kwargs)
This will run a query for each string in the list.
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/df5d28fc-a4f2-495b-8faf-56b2862c31b1%40googlegroups.com.
Oh right. Now it makes sense why you wee doing that loop. Marcus seems to have solved the riddle.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOD26LhS3dFEfinhr-eK-yJjRdP1c-N6jtCyDWASO1Y0yQ%40mail.gmail.com.
Where do get the extNodes list from?
That was from the last example that Sam posted.
extNodes = sorted([node for connection in shapeNode.conn...
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/6bc943bc-8fde-4498-a294-32aac22f280b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.