On 12/03/2013 at 16:51, xxxxxxxx wrote:
I need to clean up some widgets and Basedraw stuff if/when someone deletes any objects in the OM. This is for an ObjectData plugin. I CAN check it in GVO but would hate to do that every cycle which seems like a waste. Is there a document message to handle so I can have it do cleanup only when any object is deleted in the OM?
On 12/03/2013 at 16:54, xxxxxxxx wrote:
To be more specific, for example one of the things I need to do is erase references in an In_Ex list if it's parent has been deleted. Here is what I am doing below. I made a lil method to check if there is NONE and erase it and do some recursion to do it again until all the objects in the list are 'real'. This works fine. Just looking for some optimization. Maybe there are Description flags I should be setting to do this automatically so I don't even have to do it in code?
My code I'm using (called every GVO cycle) :
def cleanList(self, camlist) :
for i in xrange(camlist.GetObjectCount()) :
if camlist.ObjectFromIndex(self.__doc, i) == None:
On 12/03/2013 at 17:11, xxxxxxxx wrote:
c4d.plugins.nodedata.free() might be what you are looking for.
On 12/03/2013 at 17:21, xxxxxxxx wrote:
Is this not used for when your plug-in itself is being deleted? Looking for a message that tells me when any object (not my plug-in object) is being deleted (or changed in any way) so I can do some cleanup without having to do cleanup of my in_ex list on every cycle.
In the same way I modify a lot of parameters only when the Update Message is sent so I'm not doing it all the time, only when people change something.
On 12/03/2013 at 18:13, xxxxxxxx wrote:
K.I.S.S. and only optimize what really need optimizing.
if not obj:
is slightly faster than
if obj == None:
But even faster is not to do any check at all:
And remove the thing that will build up
any except/errors, in this case a faulty
In/Ex List, that will be read for every cycle
giving an error for every cycle (See print below).
I.o.w, refresh the In/Ex List and do a break.
So for example:
for o in xrange(liscount) :
listobj = inexlist.ObjectFromIndex(doc,o)
#do things with your listobj
myplugin[c4d.MY_LIST] = inexlist # rebuild a correct list
print 'GONE' # The error is now only printed once
break # start a new cycle only if errors
On 12/03/2013 at 21:40, xxxxxxxx wrote:
Hey, who're you calling S.?
Thanks, Lennart. As usual, you are supremely wise with your input. I forget try/Except even exists. I'll give it a go. Like usual, thanks for your time as you've saved my arse a number of times now.