GetVirtualObject - double call ?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/11/2010 at 08:23, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R12
Platform: Windows ;
Language(s) : PYTHON ;---------
I've got function (let say: GeneratePolys()) - which creates polygons (based on "Nr of Segment" value). Function is called from GetVirtualObject. When parameter is high it takes a few second to generate whole object and that's ok, but just after that Cinema calls GetVirtualObject one more time. I happens only when I use slider or arrows to change parameter value (and generation time takes a little longer) . If I enter it "manually" or generation time is short everything is ok. Anyone knows what is happening?Best
Andrzej -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/11/2010 at 09:17, xxxxxxxx wrote:
Hi Andrzej, this behavior is currently normal and cannot be changed. The automatic cache
already reduces the amount of unnecessary Python calls but changing the slider will update
the object.C++ supports a BaseThread here, where you can abort your calculation while the user is using the slider, ...
Cheers, Sebastian
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/11/2010 at 09:56, xxxxxxxx wrote:
Originally posted by xxxxxxxx
...changing the slider will update the object...
Yes, of course, I understand. I don't want to abort calculation or change slider behavior. My problem is that after changing slider, Cinema calls GetVirtualObject, but when calculation takes too long it calls it again. So, there is double execution of "GetVirtualObject". As I wrote If calculation time is short (inside my function) everything is ok - I change slider, there is one "GetVirtu..." call and everybody are happy
Andrzej
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/11/2010 at 16:06, xxxxxxxx wrote:
Ok. I simplified, checked, cleaned up the code. I check this code on another computer. Still the same. There is double call (and I think it is a bug). I uploaded code here. Could somebody check what is wrong?
Manual (how to do the bug)
1. Open python console
2. Execute plugin "AM Tests"
3. Enter 200000 in "Nr of points"
4. It will take about 3-4 seconds to generate geometry. "2. GetVirtualObject" will appear in console. "Generating poly" will appear in status bar.
5. Now. Clean up console.
6. Change "Step" (or "Nr of points") parameter using slider
7. Now it will take 6-8 seconds to generate geometry, because cinema will call "GetVirtual" twice. There will be "2. GetVirtualObject" * 2 and info on status bar will appear twice.Maybe I'm doing something wrong. I would be very grateful if somebody helped me.
thanks, Andrzej
""" AM Test """ from c4d import * import os, math, sys, random from c4d import plugins, utils, bitmaps PLUGIN_ID = 987653 class AMTest(plugins.ObjectData) : """Test""" def __init__(self) : self.SetOptimizeCache(True) def Init(self, node) : #print "0. Init" data = node.GetDataInstance() data.SetLong(AMTEST_PTS, 200) data.SetReal(AMTEST_STEP, .1) return True sweepProfile = [Vector()]*4 sweepProfile[0] = Vector(-1, 0, 1) sweepProfile[1] = Vector(1, 0, 1) sweepProfile[2] = Vector(1, 0, -1) sweepProfile[3] = Vector(-1, 0, -1) def GenerateSweep(self, node, sp) : swCnt = 4 spCnt = node[AMTEST_PTS] pCnt = spCnt*swCnt vCnt = (spCnt-1)*swCnt StatusSetText ("Generating Poly") op = PolygonObject(pCnt, vCnt) for i in xrange(spCnt) : StatusSetSpin() spP = Vector(0,i*node[AMTEST_STEP], 0) for j in xrange(swCnt) : op.SetPoint(i*swCnt+j, Vector(spP.x + self.sweepProfile[j].x*10, spP.y, spP.z + self.sweepProfile[j].z*10)) for i in xrange(spCnt-1) : for j in xrange(swCnt) : nextj = (j+1)%swCnt poly = CPolygon(i*swCnt+j, (i+1)*swCnt+j, (i+1)*swCnt+nextj, i*swCnt+nextj) op.SetPolygon(i*swCnt+j, poly) StatusSetBar(100.0*(1.0*i*swCnt/pCnt)) op.Message(MSG_UPDATE) StatusSetBar(100.0) return op def GetVirtualObjects(self, op, hierarchyhelp) : timerStart = GeGetMilliSeconds() print "2. Get Virtual Objects" StatusSetSpin() po = self.GenerateSweep(op, False) StatusClear() StatusSetText ("Done in: %s s" % ((GeGetMilliSeconds()-timerStart)/1000)) return po if __name__ == "__main__": path, file = os.path.split(__file__) plugins.RegisterObjectPlugin(id=PLUGIN_ID, str="AM Tests", g=AMTest, description="Oamtest", icon=None, info=OBJECT_GENERATOR|OBJECT_POLYGONOBJECT) plugins.Update()