Delete Globals?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 10 October 2005   #1
Delete Globals?

Hey all,

Is there a way to delete global variables? It would make sense. Once you've finished executing your entire script, just call on a code to delete them. This way it would save you the headache of still having them in the scene.

Anyone know of an answer?
 
Old 10 October 2005   #2
Simple...close Maya. You can not delete a global variables. Best not to use them at all.There are simple tricks to retrieve data without using globals. Invisible controls in a window or create attributtes on an empty node, set and get data and then delete when your done.

Sean

Last edited by NolanSW : 10 October 2005 at 06:21 AM.
 
Old 10 October 2005   #3
Hi Nolan.

I thought you can't delete them, but better to be sure.

Could you give me a quick example to how I would add data to a node and then retrieve it? I really don't have the faintest idea. I gather that you create a locator or something of the sort. Then create an attribute.

What If I want to add the name of an object to a string variable on this node?

It would be really helpful.

Thanks again.
 
Old 10 October 2005   #4
So here is just a quick example:

  string $sphereName[] = `sphere`;
  spaceLocator -p 0 0 0 -n temp;
  addAttr -ln saveThis -dataType "string";
  setAttr "temp.saveThis" -type "string" $sphereName[0];
  
  string $retrieveString = `getAttr "temp.saveThis"`;
  print $retrieveString;
  delete temp;
  


Simple.
Created a sphere and a locator
Created a string attribute for the locator called temp.saveThis
Set the string to be the name of the sphere
Retrieved the name
Deleted the locator

Now, if you have a UI you can create a textbox that is invisible, put data in that and retrieve it from another function without using a global variable. I do that quite often. If it needs to be numeric than I just create a floatField or an intField control. But if you are not using a UI then the first example works well for that.

Hope that helps answer your question.

Sean
 
Old 10 October 2005   #5
Absoulutely. You are the man!
 
Old 10 October 2005   #6
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



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 11:58 PM.


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