Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 17-03-2004, 04: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, 04: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, 04: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, 04: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, 04: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, 04: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, 05: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, 10: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, 10: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, 09: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

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.