This one really surprised me. I tend to avoid global variable in Softimage
plugins as much as I can, but sometimes it might be convenient.
So basically, I wanted to use a global variable ( simple Python Dictionary
) to keep some stuff in reference while interacting with a PPG. I remember
clearly that it was working well under Windows, so
I assume this is a python 2.5 Linux issue (if this is an issue - please
tell me if this is normal under Soft with python 2.5).
> def CustomCommand_Execute():
> global LAST_SELECTION
> [Do some modifications to LAST_SELECTION]
Following this pattern:
- Prompt the PPG
- Interact with the UI
- The custom command is fired - do some modifications to LAST_SELECTION
- hit another PPG UI
- Hell the LAST_SELECTION global is back to the inital value!
I've been tracing the LAST_SELECTION variable with id(), and it's changing
every time I interact with the UI; showing clearly that there is something
nasty going on under the hood (?)
Any idea to get this working?
Alan mentioned the Application.SetGlobal/Application.GetGlobal functions
... but still, this should be working natively, isn't?
> This one really surprised me. I tend to avoid global variable in Softimage
> plugins as much as I can, but sometimes it might be convenient.
> So basically, I wanted to use a global variable ( simple Python Dictionary
> ) to keep some stuff in reference while interacting with a PPG. I remember
> clearly that it was working well under Windows, so
> I assume this is a python 2.5 Linux issue (if this is an issue - please
> tell me if this is normal under Soft with python 2.5).
>> def CustomCommand_Execute():
>> global LAST_SELECTION
>> [Do some modifications to LAST_SELECTION]
> Following this pattern:
> - Prompt the PPG
> - Interact with the UI
> - The custom command is fired - do some modifications to LAST_SELECTION
> - hit another PPG UI
> - Hell the LAST_SELECTION global is back to the inital value!
> I've been tracing the LAST_SELECTION variable with id(), and it's changing
> every time I interact with the UI; showing clearly that there is something
> nasty going on under the hood (?)
> Any idea to get this working?
> Alan mentioned the Application.SetGlobal/Application.GetGlobal functions
> ... but still, this should be working natively, isn't?
My experience with global variables in scripting is softimage treats them like static declared variables from C/C++. The variable is initialized once, then cached for all future invocations of the script during the user session. They are not de-referenced when the script terminates/completes.
This mainly applies to scripts run from the script editor directly. Global variables inside of self installing plugins should work as expected.
Matt
From: softimage-boun...@listproc.autodesk.com [mailto:softimage-boun...@listproc.autodesk.com] On Behalf Of Xavier Lapointe
Sent: Friday, May 11, 2012 6:12 PM
To: softim...@listproc.autodesk.com
Subject: [Python] global variable issue on linux
Hey guys,
This one really surprised me. I tend to avoid global variable in Softimage plugins as much as I can, but sometimes it might be convenient.
So basically, I wanted to use a global variable ( simple Python Dictionary ) to keep some stuff in reference while interacting with a PPG. I remember clearly that it was working well under Windows, so
I assume this is a python 2.5 Linux issue (if this is an issue - please tell me if this is normal under Soft with python 2.5).
def CustomCommand_Execute():
global LAST_SELECTION
[Do some modifications to LAST_SELECTION]
Following this pattern:
* Prompt the PPG
* Interact with the UI
* The custom command is fired - do some modifications to LAST_SELECTION
* hit another PPG UI
* Hell the LAST_SELECTION global is back to the inital value!
I've been tracing the LAST_SELECTION variable with id(), and it's changing every time I interact with the UI; showing clearly that there is something nasty going on under the hood (?)
Any idea to get this working?
Alan mentioned the Application.SetGlobal/Application.GetGlobal functions ... but still, this should be working natively, isn't?
I am not sure whether this works under windows as well, the plugin script
can get refreshed and all your global variables will be re-initialized. The
only good approaches that I have been using is to store the varaibles in
UIITems lists. This works well for the 3D com objects as well. Another idea
would be to pass on objects returning through a safe array from the
commands itself.
On Fri, May 11, 2012 at 9:13 PM, Xavier Lapointe
<xl.mailingl...@gmail.com>wrote:
>> This one really surprised me. I tend to avoid global variable in
>> Softimage plugins as much as I can, but sometimes it might be convenient.
>> So basically, I wanted to use a global variable ( simple Python
>> Dictionary ) to keep some stuff in reference while interacting with a PPG.
>> I remember clearly that it was working well under Windows, so
>> I assume this is a python 2.5 Linux issue (if this is an issue - please
>> tell me if this is normal under Soft with python 2.5).
>>> def CustomCommand_Execute():
>>> global LAST_SELECTION
>>> [Do some modifications to LAST_SELECTION]
>> Following this pattern:
>> - Prompt the PPG
>> - Interact with the UI
>> - The custom command is fired - do some modifications to
>> LAST_SELECTION
>> - hit another PPG UI
>> - Hell the LAST_SELECTION global is back to the inital value!
>> I've been tracing the LAST_SELECTION variable with id(), and it's
>> changing every time I interact with the UI; showing clearly that there is
>> something nasty going on under the hood (?)
>> Any idea to get this working?
>> Alan mentioned the Application.SetGlobal/Application.GetGlobal functions
>> ... but still, this should be working natively, isn't?
Hm, yes I could store it in a parameter or another way ... just this feels
hacky to get something basic done (granted no refresh happend during the
plugin execution).
> I am not sure whether this works under windows as well, the plugin script
> can get refreshed and all your global variables will be re-initialized. The
> only good approaches that I have been using is to store the varaibles in
> UIITems lists. This works well for the 3D com objects as well. Another idea
> would be to pass on objects returning through a safe array from the
> commands itself.
> On Fri, May 11, 2012 at 9:13 PM, Xavier Lapointe <xl.mailingl...@gmail.com
> > wrote:
>> hit another PPG UI Item ***
>> ... All happening under the same Property page.
>>> This one really surprised me. I tend to avoid global variable in
>>> Softimage plugins as much as I can, but sometimes it might be convenient.
>>> So basically, I wanted to use a global variable ( simple Python
>>> Dictionary ) to keep some stuff in reference while interacting with a PPG.
>>> I remember clearly that it was working well under Windows, so
>>> I assume this is a python 2.5 Linux issue (if this is an issue - please
>>> tell me if this is normal under Soft with python 2.5).
>>>> def CustomCommand_Execute():
>>>> global LAST_SELECTION
>>>> [Do some modifications to LAST_SELECTION]
>>> Following this pattern:
>>> - Prompt the PPG
>>> - Interact with the UI
>>> - The custom command is fired - do some modifications to
>>> LAST_SELECTION
>>> - hit another PPG UI
>>> - Hell the LAST_SELECTION global is back to the inital value!
>>> I've been tracing the LAST_SELECTION variable with id(), and it's
>>> changing every time I interact with the UI; showing clearly that there is
>>> something nasty going on under the hood (?)
>>> Any idea to get this working?
>>> Alan mentioned the Application.SetGlobal/Application.GetGlobal functions
>>> ... but still, this should be working natively, isn't?
Yes if PPG is not getting refreshed then this seems weird. The only thing
that comes to mind is maybe the custom command execution is making things
go wrong. What if you use a function declared inside the plugin instead of
calling the custom command ? or maybe the custom command should be
implemented in the same plugin as the PPG, this does not make sense but is
worth a try.
On Fri, May 11, 2012 at 9:24 PM, Xavier Lapointe
<xl.mailingl...@gmail.com>wrote:
> Hm, yes I could store it in a parameter or another way ... just this feels
> hacky to get something basic done (granted no refresh happend during the
> plugin execution).
>> I am not sure whether this works under windows as well, the plugin script
>> can get refreshed and all your global variables will be re-initialized. The
>> only good approaches that I have been using is to store the varaibles in
>> UIITems lists. This works well for the 3D com objects as well. Another idea
>> would be to pass on objects returning through a safe array from the
>> commands itself.
>> On Fri, May 11, 2012 at 9:13 PM, Xavier Lapointe <
>> xl.mailingl...@gmail.com> wrote:
>>> hit another PPG UI Item ***
>>> ... All happening under the same Property page.
>>>> This one really surprised me. I tend to avoid global variable in
>>>> Softimage plugins as much as I can, but sometimes it might be convenient.
>>>> So basically, I wanted to use a global variable ( simple Python
>>>> Dictionary ) to keep some stuff in reference while interacting with a PPG.
>>>> I remember clearly that it was working well under Windows, so
>>>> I assume this is a python 2.5 Linux issue (if this is an issue - please
>>>> tell me if this is normal under Soft with python 2.5).
>>>>> def CustomCommand_Execute():
>>>>> global LAST_SELECTION
>>>>> [Do some modifications to LAST_SELECTION]
>>>> Following this pattern:
>>>> - Prompt the PPG
>>>> - Interact with the UI
>>>> - The custom command is fired - do some modifications to
>>>> LAST_SELECTION
>>>> - hit another PPG UI
>>>> - Hell the LAST_SELECTION global is back to the inital value!
>>>> I've been tracing the LAST_SELECTION variable with id(), and it's
>>>> changing every time I interact with the UI; showing clearly that there is
>>>> something nasty going on under the hood (?)
>>>> Any idea to get this working?
>>>> Alan mentioned the
>>>> Application.SetGlobal/Application.GetGlobal functions ... but still, this
>>>> should be working natively, isn't?
- everything lives in the same plugin
- I tried storing it in a container coming from an imported module
- tried accessing and setting the global variable directly in the
globals() dictionary
- Grumble Gumble.
> Yes if PPG is not getting refreshed then this seems weird. The only thing
> that comes to mind is maybe the custom command execution is making things
> go wrong. What if you use a function declared inside the plugin instead of
> calling the custom command ? or maybe the custom command should be
> implemented in the same plugin as the PPG, this does not make sense but is
> worth a try.
> On Fri, May 11, 2012 at 9:24 PM, Xavier Lapointe <xl.mailingl...@gmail.com
> > wrote:
>> Hm, yes I could store it in a parameter or another way ... just this
>> feels hacky to get something basic done (granted no refresh happend during
>> the plugin execution).
>>> I am not sure whether this works under windows as well, the plugin
>>> script can get refreshed and all your global variables will be
>>> re-initialized. The only good approaches that I have been using is to store
>>> the varaibles in UIITems lists. This works well for the 3D com objects as
>>> well. Another idea would be to pass on objects returning through a safe
>>> array from the commands itself.
>>> On Fri, May 11, 2012 at 9:13 PM, Xavier Lapointe <
>>> xl.mailingl...@gmail.com> wrote:
>>>> hit another PPG UI Item ***
>>>> ... All happening under the same Property page.
>>>>> This one really surprised me. I tend to avoid global variable in
>>>>> Softimage plugins as much as I can, but sometimes it might be convenient.
>>>>> So basically, I wanted to use a global variable ( simple Python
>>>>> Dictionary ) to keep some stuff in reference while interacting with a PPG.
>>>>> I remember clearly that it was working well under Windows, so
>>>>> I assume this is a python 2.5 Linux issue (if this is an issue -
>>>>> please tell me if this is normal under Soft with python 2.5).
>>>>>> def CustomCommand_Execute():
>>>>>> global LAST_SELECTION
>>>>>> [Do some modifications to LAST_SELECTION]
>>>>> Following this pattern:
>>>>> - Prompt the PPG
>>>>> - Interact with the UI
>>>>> - The custom command is fired - do some modifications to
>>>>> LAST_SELECTION
>>>>> - hit another PPG UI
>>>>> - Hell the LAST_SELECTION global is back to the inital value!
>>>>> I've been tracing the LAST_SELECTION variable with id(), and it's
>>>>> changing every time I interact with the UI; showing clearly that there is
>>>>> something nasty going on under the hood (?)
>>>>> Any idea to get this working?
>>>>> Alan mentioned the
>>>>> Application.SetGlobal/Application.GetGlobal functions ... but still, this
>>>>> should be working natively, isn't?
One last thing, I checked one plugin where this works, of course in
windows, but in my code I do not use 'global ' keyword when accesing the
global dict. Something like this:
globalDict = {}
def _setGlobalDict(inObj=None, meshData=None):
if inObj:
globalDict['obj'] = inObj # no use of 'global' here.
if meshData:
globalDict['data'] = meshData
return True
and then I call _setGlobalDict() wherever I need to.
On Fri, May 11, 2012 at 9:37 PM, Xavier Lapointe
<xl.mailingl...@gmail.com>wrote:
> - everything lives in the same plugin
> - I tried storing it in a container coming from an imported module
> - tried accessing and setting the global variable directly in the
> globals() dictionary
> - Grumble Gumble.
>> Yes if PPG is not getting refreshed then this seems weird. The only thing
>> that comes to mind is maybe the custom command execution is making things
>> go wrong. What if you use a function declared inside the plugin instead of
>> calling the custom command ? or maybe the custom command should be
>> implemented in the same plugin as the PPG, this does not make sense but is
>> worth a try.
>> On Fri, May 11, 2012 at 9:24 PM, Xavier Lapointe <
>> xl.mailingl...@gmail.com> wrote:
>>> Hm, yes I could store it in a parameter or another way ... just this
>>> feels hacky to get something basic done (granted no refresh happend during
>>> the plugin execution).
>>>> I am not sure whether this works under windows as well, the plugin
>>>> script can get refreshed and all your global variables will be
>>>> re-initialized. The only good approaches that I have been using is to store
>>>> the varaibles in UIITems lists. This works well for the 3D com objects as
>>>> well. Another idea would be to pass on objects returning through a safe
>>>> array from the commands itself.
>>>> On Fri, May 11, 2012 at 9:13 PM, Xavier Lapointe <
>>>> xl.mailingl...@gmail.com> wrote:
>>>>> hit another PPG UI Item ***
>>>>> ... All happening under the same Property page.
>>>>>> This one really surprised me. I tend to avoid global variable in
>>>>>> Softimage plugins as much as I can, but sometimes it might be convenient.
>>>>>> So basically, I wanted to use a global variable ( simple Python
>>>>>> Dictionary ) to keep some stuff in reference while interacting with a PPG.
>>>>>> I remember clearly that it was working well under Windows, so
>>>>>> I assume this is a python 2.5 Linux issue (if this is an issue -
>>>>>> please tell me if this is normal under Soft with python 2.5).
>>>>>>> def CustomCommand_Execute():
>>>>>>> global LAST_SELECTION
>>>>>>> [Do some modifications to LAST_SELECTION]
>>>>>> Following this pattern:
>>>>>> - Prompt the PPG
>>>>>> - Interact with the UI
>>>>>> - The custom command is fired - do some modifications to
>>>>>> LAST_SELECTION
>>>>>> - hit another PPG UI
>>>>>> - Hell the LAST_SELECTION global is back to the inital value!
>>>>>> I've been tracing the LAST_SELECTION variable with id(), and it's
>>>>>> changing every time I interact with the UI; showing clearly that there is
>>>>>> something nasty going on under the hood (?)
>>>>>> Any idea to get this working?
>>>>>> Alan mentioned the
>>>>>> Application.SetGlobal/Application.GetGlobal functions ... but still, this
>>>>>> should be working natively, isn't?
Tried your solution but could not get it to work :(
Found a way, but I would need to understand the internal mechanism to
reproduce it more cleanly.
from win32com.client import constants
> constants.__dicts__.append({'PLUGIN_GLOBAL_SCOPE': None,'project':
> {},'category': '','entities': []})
> container = [d for d in constants.__dicts__ if 'PLUGIN_GLOBAL_SCOPE' in
> d][0]
> One last thing, I checked one plugin where this works, of course in
> windows, but in my code I do not use 'global ' keyword when accesing the
> global dict. Something like this:
> globalDict = {}
> def _setGlobalDict(inObj=None, meshData=None):
> if inObj:
> globalDict['obj'] = inObj # no use of 'global' here.
> if meshData:
> globalDict['data'] = meshData
> return True
> and then I call _setGlobalDict() wherever I need to.
> On Fri, May 11, 2012 at 9:37 PM, Xavier Lapointe <xl.mailingl...@gmail.com
> > wrote:
>> I'll add some context:
>> - everything lives in the same plugin
>> - I tried storing it in a container coming from an imported module
>> - tried accessing and setting the global variable directly in the
>> globals() dictionary
>> - Grumble Gumble.
>>> Yes if PPG is not getting refreshed then this seems weird. The only
>>> thing that comes to mind is maybe the custom command execution is making
>>> things go wrong. What if you use a function declared inside the plugin
>>> instead of calling the custom command ? or maybe the custom command should
>>> be implemented in the same plugin as the PPG, this does not make sense but
>>> is worth a try.
>>> On Fri, May 11, 2012 at 9:24 PM, Xavier Lapointe <
>>> xl.mailingl...@gmail.com> wrote:
>>>> Hm, yes I could store it in a parameter or another way ... just this
>>>> feels hacky to get something basic done (granted no refresh happend during
>>>> the plugin execution).
>>>>> I am not sure whether this works under windows as well, the plugin
>>>>> script can get refreshed and all your global variables will be
>>>>> re-initialized. The only good approaches that I have been using is to store
>>>>> the varaibles in UIITems lists. This works well for the 3D com objects as
>>>>> well. Another idea would be to pass on objects returning through a safe
>>>>> array from the commands itself.
>>>>> On Fri, May 11, 2012 at 9:13 PM, Xavier Lapointe <
>>>>> xl.mailingl...@gmail.com> wrote:
>>>>>> hit another PPG UI Item ***
>>>>>> ... All happening under the same Property page.
>>>>>>> This one really surprised me. I tend to avoid global variable in
>>>>>>> Softimage plugins as much as I can, but sometimes it might be convenient.
>>>>>>> So basically, I wanted to use a global variable ( simple Python
>>>>>>> Dictionary ) to keep some stuff in reference while interacting with a PPG.
>>>>>>> I remember clearly that it was working well under Windows, so
>>>>>>> I assume this is a python 2.5 Linux issue (if this is an issue -
>>>>>>> please tell me if this is normal under Soft with python 2.5).
>>>>>>>> def CustomCommand_Execute():
>>>>>>>> global LAST_SELECTION
>>>>>>>> [Do some modifications to LAST_SELECTION]
>>>>>>> Following this pattern:
>>>>>>> - Prompt the PPG
>>>>>>> - Interact with the UI
>>>>>>> - The custom command is fired - do some modifications to
>>>>>>> LAST_SELECTION
>>>>>>> - hit another PPG UI
>>>>>>> - Hell the LAST_SELECTION global is back to the inital value!
>>>>>>> I've been tracing the LAST_SELECTION variable with id(), and it's
>>>>>>> changing every time I interact with the UI; showing clearly that there is
>>>>>>> something nasty going on under the hood (?)
>>>>>>> Any idea to get this working?
>>>>>>> Alan mentioned the
>>>>>>> Application.SetGlobal/Application.GetGlobal functions ... but still, this
>>>>>>> should be working natively, isn't?
> Tried your solution but could not get it to work :(
> Found a way, but I would need to understand the internal mechanism to
> reproduce it more cleanly.
> from win32com.client import constants
>> constants.__dicts__.append({'PLUGIN_GLOBAL_SCOPE': None,'project':
>> {},'category': '','entities': []})
>> container = [d for d in constants.__dicts__ if 'PLUGIN_GLOBAL_SCOPE' in
>> d][0]
>> One last thing, I checked one plugin where this works, of course in
>> windows, but in my code I do not use 'global ' keyword when accesing the
>> global dict. Something like this:
>> globalDict = {}
>> def _setGlobalDict(inObj=None, meshData=None):
>> if inObj:
>> globalDict['obj'] = inObj # no use of 'global' here.
>> if meshData:
>> globalDict['data'] = meshData
>> return True
>> and then I call _setGlobalDict() wherever I need to.
>> On Fri, May 11, 2012 at 9:37 PM, Xavier Lapointe <
>> xl.mailingl...@gmail.com> wrote:
>>> I'll add some context:
>>> - everything lives in the same plugin
>>> - I tried storing it in a container coming from an imported module
>>> - tried accessing and setting the global variable directly in the
>>> globals() dictionary
>>> - Grumble Gumble.
>>>> Yes if PPG is not getting refreshed then this seems weird. The only
>>>> thing that comes to mind is maybe the custom command execution is making
>>>> things go wrong. What if you use a function declared inside the plugin
>>>> instead of calling the custom command ? or maybe the custom command should
>>>> be implemented in the same plugin as the PPG, this does not make sense but
>>>> is worth a try.
>>>> On Fri, May 11, 2012 at 9:24 PM, Xavier Lapointe <
>>>> xl.mailingl...@gmail.com> wrote:
>>>>> Hm, yes I could store it in a parameter or another way ... just this
>>>>> feels hacky to get something basic done (granted no refresh happend during
>>>>> the plugin execution).
>>>>>> I am not sure whether this works under windows as well, the plugin
>>>>>> script can get refreshed and all your global variables will be
>>>>>> re-initialized. The only good approaches that I have been using is to store
>>>>>> the varaibles in UIITems lists. This works well for the 3D com objects as
>>>>>> well. Another idea would be to pass on objects returning through a safe
>>>>>> array from the commands itself.
>>>>>> On Fri, May 11, 2012 at 9:13 PM, Xavier Lapointe <
>>>>>> xl.mailingl...@gmail.com> wrote:
>>>>>>> hit another PPG UI Item ***
>>>>>>> ... All happening under the same Property page.
>>>>>>>> This one really surprised me. I tend to avoid global variable in
>>>>>>>> Softimage plugins as much as I can, but sometimes it might be convenient.
>>>>>>>> So basically, I wanted to use a global variable ( simple Python
>>>>>>>> Dictionary ) to keep some stuff in reference while interacting with a PPG.
>>>>>>>> I remember clearly that it was working well under Windows, so
>>>>>>>> I assume this is a python 2.5 Linux issue (if this is an issue -
>>>>>>>> please tell me if this is normal under Soft with python 2.5).
>>>>>>>> Here's basically what I was trying to do:
>>>>>>>>> def CustomCommand_Execute():
>>>>>>>>> global LAST_SELECTION
>>>>>>>>> [Do some modifications to LAST_SELECTION]
>>>>>>>> Following this pattern:
>>>>>>>> - Prompt the PPG
>>>>>>>> - Interact with the UI
>>>>>>>> - The custom command is fired - do some modifications to
>>>>>>>> LAST_SELECTION
>>>>>>>> - hit another PPG UI
>>>>>>>> - Hell the LAST_SELECTION global is back to the inital value!
>>>>>>>> I've been tracing the LAST_SELECTION variable with id(), and it's
>>>>>>>> changing every time I interact with the UI; showing clearly that there is
>>>>>>>> something nasty going on under the hood (?)
>>>>>>>> Any idea to get this working?
>>>>>>>> Alan mentioned the
>>>>>>>> Application.SetGlobal/Application.GetGlobal functions ... but still, this
>>>>>>>> should be working natively, isn't?
Sorry a bit late in the thread, but global variables don't work in Python
plugins, as XSI fairly often re-executes the plugin code, especially when
dealing with PPG.
Not sure why it's doing this, but the consequence is that you just can't
rely on those as you would in a regular module, and that's a good reason to
prefer coding python in modules than in plugins.
I think there is a way to make global work though, if you do something like
this:
if 'MYGLOBAL' not in globals():
global MYGLOBAL
MYGLOBAL = 'MY_GLOBAL_DEFAULT_VALUE'
Cheers,
Aloys
On Sat, May 12, 2012 at 2:48 PM, Alan Fregtman <alan.fregt...@gmail.com>wrote:
> Makes one wonder if that's why Application.SetGlobal() exists. =p lol
> On Fri, May 11, 2012 at 10:15 PM, Xavier Lapointe <
> xl.mailingl...@gmail.com> wrote:
>> Tried your solution but could not get it to work :(
>> Found a way, but I would need to understand the internal mechanism to
>> reproduce it more cleanly.
>> from win32com.client import constants
>>> constants.__dicts__.append({'PLUGIN_GLOBAL_SCOPE': None,'project':
>>> {},'category': '','entities': []})
>>> container = [d for d in constants.__dicts__ if 'PLUGIN_GLOBAL_SCOPE' in
>>> d][0]
>>> One last thing, I checked one plugin where this works, of course in
>>> windows, but in my code I do not use 'global ' keyword when accesing the
>>> global dict. Something like this:
>>> globalDict = {}
>>> def _setGlobalDict(inObj=None, meshData=None):
>>> if inObj:
>>> globalDict['obj'] = inObj # no use of 'global' here.
>>> if meshData:
>>> globalDict['data'] = meshData
>>> return True
>>> and then I call _setGlobalDict() wherever I need to.
>>> On Fri, May 11, 2012 at 9:37 PM, Xavier Lapointe <
>>> xl.mailingl...@gmail.com> wrote:
>>>> I'll add some context:
>>>> - everything lives in the same plugin
>>>> - I tried storing it in a container coming from an imported module
>>>> - tried accessing and setting the global variable directly in the
>>>> globals() dictionary
>>>> - Grumble Gumble.
>>>>> Yes if PPG is not getting refreshed then this seems weird. The only
>>>>> thing that comes to mind is maybe the custom command execution is making
>>>>> things go wrong. What if you use a function declared inside the plugin
>>>>> instead of calling the custom command ? or maybe the custom command should
>>>>> be implemented in the same plugin as the PPG, this does not make sense but
>>>>> is worth a try.
>>>>> On Fri, May 11, 2012 at 9:24 PM, Xavier Lapointe <
>>>>> xl.mailingl...@gmail.com> wrote:
>>>>>> Hm, yes I could store it in a parameter or another way ... just this
>>>>>> feels hacky to get something basic done (granted no refresh happend during
>>>>>> the plugin execution).
>>>>>>> I am not sure whether this works under windows as well, the plugin
>>>>>>> script can get refreshed and all your global variables will be
>>>>>>> re-initialized. The only good approaches that I have been using is to store
>>>>>>> the varaibles in UIITems lists. This works well for the 3D com objects as
>>>>>>> well. Another idea would be to pass on objects returning through a safe
>>>>>>> array from the commands itself.
>>>>>>> On Fri, May 11, 2012 at 9:13 PM, Xavier Lapointe <
>>>>>>> xl.mailingl...@gmail.com> wrote:
>>>>>>>> hit another PPG UI Item ***
>>>>>>>> ... All happening under the same Property page.
>>>>>>>>> This one really surprised me. I tend to avoid global variable in
>>>>>>>>> Softimage plugins as much as I can, but sometimes it might be convenient.
>>>>>>>>> So basically, I wanted to use a global variable ( simple Python
>>>>>>>>> Dictionary ) to keep some stuff in reference while interacting with a PPG.
>>>>>>>>> I remember clearly that it was working well under Windows, so
>>>>>>>>> I assume this is a python 2.5 Linux issue (if this is an issue -
>>>>>>>>> please tell me if this is normal under Soft with python 2.5).
>>>>>>>>> Here's basically what I was trying to do:
>>>>>>>>>> def CustomCommand_Execute():
>>>>>>>>>> global LAST_SELECTION
>>>>>>>>>> [Do some modifications to LAST_SELECTION]
>>>>>>>>> Following this pattern:
>>>>>>>>> - Prompt the PPG
>>>>>>>>> - Interact with the UI
>>>>>>>>> - The custom command is fired - do some modifications to
>>>>>>>>> LAST_SELECTION
>>>>>>>>> - hit another PPG UI
>>>>>>>>> - Hell the LAST_SELECTION global is back to the inital value!
>>>>>>>>> I've been tracing the LAST_SELECTION variable with id(), and it's
>>>>>>>>> changing every time I interact with the UI; showing clearly that there is
>>>>>>>>> something nasty going on under the hood (?)
>>>>>>>>> Any idea to get this working?
>>>>>>>>> Alan mentioned the
>>>>>>>>> Application.SetGlobal/Application.GetGlobal functions ... but still, this
>>>>>>>>> should be working natively, isn't?
>>>>>>>>> Thanks!
>>>>>>>>> --
>>>>>>>>> Xavier
>>>>>>>> --
>>>>>>>> Xavier
>>>>>>> --
>>>>>> --
>>>>>> Xavier
>>>>> --
>>>> --
>>>> Xavier
>>> --
>> --
>> Xavier
-- Aloys Baillet
Lead Software Developer
Research & Development - Animal Logic
--