Default draw Style

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
dammerel
Posts: 98
Joined: Sat Aug 09, 2014 2:15 am

Default draw Style

Post by dammerel »

Hi all I am using 0.18 freecad is there a way to preset a draw style as default example I like the flatline mode

Thank you Andrew
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Default draw Style

Post by vocx »

dammerel wrote: Wed Jan 15, 2020 8:31 am Hi all I am using 0.18 freecad is there a way to preset a draw style as default example I like the flatline mode

Thank you Andrew
Flat Lines is the default style. What are you trying to do exactly, which workbench are you using?

You need to provide Important information.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Default draw Style

Post by triplus »

Hi Andrew.

AFAIK there currently isn't a setting for that. In addition each time you create a new document, the draw style gets reset and is document dependent. Hence you can't run some code snippet once, on for example FreeCAD start. What you could do is to first create a macro with such contents:

Code: Select all

Gui.runCommand('Std_New')
Gui.runCommand('Std_DrawStyle', 3)
And after to create a macro command on (global) toolbar:

https://www.freecadweb.org/wiki/Customize_Toolbars

Now instead of pressing on "Create a new document" command, you press on the newly created macro command. And that should give you the results you are after.

P.S. https://www.freecadweb.org/wiki/Std_DrawStyle#Scripting
User avatar
Roy_043
Veteran
Posts: 8547
Joined: Thu Dec 27, 2018 12:28 pm

Re: Default draw Style

Post by Roy_043 »

Shouldn't that be?:

Code: Select all

Gui.runCommand('Std_New')
Gui.runCommand('Std_DrawStyle', 1)
For the menu ( -> View -> Draw Style) to reflect this new value you have to temporarily switch to a different document. Is there a way to avoid that?
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Default draw Style

Post by openBrain »

triplus wrote: Wed Jan 15, 2020 8:43 pm AFAIK there currently isn't a setting for that. In addition each time you create a new document, the draw style gets reset and is document dependent. Hence you can't run some code snippet once, on for example FreeCAD start.
You could have a macro launched at startup that registers a document observer. This latter then can set a default draw style each time a document is open and/or created. ;)
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Default draw Style

Post by triplus »

Roy_043 wrote: Thu Jan 16, 2020 9:07 pm Shouldn't that be?:
I used the number 3 for the demonstration purposes. The number can be any of the following values, depending on the desired outcome:

https://www.freecadweb.org/wiki/Std_DrawStyle#Scripting
openBrain wrote: Thu Jan 16, 2020 9:28 pm You could have a macro launched at startup that registers a document observer. This latter then can set a default draw style each time a document is open and/or created. ;)
Fair point. One can install Autoload module (Tools -> Addon manager) and follow the procedure:

https://forum.freecadweb.org/viewtopic. ... 95#p180338

Copy this code and paste it as a new macro (Autoload_DrawStyle.py):

Code: Select all

import FreeCAD
import FreeCADGui


class DocObserver(object):
    """Document observer."""
    def slotCreatedDocument(self, doc):
        """Change drawstyle on document created."""
        FreeCADGui.runCommand("Std_DrawStyle", 3)
        FreeCAD.Console.PrintMessage("Drawstyle set\n")

do = DocObserver()
FreeCAD.addDocumentObserver(do)
P.S. The extension should be .py and not .FCMacro.
Post Reply