FreeCAD Logo FreeCAD 1.0
  • English Afrikaans Arabic Belarusian Catalan Czech German Greek Spanish Spanish Basque Finnish Filipino French Galician Croatian Hungarian Indonesian Italian Japanese Kabyle Korean Lithuanian Dutch Norwegian Bokmal Polish Portuguese Portuguese Romanian Russian Slovak Slovenian Serbian Swedish Turkish Ukrainian Valencian Vietnamese Chinese Chinese
  • Features
  • Download
  • Blog
  • Documentation
    Documentation index Getting started Users documentation The FreeCAD manual Workbenches documentation Python coding documentation C++ coding documentation Tutorials Frequently asked questions Privacy policy About FreeCAD
  • Contribute
    How to help Sponsor Report a bug Make a pull request Jobs and funding Contribution guidelines Developers handbook Translations
  • Community
    Code of conduct Forum The FPA GitHub GitLab Codeberg Mastodon Matrix IRC IRC via Webchat Gitter Discord Reddit Twitter Facebook LinkedIn Calendar
  • ♥ Donate

Donate

$
SEPA Information
Please set up your SEPA bank transfer to:
Beneficiary: The FreeCAD project association
IBAN: BE04 0019 2896 4531
BIC/SWIFT: GEBABEBBXXX
Bank agency: BNP Paribas Fortis
Address: Rue de la Station 64, 1360 Perwez, Belgium

While Stripe doesn't support monthly donations, you can still become a sponsor! Simply make a one-time donation equivalent to 12 months of support, and you'll gain access to the corresponding sponsoring tier. It's an easy and flexible way to contribute.

If you are not sure or not able to commit to a regular donation, but still want to help the project, you can do a one-time donation, of any amount.

Choose freely the amount you wish to donate one time only.

You can support FreeCAD by sponsoring it as an individual or organization through various platforms. Sponsorship provides a steady income for developers, allowing the FPA to plan ahead and enabling greater investment in FreeCAD. To encourage sponsorship, we offer different tiers, and unless you choose to remain anonymous, your name or company logo will be featured on our website accordingly.

from 1 USD / 1 EUR per month. You will not have your name displayed here, but you will have helped the project a lot anyway. Together, normal sponsors maintain the project on its feet as much as the bigger sponsors.

from 25 USD / 25 EUR per month. Your name or company name is displayed on this page.

from 100 USD / 100 EUR per month. Your name or company name is displayed on this page, with a link to your website, and a one-line description text.

from 200 USD / 200 EUR per month. Your name or company name and logo displayed on this page, with a link to your website and a custom description text. Companies that have helped FreeCAD early on also appear under Gold sponsors.

Instead of donating each month, you might find it more comfortable to make a one-time donation that, when divided by twelve, would give you right to enter a sponsoring tier. Don't hesitate to do so!

Choose freely the amount you wish to donate each month.

Please inform your forum name or twitter handle as a notein your transfer, or reach to us, so we can give you proper credits!

Macro Toggle Drawstyle Optimized

Description
Script optimized for all languages and to object selected or all objects.

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.
See also:
Toggle global display mode: Macro_Toggle_Drawstyle_Optimized_2.FCMacro
Toggle selected object(s) display mode (changes visible only in global As is (located on View toolbar) display mode): Macro_Toggle_Drawstyle_Optimized_3.FCMacro

Macro version: 2.0
Last modified: 2020-29-01
FreeCAD version: 0.17 and above
Download: ToolBar Icon
Author: Piffpoof, triplus

Author
Piffpoof, triplus
Download
ToolBar Icon
Links
Macros recipes
How to install macros
How to customize toolbars
Macro Version
2.0
Date last modified
2020-29-01
FreeCAD Version(s)
0.17 and above
Default shortcut
None
See also
Macro Toggle Drawstyle

Description

Script optimized for all languages and to object selected or all objects.

Three macros are available:

  • Combination that toggle global display mode when nothing is selected and/or toggle selected objects display mode if objects are selected. When objects are selected global display mode is automatically set to As is: Macro_Toggle_Drawstyle_Optimized.FCMacro
  • Toggle global display mode: Macro_Toggle_Drawstyle_Optimized_2.FCMacro
  • Toggle selected object(s) display mode (changes visible only in global As is (located on View toolbar) display mode): Macro_Toggle_Drawstyle_Optimized_3.FCMacro

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.

Installation

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

Usage

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).

Script

Combination that toggle global display mode when nothing is selected and/or toggle selected objects display mode if objects are selected. When objects are selected global display mode is automatically set to As is:

ToolBar icon

Macro_Toggle_Drawstyle_Optimized.FCMacro

# triplus @ 2016, 2020
# Toggle object/global display mode
# ==============================

# 0 = "As is"
# 1 = "Flat lines"
# 2 = "Shaded
# 3 = "Wireframe"
# 4 = "Points"
# 5 = "Hidden line"
# 6 = "No shading"

globalA = 0
globalB = 3

a = "Flat Lines"
b = "Shaded"
c = "Wireframe"
d = "Points"

objectA = a
objectB = c

# ==============================

from PySide import QtGui
import FreeCADGui as Gui

mw = Gui.getMainWindow()
sel = Gui.Selection.getSelectionEx()


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"),
}


default = act[0]
actionA = act[globalA]
actionB = act[globalB]


if sel:
    obj = []
    default.trigger()
    for s in sel:
        if s.Object.TypeId == "App::Link":
            if s.Object.LinkedObject not in obj:
                obj.append(s.Object.LinkedObject)
        elif s.Object not in obj:
            obj.append(s.Object)
        else:
            pass

    for o in obj:
        if o.ViewObject.DisplayMode == objectA:
            o.ViewObject.DisplayMode = objectB
        else:
            o.ViewObject.DisplayMode = objectA
else:
    if actionA.isChecked():
        actionB.trigger()
    else:
        actionA.trigger()

Script 2

Toggle global display mode:

The icon ToolBar

Macro_Toggle_Drawstyle_Optimized_2.FCMacro

# triplus @ 2016, 2020
# Toggle global display mode
# ==============================

# 0 = "As is"
# 1 = "Flat lines"
# 2 = "Shaded
# 3 = "Wireframe"
# 4 = "Points"
# 5 = "Hidden line"
# 6 = "No shading"

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()

Script 3

Toggle selected object(s) display mode (changes visible only in global As is (located on View toolbar) display mode):

The icon ToolBar

Macro_Toggle_Drawstyle_Optimized_3.FCMacro

# triplus @ 2016, 2020
# Toggle selected object(s) display mode
# ==============================

a = "Flat Lines"
b = "Shaded"
c = "Wireframe"
d = "Points"

styleA = a
styleB = c

# ==============================

from PySide import QtGui
import FreeCADGui as Gui

obj = []
mw = Gui.getMainWindow()
sel = Gui.Selection.getSelectionEx()
mw.findChild(QtGui.QAction, "Std_DrawStyleAsIs").trigger()


for s in sel:
    if s.Object.TypeId == "App::Link":
        if s.Object.LinkedObject not in obj:
            obj.append(s.Object.LinkedObject)
    elif s.Object not in obj:
        obj.append(s.Object)
    else:
        pass


for o in obj:
    if o.ViewObject.DisplayMode == styleA:
        o.ViewObject.DisplayMode = styleB
    else:
        o.ViewObject.DisplayMode = styleA

Links

The Forum link (2016-11-27 ver:1.0 FC =< 0.17) : Keyboard shortcut, View toolbar - Wireframe

The Forum link (2020-29-01 ver:2.0 FC => 0.17) : Keyboard shortcut, View toolbar - Wireframe

This page is retrieved from https://wiki.freecad.org/Macro_Toggle_Drawstyle_Optimized

Get in touch!
Forum GitHub Mastodon Matrix IRC Gitter.im Discord Reddit Twitter Facebook LinkedIn

© The FreeCAD Team. Homepage image credits (top to bottom): ppemawm, r-frank, epileftric, regis, rider_mortagnais, bejant.

This project is supported by: , KiCad Services Corp. and other sponsors

GitHubImprove this page on GitHub