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 04-12-2004, 01:39 AM   #1
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default syntax?

Can anyone tell me what's wrong with this code? I know it does nothing for now, but I don't understand the error message Cannot cast data of type string to string[]

global proc editAttrPopup ()
{
$currentObj = `ls -sl`;
print($currentObj);
string $currentAttrMin = ($currentObj + ".up_Filter_Size");

window -menuBar true -maximizeButton false -title "Edit_Attribute" -iconName "editAttrPopupI" -w 200 -h 150 PopEditAttrB_w;
columnLayout;

rowColumnLayout -numberOfRows 2;

showWindow PopEditAttrB_w;

}

Thanks.
Dann is offline   Reply With Quote
Old 04-12-2004, 01:37 PM   #2
kbrown
Moderator
 
kbrown's Avatar
 
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Can't check with maya right now but I can spot two things off top of my head...

The ls command returns always a string array. So you should do something like this:

string $currentObj[] = `ls -sl`;

Now let's say you're interested on the first object in the selection (index 0).

print($currentObj[0]);

The other thing is that in a script, you need to use the getAttr command to retrieve a value of an attribute. Like this:

string $currentAttrMin = getAttr($currentObj + ".up_Filter_Size");

You might want to also check the data type of the up_Filter_Size. Something tells me that it's not a string (although the above will propably work due to the automatic type conversion).
__________________
Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
kbrown is offline   Reply With Quote
Old 05-12-2004, 07:06 PM   #3
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Thanks KB, I got that part working with your help, so now I'm back for more. I'm trying to link my script to an optionMenu, but can't get it right. I'm not very good at this yet, and the docs are prety crappy when it comes to helping with syntax. Thankfully there are people like you out there.

What it does is it builds a menu based on whatever user created attributes are on your object. Down the road, I'm going to try and read the min/max values of those attributes, and place those values in a field. Then there will be an edit button so I can change the min/max values of each attribute. I have a script that does that, so I'm just working on the interface.

What I am currently stuck on is when I run the script and change the menu selection, I can't get anything to happen. I tried the -command function on the menuItem, but it doesn't work when in optionMenu. I cannot figure out the syntax of the -cc function on the optionMenu, and while the docs claim it runs every time you change your selection, it does not.


global proc optMenu()
{
string $currentObj[] = `ls -sl`;

string $currentObjAttr[]= `listAttr -ud ($currentObj[0])`;
string $currentAttr = ($currentObj[0] +"."+ $currentObjAttr[0]);

int $counter = 0;

string $selected = $currentObjAttr[0];
// string $changeSelected = "print("+$selected+")";

window -menuBar true -maximizeButton false -title "Option Menu" -iconName "optMenu_I" -w 200 -h 150 optMenu_w;
columnLayout;

rowColumnLayout -numberOfRows 3;
optionMenu -label "Attributes" -cc "($selected = $currentObjAttr[$counter])";
while ($currentObjAttr[$counter] != "")
{
menuItem -label $currentObjAttr[$counter];
$counter +=1;
}
showWindow optMenu_w;
}


Thanks again for the help. Attached is a very simple Maya file you can use to test the script in you are so inclined.
Attached Files
File Type: zip optionmenu.zip (5.7 KB, 12 views)
Dann 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.