Draw Methods doesn't work on GeUserArea
-
Hi,
I'm trying to attach a simple GeUserArea with just a bunch of Draw Methods (i.e. DrawText etc) but it appears blank when I execute the script. There are also no errors on the console.
You can check the wip code here:
import c4d from c4d import bitmaps, documents, gui, plugins, threading, utils class UserArea(c4d.gui.GeUserArea): color = c4d.Vector(1, 0, 0) def DrawMsg(self, x1, y1, x2, y2, msg): self.DrawText("Test Text Area", 10, 10) self.DrawSetPen(self.color) self.DrawRectangle(x1, y1, x2, y2) return super(UserArea, self).Message(msg, result) return True class MyDialog(c4d.gui.GeDialog): def CreateLayout(self): paramid = 10002 self.AddUserArea(paramid, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 100, 100) self.AttachUserArea(UserArea(), paramid) return True def Command(self, id, msg): return True def CoreMessage(self, id, data): return True if __name__ == "__main__": dlg = MyDialog() dlg.Open(dlgtype=c4d.DLG_TYPE_MODAL_RESIZEABLE)
Thank you for looking at my problem
-
The user area has to be a member variable of the
GeDialog
class:class ExampleDialog(c4d.gui.GeDialog): # The GeUserArea need to be stored somewhere, we will need this instance to be attached to the current Layout geUserArea = ExampleGeUserArea()
-
Thanks for the response.
TheDrawSetPen
andDrawRectangle
works but for some reason the
DrawGetTextWidth()
doesn't.I also used the value from the
DrawGetTextWidth()
but I still get the same result (i.e. the Text is not being drawn)Here is the code so far:
import c4d from c4d import bitmaps, documents, gui, plugins, threading, utils class UserArea(c4d.gui.GeUserArea): color = c4d.Vector(1, 0, 0) def DrawMsg(self, x1, y1, x2, y2, msg): self.DrawText("Test Text Area", 67, 67) print self.DrawGetTextWidth("Test Text Area") #self.DrawSetPen(self.color) self.DrawRectangle(x1, y1, x2, y2) class MyDialog(c4d.gui.GeDialog): ua = UserArea() def CreateLayout(self): paramid = 10002 self.AddUserArea(paramid, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 200, 200) self.AttachUserArea(self.ua, paramid) return True def Command(self, id, msg): return True def CoreMessage(self, id, data): return True if __name__ == "__main__": dlg = MyDialog() dlg.Open(dlgtype=c4d.DLG_TYPE_MODAL_RESIZEABLE)
-
Hi,
I haven't run your script, but you invoke
DrawRectangle
afterDrawText
, covering up any text you have drawn previously.Cheers,
zipit -
@zipit
Thanks for pointing it out. It now works as expected.