@m_adam
Thanks for the solution. Sorry also for the late response.
I tried implementing the following logic of the visibility plug-in: If not visible: Don't enable. If visible: Enable. (i.e. the highlighting.
However, it gives me two errors:
'MyMenuPlugin' object has no attribute 'status'
on the self.state = self.status
line. Which is a bit confusing since I already declared status variable above.
- Also, I'm not sure if I'm returning properly with the
not c4d.CMD_VALUE | c4d.CMD_ENABLED
statement. LOL
Just to recap, I'm after this behavior
https://www.dropbox.com/s/3ozfoplfyg3yaj9/c4d133_command_highlighting.mp4?dl=0
Here is the code so far:
import c4d
from c4d import gui, plugins, bitmaps, utils, documents
PLUGIN_ID = 1010203
class MyMenuPlugin(plugins.CommandData):
def toggle_vis_subd(self):
self.doc = c4d.documents.GetActiveDocument()
bd = self.doc.GetActiveBaseDraw()
displayFilter = bd.GetDisplayFilter()
if displayFilter & c4d.DISPLAYFILTER_HYPERNURBS:
bd[c4d.BASEDRAW_DISPLAYFILTER_HYPERNURBS] = False
print "Switched Off Subdivision Surface Display Filter"
else:
bd[c4d.BASEDRAW_DISPLAYFILTER_HYPERNURBS] = True
print "Switched On Subdivision Surface Display Filter"
self.status = bd[c4d.BASEDRAW_DISPLAYFILTER_HYPERNURBS]
bd.Message(c4d.MSG_CHANGE)
c4d.EventAdd()
c4d.StatusClear()
def Execute(self, doc):
self.toggle_vis_subd()
return True
def GetState(self, doc):
self.state = self.status
if self.state == False:
return not c4d.CMD_VALUE | c4d.CMD_ENABLED
if self.state == True:
return c4d.CMD_VALUE | c4d.CMD_ENABLED
if __name__ == "__main__":
status = plugins.RegisterCommandPlugin(PLUGIN_ID, "bt_Visibility",0, None, "bt_Visibility", MyMenuPlugin())
if (status):
print "Visibility plug-in successfully initialized"
Thank you for looking at problem. The visibility code block I think is from a github c4d sample script.