Delete Globals?

Become a member of the CGSociety

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

Thread Tools Display Modes
  10 October 2005
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?
  10 October 2005
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.


Last edited by NolanSW : 10 October 2005 at 06:21 AM.
  10 October 2005
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.
  10 October 2005
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;

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.

  10 October 2005
Absoulutely. You are the man!
  10 October 2005
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
Society of Digital Artists

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

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

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