Elements need to be in callers-dictionary ?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/06/2011 at 13:18, xxxxxxxx wrote:

    Yea, I know, bad Title..

    Why do Elements, i.e. a GeDialog, have to be in the calling instances, i.e. a CommandData, dictionary ?

    This code, within a CommandData, opens a dialog. But it closes itself once it appeared.

        def Execute(self, doc) :  
          dlg     = MyDialog()  
          dlg.Open(c4d.DLG_TYPE_ASYNC, 10000913)
    

    The only thing fixing this problem is, to add the dialog to the CommandData - Instances dictionary, well, attributes.

        def Execute(self, doc) :  
          self.dlg     = MyDialog()  
          self.dlg.Open(c4d.DLG_TYPE_ASYNC, 10000913)
    

    Same counts for GeUserArea.

    Thanks,
    Niklas



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/06/2011 at 16:09, xxxxxxxx wrote:

    This is how Python works. The garbage collector kills all objects which are not referenced anymore. In your first example a local variable refers to the dialog object. This reference is deleted when the function scope is left and nothing references the object dialog - so it will be be deleted. In your second example you create the dialog at the same location but if you leave the function scope its still referenced by the CommandData object which is alive until C4D is closed.

    Take a look at this: http://docs.python.org/release/2.5.2/ext/refcounts.html



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/06/2011 at 04:55, xxxxxxxx wrote:

    I thought dialog objects are just a kind of pointers to a dialog in Cinema 4D, not that Python really owns theese objects ! Good to know. :)
    Thanks for your reply.


Log in to reply