Integrating 3D models with photography
Interested in integrating your 3D work with the real world? This might help
# 1 07-12-2004 , 10:56 AM
Registered User
Join Date: Jul 2003
Posts: 5

Newbie question about polySmoothing multiple objects..

Right, just starting scripting/writing expressions and got this resolution change thing that's a bit too long.

Basicly I'm changing all polysmooth divisions in a character (30+ of them) and currently just using a 'if (res == 1) { polySmoothFace1 = 1;polySmoothFace2 = 1; etc etc.. } which is a rather long list in the end.

I'd like to do a simple for loop instead and going through the number 1 to 30 but don't know how to add that number into the polySmoothFace[X] command to get it to work.

Any help would be greatly appreciated.

# 2 07-12-2004 , 01:54 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
use a for loop:
select your objects in the outliner then run this

global proc changeSmoothing(int $res)
{
pickWalk -d down;
string $objArray[] = `ls -sl`;
for($obj in $objArray)
{
string $conns[] = `listConnections $obj`;
for($conn in $conns)
{
if(`match "polySmoothFace" $conn` != "")
{
setAttr ($conn + ".divisions") $res;
}
}
}
}

changeSmoothing(1);

Change the number in the parametres that will be your smoothing level.

That should do it.

user added image
Alan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 3 08-12-2004 , 01:32 AM
Registered User
Join Date: Aug 2004
Posts: 24
Heres another alternative for you, it changes all the polySmoothFace values in the maya scene to the value stored in $SmoothLevel.



int $SmoothLevel = 1;
string $polySmooth[] = `ls -type polySmoothFace`;
string $EachSmooth;
for ($EachSmooth in $polySmooth)
{
setAttr ($EachSmooth + ".divisions") $SmoothLevel;
}


----------------------------------------------
Richard Cheek
https://www.freelance-animation.com
----------------------------------------------
# 4 08-12-2004 , 04:10 PM
Registered User
Join Date: Jul 2003
Posts: 5
Thanks guys! Both work fine, just one question, if I for instance say int $SmoothLevel = Character.Res then Maya won't update until I switch to another frame or press 'edit' (in the expression editor) again.

How can I make it update straight away? Is there a risk it'll slow things down then, if Maya keeps setting the polysmooth levels every frame?

Can you make an expression run only once the input variables have changed so that it doesn't update until you've changed the smoothing levels?

Thanks again, really helpful!

# 5 08-12-2004 , 08:53 PM
Registered User
Join Date: Aug 2004
Posts: 24
I didn't realize you wanted this as an expression to control the smooth levels. That will slow things down, probably by quite a lot, although I've never tried it this way.
Your best bet is to make a direct connection from your control attribute to your smooth nodes. Simply add an extra attribute to a control object, and then use the connection editor to connect this new attribute (a int, not float) to the divisions of the polySmoothFace node.
Because you have 30, this might take a while, but the end result will work a lot better than an expression.

You could probably write a simple MEL script to set it all up for you, similar to what I wrote below but change the loop to connect the attributes, instead of set them.


Richard


----------------------------------------------
Richard Cheek
https://www.freelance-animation.com
----------------------------------------------
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads