While in Sketcher Edit mode I see commands in the Python console like this when a tool is clicked on:
>>> Gui.runCommand('Sketcher_CompConstrainRadDia',0)
>>> Gui.runCommand('Sketcher_CompCreateFillets',0)
>>> Gui.runCommand('Sketcher_CompCreateBSpline',0)
How can I capture these commands from the console? I'm running a macro and I want to know what sketcher is currently doing.
Thank you
How to capture sketcher commands?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 92
- Joined: Mon Nov 19, 2018 8:26 pm
Re: How to capture sketcher commands?
You sure can by using the Record macro button....
- Attachments
-
- macrorecorder.png (183.94 KiB) Viewed 1538 times
Re: How to capture sketcher commands?
I did some testing using this:
I don't know enough about python but this looks like the python console is a text based object. I tried a couple things and it's apparent that with a little work all the sketcher commands could be captured. The text comes in what they call blocks. My goal is to know when external geo is selected.
Reading the python text can get us the current sketcher command but there is no feedback to know when the command is cleared, this will take monitoring "Esc or right mouse click".
Code: Select all
mw=Gui.getMainWindow()
self.t_console=mw.findChild(QtGui.QPlainTextEdit, "Python console")
Reading the python text can get us the current sketcher command but there is no feedback to know when the command is cleared, this will take monitoring "Esc or right mouse click".
Re: How to capture sketcher commands?
I wanted to know when 'External geometry' is selected and when it's deselected. This is a follow-on of this post:What do you mean? When 'External geometry' command is run? Or when the user select a 'external geometry' of the sketch?
https://forum.freecadweb.org/viewtopic. ... al#p512170
Ultimately, my goal was a macro to try a visualization approach, while in sketch-edit if the user selects 'External geometry' do this:
1) Tilt the camera view 5 degrees
2) Set to Wireframe
3) Trigger a dialog to select the object (hide unselected) under the cursor.
And of coarse undo all of that when 'External geometry' is de-selected.
I know that getting this info from the python console is far from ideal but Sketcher is not exposing itself much. If nothing else maybe this will inspire some API work for Sketcher.