Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   accessing parameters (https://simplymaya.com/forum/showthread.php?t=11016)

raffael3d 17-03-2004 04:17 PM

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.

Alan 17-03-2004 04:22 PM

change the single quotes to backticks: change ' to ` and it will work.

Alan

raffael3d 17-03-2004 04:35 PM

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?

Alan 17-03-2004 04:47 PM

$sdiv = `getAttr "polySmoothFace1.divisions"`;
$sdiv += 1;
setAttr "polySmoothFace1.divisions" $sdiv;

that'll do it
Alan

raffael3d 17-03-2004 04:53 PM

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!

Alan 17-03-2004 04:58 PM

$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

raffael3d 17-03-2004 05:08 PM

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.

raffael3d 17-03-2004 10:20 PM

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.

raffael3d 17-03-2004 10:28 PM

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?

Alan 18-03-2004 09:31 AM

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


All times are GMT. The time now is 09:20 PM.

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