Hi,
I'm trying to work with doc.StartPickSession(callback, multi) and I'm running into some questions.
Trying this simple code...
import c4d
from c4d import gui
def OnPick(active, multi):
print "active: ", active
print "multi: ", multi
# Main function
def main():
doc.StartPickSession(OnPick, multi=True)
# Execute main()
if __name__=='__main__':
main()
I'm able to start a multi-object pick session, but once I double-click to complete it, I get this error:
TypeError: OnPick() takes exactly 2 arguments (3 given)
After a bit of detective work, it seems that adding a mystery
variable to my callback function def OnPick(mystery, active, multi):
fixes the error. When I run this:
import c4d
from c4d import gui
def OnPick(mystery, active, multi):
print "mystery: ", mystery
print "active: ", active
print "multi: ", multi
# Main function
def main():
doc.StartPickSession(OnPick, multi=True)
# Execute main()
if __name__=='__main__':
main()
I get this console output:
mystery: 0
active: [<c4d.BaseObject object called 'Cube/Cube' with ID 5159 at 0x00000290184D2B90>, <c4d.BaseObject object called 'Cube.1/Cube' with ID 5159 at 0x00000290184D2130>, <c4d.BaseObject object called 'Cube.2/Cube' with ID 5159 at 0x00000290184D2170>]
multi: True
After a bit more detective work, it seems that mystery
is 0
if I complete the pick-session by double-clicking, and it's 1
if I press Esc
to finish the pick session.
Questions
- What is the
mystery
variable, and what is it actually returning. - Is there a way to trigger a multi-pick session where the user doesn't have to hold down shift/ctrl to select multiple elements?
- I'm noticing some weirdness in terms of which objects are selected in the Editor/Viewport after a pick session (especially if I end it by pressing
Esc
). What messages/redraws do I need to call after a pick session? Do I need to handle undo or will C4D?
Thanks,
Donovan