View Full Version : what's wrong with this simple code?
cgbeige 09-25-2010, 05:30 PM I get this error for my script when I am certain that the returned value is just 1 or 0:
//Error: Cannot convert data of type int[] to type int.
the portion of my script:
global proc toggleMyBorders()
{
int $myBorderValue = `polyOptions -q -dmb`;
if ($myBorderValue == 0)
{
polyOptions -dmb 1 -sb 6;
}
else
{
polyOptions -dmb 0 -sb 6;
}
}
|
|
mduvekot
09-25-2010, 06:57 PM
Make that
global proc toggleMyBorders()
{
int $myBorderValue[] = `polyOptions -q -dmb`;
if ($myBorderValue[0] == 0)
{
polyOptions -dmb 1 -sb 6;
}
else
{
polyOptions -dmb 0 -sb 6;
}
}
safakoner
09-25-2010, 08:13 PM
shorter...
int $myBorderValue[] = `polyOptions -q -dmb`;
polyOptions -dmb (!$myBorderValue[0]) -sb 6;
ewerybody
10-06-2010, 09:27 AM
oneliner!:buttrock:mc.polyOptions(dmb=(not mc.polyOptions(q=1,dmb=1)[0]))
btw: why the hell does that return an int array?!?! "Changes the global display polygonal attributes." (http://download.autodesk.com/us/maya/2009help/CommandsPython/polyOptions.html#hSynopsis) Are there multiple globals?!? Different realities?!?
mduvekot
10-06-2010, 10:40 AM
because
select -r pPlane1 pCube1 ;
polyOptions -q -dmb;
// Result: 0 1 //
ewerybody
10-06-2010, 12:11 PM
yes. But there are actually other commands that can return single OR array values (getAttr or optionVar for instance)
furthermore this is obviously not a global one! darn docs..
But apropos docs: always overread the -r flag (http://download.autodesk.com/us/maya/2009help/Commands/polyOptions.html#flagrelative) :DpolyOptions -r -dmb 1;When this flag is used with flags dealing with a boolean value, the boolean value is toggled
CGTalk Moderation
10-06-2010, 12:11 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.