Hi Everyone!
I want to Draw HUD in the viewport using CommandData Plugin. And i put my 'draw' function in to CommandData.GetState(self, doc)
but nothing happend in the viewport.
And the code like this:
import c4d
_Plugin_id = 20230616
_Plugin_name = "Command_Test"
class Command(c4d.plugins.CommandData):
def __init__(self):
self.a = False
def Execute(self, doc):
if self.a:
self.a = False
else:
self.a = True
print(self.a)
return True
def GetState(self, doc):
if self.a:
print(123)
bd = doc.GetActiveBaseDraw()
bd.SetMatrix_Screen()
bd.DrawHUDText(50,50, "Test HUD")
return c4d.CMD_VALUE | c4d.CMD_ENABLED
else:
return c4d.CMD_ENABLED
if __name__ == '__main__':
c4d.plugins.RegisterCommandPlugin(id=_Plugin_id, str=_Plugin_name,
info=0, icon=None, help='', dat=Command())
And there have another problem: you can see the "print(123)" in the GetState
method for testing, when i click my plugin, cinema4d can print correctly and continuosly in the console, but if i move my mouse to the viewport or click somewhere (like refreshing maybe), the cinema4d has been stucking.
I don't know if I'm wrong or misunderstood something