{{Macro |Name=Macro Toggle Drawstyle |Description=When working with FreeCAD there are times when you want to quickly change the Drawstyle of the object you are working with. This is available through the Drawstyle pull-down menu where any Drawstyle may be selected. This macro makes 2 of the Drawstyles available as a clickable button on a toolbar which the user may click to toggle back and forth between the two Drawstyles. The user can modify the macro code to select which 2 Drawstyles they wish to toggle between. This does not add functionality missing in the Drawstyles pull-down menu, but rather an increased convenience level. |Author=Piffpoof |Version=2.0 |Date=2020-02-02 |FCVersion= >=0.17 |Download=[https://www.freecadweb.org/wiki/images/0/0b/Macro_Toggle_Drawstyle.png ToolBar Icon] |SeeAlso=Macro Toggle Drawstyle Optimized for all language }}
When working with FreeCAD there are times when you want to quickly change the Drawstyle of the object you are working with. This is available through the Drawstyle pull-down menu where any Drawstyle may be selected. This macro makes 2 of the Drawstyles available as a clickable button on a toolbar which the user may click to toggle back and forth between the two Drawstyles. The user can modify the macro code to select which 2 Drawstyles they wish to toggle between. This does not add functionality missing in the Drawstyles pull-down menu, but rather an increased convenience level.
Installation is comprised of copying the two code to the appropriate Macro directory and invoking it from the Macro menu. It is much preferable to add it both to a toolbar so as to be more easily available.
- see How to install macros for information on how to install this macro code
- see Customize Toolbars for information how to install as a button on a toolbar
Select an object, then click on the associated toolbar button, or invoke from the Macro menu. The Drawstyle of the slected object will toggle between the two drawstyles specified in the macro code (see code listing below). Note: The specification for each Drawstyle is listed in the code, by modifying the code (which is documented in the macro code) the user may select which 2 Drawstyles are toggled between.
The selected object will be redrawn in the other drawstyle specified in the macro.
Script optimized for all languages and to object selected or all objects Keyboard shortcut, View toolbar - Wireframe (Sun Nov 27, 2016 6:49 pm)
Macro Toggle Drawstyle.FCMacro
{{MacroCode|code=
###Legal Values for Drawstyle###
5 = "Hidden line"
################################
==============================
5 = "Hidden line"
styleA = 0 styleB = 3
==============================
from PySide import QtGui import FreeCADGui as Gui
mw = Gui.getMainWindow()
act = { 0: mw.findChild(QtGui.QAction, "Std_DrawStyleAsIs"), 1: mw.findChild(QtGui.QAction, "Std_DrawStyleFlatLines"), 2: mw.findChild(QtGui.QAction, "Std_DrawStyleShaded"), 3: mw.findChild(QtGui.QAction, "Std_DrawStyleWireframe"), 4: mw.findChild(QtGui.QAction, "Std_DrawStylePoints"), 5: mw.findChild(QtGui.QAction, "Std_DrawStyleHiddenLine"), 6: mw.findChild(QtGui.QAction, "Std_DrawStyleNoShading"), }
actionA = act[styleA] actionB = act[styleB]
if actionA.isChecked(): actionB.trigger() else: actionA.trigger()
}}
The forum discussion Keyboard shortcut, View toolbar - Wireframe
documentation index > Macro Toggle Drawstyle