creating Multiple empty groups in maya

59 views
Skip to first unread message

Vishal Kadam

unread,
Jun 24, 2020, 6:53:34 AM6/24/20
to Python Programming for Autodesk Maya
Need to create Multiple empty groups for the list of names in maya

for example I have
doorBell01
doorBell02
doorBell03
doorBell04

need all the list names into empty groups in maya as doorBell01_GRP and if I want to add prefix as prop the first letter for every name should be capital, and remaining letters as it is 
so finally name of the groups should be

propDoorBell01_GRP
propDoorBell02_GRP
propDoorBell03_GRP
propDoorBell04_GRP

Vishal Kadam

unread,
Jun 24, 2020, 7:33:37 AM6/24/20
to Python Programming for Autodesk Maya
can this be possible using python or mel

Soham Parmar

unread,
Jun 24, 2020, 7:57:13 AM6/24/20
to python_in...@googlegroups.com
from maya import cmds


def addPrefix(prefix):
for obj in cmds.ls(sl=True):
cmds.rename(obj, prefix + obj)


def addSurfix(surfix):
for obj in cmds.ls(sl=True):
cmds.rename(obj, obj + surfix)


addPrefix("test")

addSurfix("test")
This will work selection based.

-- 
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/14e44f62-7452-4ef0-8f38-b272e42e30fdo%40googlegroups.com.

Vishal Kadam

unread,
Jun 25, 2020, 4:45:39 AM6/25/20
to Python Programming for Autodesk Maya
this one is fine but I don't have any obj or group nodes in maya scene so for example I use this below script in new maya scene

from maya import cmds

mel.eval("CreateEmptyGroup;")


def addPrefix(prefix):
for obj in cmds.ls(sl=True):
cmds.rename(obj, prefix + obj)

addPrefix("prop")

Result will create a empty group node with prefix like

propnull1

I want the result should be

propNull1

so here prop Will be in lowercase and null1 only First first letter should be caps

I have a list of names in a text file

example:-

doorBell01
doorBell02
doorBell03
doorBell04

so final output should be

propDoorBell01

so in this case only D should be in caps with prop as prefix and remaining should be same

Actually I have a list of names in a text file and I want to rename them by adding prefix and only only first letter should be caps,
I have tried to do this by renaming tools but couldn't find any,
then I thought this could be done with python butI don't know How

I know its confusing Hope you understand what I need


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Vishal Kadam

unread,
Jun 30, 2020, 1:13:52 AM6/30/20
to Python Programming for Autodesk Maya
can anyone help me with this

Soham Parmar

unread,
Jun 30, 2020, 1:17:27 AM6/30/20
to python_in...@googlegroups.com
from maya import cmds

mel.eval("CreateEmptyGroup;")

def addPrefix(prefix):
for obj in cmds.ls(sl=True):
      cmds.rename(obj, prefix + obj.capitalize())

addPrefix("prop")


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/3727d683-2867-49dc-8c38-fd5ccd4ae316o%40googlegroups.com.

Marcus Ottosson

unread,
Jun 30, 2020, 3:04:31 AM6/30/20
to python_in...@googlegroups.com
If you're interested in learning Python more generally, have a look at Justin's Python tutorials, they are a fantastic way to get started I think, and gets you all the way to making GUIs with Qt


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
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/3727d683-2867-49dc-8c38-fd5ccd4ae316o%40googlegroups.com.

--
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.
Reply all
Reply to author
Forward
0 new messages