how can I halt the execution of a Script Manger script, execute "mouse commands", and then resume the script? I have attached an example at the end oy my posting.
[edited by @ferdinand]
# doc is a predefined module attribute ("variable") in a Script Manager
# context pointing to the active document and equivalent to
# Get the selected objects in the active document.
selected = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
# The fixed global position all objects should be set to.
pos = c4d.Vector(0, 0, 0)
# Iterate over all selected objects and set the global position of each.
for obj in selected:
# Get the global matrix of the object, set its offset and write it back.
mg = obj.GetMg()
mg.off = pos
obj[c4d.ID_BASEOBJECT_USECOLOR] = c4d.ID_BASEOBJECT_USECOLOR_ALWAYS
obj[c4d.ID_BASEOBJECT_COLOR] = c4d.Vector(0.5, 0.8, 0.3)
obj[c4d.ID_BASEOBJECT_USECOLOR] = 1
c4d.CallCommand(12102) # Axis
c4d.CallCommand(440000121) # Active snapping
# How can I halt the script at this point and evaluate "mouse commands"
# at this point.
c4d.CallCommand(600000020) # hide objects
if __name__ == '__main__':
Thank you for reaching out to us. Please remember that we only accept questions in the English language in this forum. You also posted in the wrong forum, your posting was a bit hard to read, and was lacking tags. I would recommend (re)reading our Forum Guidelines for future postings. I have translated, moved, tagged, and formatted your posting for you in this case.
About your question:
It is not clear to me what you mean by "executing mouse commands" (German: "Mausbefehle ausführen"). Your topic title was also referring to stopping a program, I assume you meant halting a program from the German context, i.e., halt an execution which is then resumed later.
In principle, Script Manger Scripts are blocking, and the evaluation of all GUI interaction is halted while the script is executed. Technically, you can evaluate mouse and keyboard inputs manually within a Script Manger script with c4d.gui.GetInputState() and .GetInputState() and you can also carry out viewport interaction via c4d.utils.ViewportSelect and c4d.BaseDraw.
But that does not allow the user to change the selection state of the Object Manager for example. In practice, you should also implement such GUI input heavy tools as c4d.plugins.ToolData plugins, as they are much better suited for such tasks. And even though a ToolData plugin is not blocking in the sense a Script Manger script is, you will still not be able to resume normal GUI operations amidst the execution of a tool.
To receive better help, you should clarify what you meant by "mouse commands" specifically and clarify what your general goal is for the script.
One more question, why does it process the command gui.MessageDialog('Hide Object[s]') first, is it pretty much last in the order of commands?? How do I have to install the command so that the program runs according to the order in which it was entered?
Thank you very much!