So in doing a little research , stumbled upon del() globals(), and locals()
del( ' name of instance') will remove the object from memory... NICE!
globals() lists all the instances in memory of your Maya session, notice that it's not just classes and procedures, but also any random variables you( or a script that was run) created. ie: if you've import maya.cmds as mc it will show up , but also if you've run a sel = cmds.ls(sl=True), that will also show up..
locals() scope of local variables... ( as above )
So in looking for your errant variables, it becomes even more important, NOT to have them, but also to name them something that not only doesn't overlap with existing variables.. ( as mel won't let you, python you can redeclare f***All ) , but also to name them with a unique signifier.. I've started using sm for mine.. which makes things fun ,, like, my sm_rigging_tools gets imported as smrt. ahh.. how cute. , but my matrix math is sort of ugly smmm .
in any case I thought I'd try and be more proactive, so I can do things like search for only my instances.. We'll see how it all works out.
glist = globals()
for g in glist:
if g.startswith("sm"):
print g
In mel you can list all gloabl variables using env, but , since variables written into the script editor, unless scoped, are global, you want to be very careful.
And also, just like a mel variable cannot be redefined.. it also appears that it cannot be removed either.
string $gList[] = `env`;
$glist = `sort $gList`;
for ($g in $gList)
print ($g + "\n");
}
but realistically, it probably doesn't hurt to scope python in the script editor as well
-=s
No comments:
Post a Comment