Thank you Manuel, that works perfectly.
I can use CallCommand() but I don't want to as it will always call c4d.EventAdd() and as I can't specify which bd to set as the renderview. I tend to not use CallCommand() in a plugin as it is only be able to be called in the main thread (which would be fine in this case) and as it seems to 'simulate' user interaction.
How can I set or check the 'use as render view' setting in python?
I couldn't find a bit to set ect. The only thing I can find is the 'CallCommand()' ID which I can't use.
Right now, I am trying to figure out where this setting is set. I am guessing it might be the document, but there is only an option to GetRenderBaseDraw() but I can't find a function to 'Set' it.
It would be awesome if you could point me in the direction.
Thats a perfect explanation that solves many of my issues - even in some of my other Plugins.
I am sorry, I did in fact refer to c4d freezing when I said crashing. Sorry for the confusion.
I researched a "bug" with the new console not printing while dragging the mouse and got this answer.
Is it wrong? Is there maybe another reason this crashes C4D that I can work around?
thanks, that worked great in R19.
In R21, it will also work, but it will now crash Cinema4d when the area with the code above had focus when a user uses shift+c to launch the commander, insert a command and press enter.
I learned that the GUI in R21 has been changed and is not thread-save anymore. Can I do anything to prevent the crash when using this code?
thank you for your reply, I think I am doing something wrong:
I have this code in the Message function of my dialogwhere 10002 is the ID of a Group in my Layout:
def Message(self, msg, result):
# this will crash c4d with the commander window
state = c4d.BaseContainer()
self.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSERIGHT, state)
if state.GetInt32(c4d.BFM_INPUT_VALUE) == True:
x = state.GetInt32(c4d.BFM_INPUT_X)
y = state.GetInt32(c4d.BFM_INPUT_Y)
g2l = self.Global2Local()
x += g2l['x']
y += g2l['y']
print "Found rightclick in dialog"
print "X: " +str(x)
print "Y: " +str(y)
if self.GetPositionInGuiArea(10002, x, y):
IDM_MENU1 = c4d.FIRST_POPUP_ID
IDM_MENU2 = c4d.FIRST_POPUP_ID+1
IDM_MENU3 = c4d.FIRST_POPUP_ID+2
menu = c4d.BaseContainer()
menu.InsData(IDM_MENU1, 'Menu 1')
menu.InsData(IDM_MENU2, 'Menu 2')
menu.InsData(IDM_MENU3, 'Menu 3')
l2s = self.Local2Screen()
print str(x+l2s['x']) + " :: " + str(y+l2s['y'])
result = gui.ShowPopupDialog(cd=None, bc=menu, x=x+l2s['x'], y=y+l2s['y'])
return gui.GeDialog.Message(self, msg, res)
This code will still open the default popup menu - I tried with self as well as the basecall c4d.gui.GeDialog.KillEvents(). C4D will open my menu but it wil sometimes also open the default context menu after clicking something in the menu or canceling the rightclick with esc.
Could you maybe provide an example?
I am trying to use the right-click and middle-click function in my ASYNC-Dialog of a Command plugin.
I can detect the clicks just fine, but I always get C4Ds basic behaviour as well. Is there a way to surpress the default context menu or the viewport toggle? I found that returning something invalid from Message() will stop the default behaviour and throw an error - but this can't be the solution, I think.
Is there maybe a way to return a message with the c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSERIGHT, c4d.BFM_INPUT_VALUE changed to false so c4d won't try to act on the message?
Can I modify this code to 'catch' the right or middleclick in the viewport / editor befor it is doing the internal function?
I was trying to get the middleclick in the editor and I can detect it, but it will always switch between four-split and one window editor layout. - I don't want this to happen.