Integrating 3D models with photography
Interested in integrating your 3D work with the real world? This might help
# 1 17-03-2004 , 04:17 PM
Registered User
Join Date: May 2003
Posts: 6

accessing parameters

I want to access the smooth parameter and assign it to a variable like this


$sdiv = 'getAttr "polySmoothFace1.divisions"';

however it tells me that the syntax is incorrect, I'm new to MEL and the '" are used not correctly, how can I assign "getAttr" to a variable?
thanks.

# 2 17-03-2004 , 04:22 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
change the single quotes to backticks: change ' to ` and it will work.

Alan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 3 17-03-2004 , 04:35 PM
Registered User
Join Date: May 2003
Posts: 6
thanks a lot! works well.

now I want to replace the value like this:

setAttr polySmoothFace1.divisions $sdiv + 1;

tried it with quotes as well, doesn't work, any tips?

# 4 17-03-2004 , 04:47 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
$sdiv = `getAttr "polySmoothFace1.divisions"`;
$sdiv += 1;
setAttr "polySmoothFace1.divisions" $sdiv;

that'll do it
Alan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 5 17-03-2004 , 04:53 PM
Registered User
Join Date: May 2003
Posts: 6
thanks a lot. how can I get the current selected smooth param?
let's say you have obj1 select and you execute the script then you select obj2 and now the script doesn't work because no obj name is assigned to it.
I'm not really familiar yet with that object model of mel, any tips in that area how I can assign to the current selected object?
thanks!

# 6 17-03-2004 , 04:58 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
$obj = `ls -sl`

that will return the currently selected object.

If you want to assign differnt levels of smooth to objects I would consider adding an attribute to the object to represent smooth value and then have the object get that value so that rather than changing the polySmooth variable directly you edit the new attribute and then the polySmooth takes it's value from there.

Alan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 7 17-03-2004 , 05:08 PM
Registered User
Join Date: May 2003
Posts: 6
thanks my goal is that you later can assign that script to a key, so by simply clicking the + key the amount of smoothness increases or with - decreases.
so I thought it might be the easiest to simply increase the level.

$selobj = `ls -sl`;
addAttr smoothlevel

by having an attribiute how do I have to declare it for the smooth operator or would you use a differnt approach?
thanks.

# 8 17-03-2004 , 10:20 PM
Registered User
Join Date: May 2003
Posts: 6
in the manual it says polysmooth can be applied to faces or objects, how can I apply it simply to the object?

something like
$obj = `ls -sl`;
polySmooth -dv 2 plg2.f[0:5];

should be possible or
setAttr "polySmoothFace1.divisions" $sdiv;
without the Face1:
setAttr "polySmooth.divisions" $sdiv;

but doesn't work. any tips appreciated.

# 9 17-03-2004 , 10:28 PM
Registered User
Join Date: May 2003
Posts: 6
another attempt doing the same for subdiv surfaces:

$sdiv = `getAttr "subdivDisplaySmoothness"`;
$sdiv += 1;
setAttr "subdivDisplaySmoothness" -s $sdiv;

any idea how I can access the subDisplay smoothness and get the current value?

# 10 18-03-2004 , 09:31 AM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
change it and then look in the script editor to see what it's changed and then use what you've learned above to get those params.

Alan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
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