Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Maya Basics & Newbie Lounge (https://simplymaya.com/forum/forumdisplay.php?f=31)
-   -   Creating multiple proxy onjects (https://simplymaya.com/forum/showthread.php?t=34477)

ben hobden 07-10-2010 04:57 PM

Creating multiple proxy onjects
 
Does anyone know of a way I can speed up creating proxy objects of the geometry in a scene. Say I have a scene where ther are 100 seperate pieces of geometry. If I want to smooth them all, I have to convert each one to a sub div surface or create a proxy object, in turn, one by one. You dont seem to be able to select more than object and smooth them. Am I right...and I just have to do each one in turn?

bendingiscool 07-10-2010 05:12 PM

This sounds like a very simple MEL/Python task, select all your objects, and in a python tab run this...


import maya.cmds as mc

sel = mc.ls(sl=True)

for i in range(len(sel)):
polyToSub = mc.polyToSubdiv(sel[i])
mc.hide(sel[i])

give me a shout if have problems...

cheers,
Chris

ben hobden 07-10-2010 05:20 PM

Quote:

Originally posted by bendingiscool
This sounds like a very simple MEL/Python task, select all your objects, and in a python tab run this...


import maya.cmds as mc

sel = mc.ls(sl=True)

for i in range(len(sel)):
polyToSub = mc.polyToSubdiv(sel[i])
mc.hide(sel[i])

give me a shout if have problems...

cheers,
Chris

Hi Chris. Thanks. I never use Python or MEL, and dont know how to use either. Can I just copy and paste all that into the python box under the viewport and hit enter? Will I need all the objects selected when doing so? Will I not need to add any semi-colons anywhere? at the end of each line? (I have a vague familiarity with php)

ben hobden 07-10-2010 06:13 PM

Enetered this into the Python Tab of the Script editor, and this is the error message I got on execution


# Error: ('expected an indented block', ('<maya console>', 5, 9, 'polyToSub = mc.polyToSubdiv(sel[i])'))

stwert 07-10-2010 09:12 PM

Python doesn't require end of line syntax, such as semi-colons, however, it does require you to define grouped statements by way of whitespace.
What this means is that you will have to tab in the two lines after "for in in range..."

The whitespace was obviously lost when bendingiscool pasted in the code here.

Edit: Should be like this:

import maya.cmds as mc

sel = mc.ls(sl=True)

for i in range(len(sel)):
[tab] polyToSub = mc.polyToSubdiv(sel[i])
[tab] mc.hide(sel[i])

#replace the [tab] with an actual tab ;)

ben hobden 07-10-2010 09:26 PM

Cheers stwert, I know it must be doable cause Ive just seen a tutorial where the guy uses a smooth button he has created on his shelf from a MEL script.

I did each piece individually in the end, but I will have to go through the process again at some point over the next few days and wil give this a try again then.


All times are GMT. The time now is 08:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018