CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 10-04-2012, 10:01 PM   #1
DeadlyNightshade
Plz...
 
DeadlyNightshade's Avatar
portfolio
Martin Dahlin
Jr. Technical Artist
King
Stockholm, Sweden
 
Join Date: Jul 2012
Posts: 899
Stupid problem: unable to store variable data into another variable

I'm working on my custom UV editor again and want to add functionality to store manipulation values for later use. The first procedure below is an example of a working one. $manipAmt is the variable holding the manipulation value (amount), $uvEntryField is the name of the input field, and $manipVarA is the variable I want to use for storage.

Code:
// Addition command (+0.01): $manipAmt += 0.01; floatField -e -v $manipAmt $uvEntryField; // Subtraction procedure (-0.01): global proc subtract001() { global float $manipAmt; global string $uvEntryField; if ($manipAmt >= 0.01) { $manipAmt -= 0.01; floatField -e -v $manipAmt $uvEntryField; } else { $manipAmt = 0; floatField -e -v 0.0 $uvEntryField; } } global proc readVarA() { global float $manipAmt; global string $uvEntryField; global float $manipVarA; floatField -e -v $manipVarA $uvEntryField; } global proc writeVarA() { global float $manipAmt; global float $manipVarA; $manipVarA = $manipAmt; }


There's obviously something I'm missing here because when I run the "read" procedure I don't get anything and the uvEntryField is just updated with a 0 (and $manipAmt remains). I'm suspecting that $manipVarA = $manipAmt isn't working - if it was then the value from the floatField would be stored there. And just to make sure, I also tried $manipVarA = $uvEntryField and that didn't work either.

Although the following is irrelevant, here are some buttons using my procedures:
Code:
iconTextButton -image1 "manipVal001.bmp" -command "$manipAmt += 0.01; floatField -e -v $manipAmt $uvEntryField;" -commandRepeatable true -label "Add/subtract 0.01" -annotation "Add/subtract 0.01" manipVal001; popupMenu -button 3 -p manipVal001 -postMenuCommand "subtract001()" manipVal001Popup; iconTextButton -image1 "manipVarA.bmp" -command "writeVarA()" -commandRepeatable true -label "Store/Read variable" -annotation "Store/Read variable" manipVarA; popupMenu -button 3 -p manipVarA -postMenuCommand "readVarA()" manipVarAPopup;

It's so frustrating because this error is there probably because of some newbie mistake. It's late and I've been scripting for far too long and I guess that's when you start losing focus.
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.

Last edited by DeadlyNightshade : 10-04-2012 at 10:04 PM.
 
Old 10-05-2012, 12:57 AM   #2
gmask
Obfuscator
 
gmask's Avatar
gmask
Power Sitting
Topanga, USA
 
Join Date: Oct 2002
Posts: 6,937
The problem appears to be that you are trying to read a global variable from a string that is getting evaluated without declaring the global in the string.. so basically it doesn't know what the global is.

just add the global to your string

-command "global string $uvEntryField;$manipAmt += 0.01; floatField -e -v $manipAmt $uvEntryField;"
__________________
blah blah blah
 
Old 10-05-2012, 09:18 AM   #3
DeadlyNightshade
Plz...
 
DeadlyNightshade's Avatar
portfolio
Martin Dahlin
Jr. Technical Artist
King
Stockholm, Sweden
 
Join Date: Jul 2012
Posts: 899
Okay, I'll add "global" to all my $uvEntryField -declarations and see what happens. Thanks.
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.
 
Old 10-05-2012, 05:24 PM   #4
DeadlyNightshade
Plz...
 
DeadlyNightshade's Avatar
portfolio
Martin Dahlin
Jr. Technical Artist
King
Stockholm, Sweden
 
Join Date: Jul 2012
Posts: 899
I checked my declarations and $uvEntryField is declared as a global everywhere in my script.
The only place it's not declared is in your example and in buttons like it - because it's not needed there. It's something else that doesn't work.

Procedure subtract001() in my original post works, but not the following two (variable storage procedures) so the issue is not with declarations it seems.
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.

Last edited by DeadlyNightshade : 10-05-2012 at 05:28 PM.
 
Old 10-05-2012, 07:37 PM   #5
DeadlyNightshade
Plz...
 
DeadlyNightshade's Avatar
portfolio
Martin Dahlin
Jr. Technical Artist
King
Stockholm, Sweden
 
Join Date: Jul 2012
Posts: 899
Script now works and I don't even know what I did (if I even did anything).
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.
 
Old 10-05-2012, 07:37 PM   #6
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
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 12:16 PM.


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