Re: [Maya-Python] Check if object exists in world before using parent command

2017-02-23 Thread Justin Israel
You could check if it has a parent first: hasParent = bool(cmds.listRelatives("cube2", parent=True)) Justin On Fri, Feb 24, 2017 at 9:42 AM likage wrote: > This is my outliner, eg. '|hie1|cube1' and 'cube2' > > If I select cube1 and did: > cmds.parent("|hie1|cube1", world=True) > > > This

Re: [Maya-Python] Count, filter out duplicates in keys while doing the same for values

2017-02-23 Thread Justin Israel
On Fri, Feb 24, 2017 at 9:36 AM likage wrote: > Hi Justin, > > Sorry for the late reply. > > It works like a charm, thanks! > Sweet! You are welcome. > > > On Thursday, February 16, 2017 at 8:04:50 PM UTC-8, Justin Israel wrote: > > Untested, but that looks to be almost exactly the same logic

[Maya-Python] Check if object exists in world before using parent command

2017-02-23 Thread likage
This is my outliner, eg. '|hie1|cube1' and 'cube2' If I select cube1 and did: cmds.parent("|hie1|cube1", world=True) This will unparent my cube1 out of hie1 and into 'world' level? Sorry, can't think of a better term. But if I did the same thing to cube2: cmds.parent("cube2", world=True) I wi

Re: [Maya-Python] Count, filter out duplicates in keys while doing the same for values

2017-02-23 Thread likage
Hi Justin, Sorry for the late reply. It works like a charm, thanks! On Thursday, February 16, 2017 at 8:04:50 PM UTC-8, Justin Israel wrote: > > Untested, but that looks to be almost exactly the same logic as what I > gave you for tracking the counts for each user/product. But instead of > tr

Re: [Maya-Python] Rename all objects in list with name of an other lists

2017-02-23 Thread denis hoffmann
Thank you very mutch, you are my hero! import maya.cmds as cmds ShaderNames = cmds.ls ('phong*', mat=True) NewNames = ('Name1', 'Name2','Name3','Name4','Name5',) for i in xrange(len(ShaderNames)): cmds.rename (ShaderNames[i] , NewNames[i]) That is my final resoult. Am Donnerstag, 23. F

Re: [Maya-Python] Rename all objects in list with name of an other lists

2017-02-23 Thread Robert White
for shader_name, new_name in zip(ShaderNames, newNames): rename shader_name, new_name On Thursday, February 23, 2017 at 11:53:08 AM UTC-6, Michał Frątczak wrote: > > smth like this... > > for i in xrange(len(ShaderNames)): > rename ShaderNames[i] NewNames[i] > > > W dniu 2017-02-23 o 17:1

Re: [Maya-Python] Rename all objects in list with name of an other lists

2017-02-23 Thread f.michal
smth like this... for i in xrange(len(ShaderNames)):     rename ShaderNames[i]  NewNames[i] W dniu 2017-02-23 o 17:14, denis hoffmann pisze: Hey guys, I want to rename all shaders with names from a list.

[Maya-Python] Rename all objects in list with name of an other lists

2017-02-23 Thread denis hoffmann
Hey guys, I want to rename all shaders with names from a list. so I make a list of all shaders and a var with all names I want to have. ShaderNames = [u'Shader0', u'Shader1', u'Shader2', u'Shader3', u'Shader4', u'Shader5'] NewNames = ['Name1', 'Name2', 'Name3', 'Name4', 'Name5'] what is the

[Maya-Python] [Python API 1.0] - Proper flow in code

2017-02-23 Thread justin hidair
Quick questions here : How do you properly destroy your objects and MScriptutils.. ? Any optimization tricks ? Finally how many of you guys use Python API 2.O ? -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubs