View Full Version : Delete Globals?
10-18-2005, 03:20 AM
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-18-2005, 07:18 AM
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.
10-20-2005, 02:01 AM
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.
10-20-2005, 03:41 AM
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;
string $retrieveString = `getAttr "temp.saveThis"`;
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-22-2005, 01:20 AM
Absoulutely. You are the man!
10-22-2005, 01:20 AM
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-2015, Jelsoft Enterprises Ltd.