SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / accessing parameters
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 17-03-2004, 03:17 PM   #1
raffael3d
Registered User
 
Join Date: May 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
raffael3d is offline   Reply With Quote
Old 17-03-2004, 03:22 PM   #2
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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

Alan
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 17-03-2004, 03:35 PM   #3
raffael3d
Registered User
 
Join Date: May 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?
raffael3d is offline   Reply With Quote
Old 17-03-2004, 03:47 PM   #4
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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

that'll do it
Alan
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 17-03-2004, 03:53 PM   #5
raffael3d
Registered User
 
Join Date: May 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!
raffael3d is offline   Reply With Quote
Old 17-03-2004, 03:58 PM   #6
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

$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
Alan is offline   Reply With Quote
Old 17-03-2004, 04:08 PM   #7
raffael3d
Registered User
 
Join Date: May 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 is offline   Reply With Quote
Old 17-03-2004, 09:20 PM   #8
raffael3d
Registered User
 
Join Date: May 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 is offline   Reply With Quote
Old 17-03-2004, 09:28 PM   #9
raffael3d
Registered User
 
Join Date: May 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?
raffael3d is offline   Reply With Quote
Old 18-03-2004, 08:31 AM   #10
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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
Alan is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.