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()