CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 07-03-2013, 11:40 AM   #1
DeadlyNightshade
Plz...
 
DeadlyNightshade's Avatar
portfolio
Martin Dahlin
Jr. Technical Artist
King
Stockholm, Sweden
 
Join Date: Jul 2012
Posts: 925
Weird formatting problem

Code:
global proc memoryAdd(string $field) { string $evalString = eval("float $temp = " + `optionVar -q memOptVar`); optionVar -stringValue "memOptVar" $evalString; } global proc memorySub(string $field) { string $evalString = eval("float $temp = " - `optionVar -q memOptVar`); optionVar -stringValue "memOptVar" $evalString; }
// Error: Line 9.71: Cannot mix string and numeric data types in arithmetic expressions.

...which is funny because these procedures are identical. The only difference is the plus and minus signs in the eval -statement
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.
 
Old 07-03-2013, 12:18 PM   #2
djx
Where's my pony?
 
djx's Avatar
David Johnson
vfx & creature td
Melbourne, Australia
 
Join Date: Jun 2003
Posts: 3,564
I think its because eval is expecting a string argument. In strings + is the concatenation operator. In a string context, - means nothing, so your 2nd proc fails.

Try:
Code:
global proc memorySub(string $field) { string $evalString = eval("float $temp = -" + `optionVar -q memOptVar`); optionVar -stringValue "memOptVar" $evalString; }

Except:
I have a feeling that will fail if the optionVar returns a negative number. Maybe you have to do:
Code:
global proc memorySub(string $field) { string $evalString = eval("float $temp = -1*" + `optionVar -q memOptVar`); optionVar -stringValue "memOptVar" $evalString; }


Better still, just use a float optionVar
Code:
optionVar -fv "memOptVar" (-1*`optionVar -q memOptVar`);

David
__________________
http://www.djx.com.au

Last edited by djx : 07-03-2013 at 12:24 PM. Reason: an after thought
 
Old 07-03-2013, 01:54 PM   #3
DeadlyNightshade
Plz...
 
DeadlyNightshade's Avatar
portfolio
Martin Dahlin
Jr. Technical Artist
King
Stockholm, Sweden
 
Join Date: Jul 2012
Posts: 925
Thanks a bunch - got it working!
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.
 
Old 07-03-2013, 01:54 PM   #4
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

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


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.