Setting view direction from within script

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
Mark Szlazak
Posts: 439
Joined: Tue Apr 04, 2017 6:06 pm
Location: SF Bay Area, California

Setting view direction from within script

Post by Mark Szlazak »

I manually found a "custom" view on the GUI that i like for a bunch of parts i created with a script. If i save the result to a FreeCAD file then I get this custom view automatically when opening the file.

How can i extract this view information from FreeCAD to put in my script so that anyone using the script alone will get this same custom view on the GUI?
wmayer
Founder
Posts: 20244
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Setting view direction from within script

Post by wmayer »

With

Code: Select all

customView = Gui.ActiveDocument.ActiveView.getCamera()
you get a string representation of the camera settings and with

Code: Select all

Gui.ActiveDocument.ActiveView.setCamera(customView)
you can set it again.
Mark Szlazak
Posts: 439
Joined: Tue Apr 04, 2017 6:06 pm
Location: SF Bay Area, California

Re: Setting view direction from within script

Post by Mark Szlazak »

Thank you! :D
Post Reply