Hi,
I an converting all my C.O.F.F.E.E scripts to python.
But I have a problem with python at the real-time display of the objects I create.
I synthesized this problem in the simplified script below.
If I press on the button <Creation null polygon> the polygon will only show on the screen when I close the plugin window.
How to make the polygon appear on the screen without being obliged to close the plugin window ?
import c4d
from c4d import gui, documents
button_1 = 1000
class MyDialog(c4d.gui.GeDialog):
def CreateLayout(self):
self.SetTitle("Creation polygon")
self.AddButton(button_1, c4d.BFH_LEFT, 300, 24, "Creation null polygon")
self.GroupEnd()
return True
def Command(self, cid, msg):
if cid == button_1:
polygon = c4d.BaseObject(c4d.Opolygon)
doc = c4d.documents.GetActiveDocument()
doc.InsertObject(polygon)
c4d.EventAdd()
return True
class MyCommandData(c4d.plugins.CommandData):
def Execute(self, doc):
dlg = MyDialog()
dlg.Open(c4d.DLG_TYPE_MODAL, -1, -1, 400, 200)
dlg.InitValues(self)
return True
if __name__ == "__main__":
c4d.plugins.RegisterCommandPlugin(id=10000015,
str="Creation polygon",
info=0,
icon=c4d.bitmaps.BaseBitmap(),
help="",
dat=MyCommandData())