(SOLVED) Zoom to fit working plane?

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
thomas-neemann
Veteran
Posts: 11894
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: (WORKAROUND) Zoom to fit working plane?

Post by thomas-neemann »

mario52 wrote: Fri Feb 24, 2023 5:16 pm ...

hi mario

Thank you for your work, but
if I use it correctly it doesn't work with me
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
mario52
Veteran
Posts: 4690
Joined: Wed May 16, 2012 2:13 pm

Re: (WORKAROUND) Zoom to fit working plane?

Post by mario52 »

Hi

home work fine ... sorry

Zoom_to_fit_working_plane03.gif
Zoom_to_fit_working_plane03.gif (834.98 KiB) Viewed 1007 times

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.21.0.31917 (Git)
Build type: Release
Branch: master
Hash: 4639283b459f9ff9093e289908cc003db8745b82
Python 3.10.9, Qt 5.15.6, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
thomas-neemann
Veteran
Posts: 11894
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: (WORKAROUND) Zoom to fit working plane?

Post by thomas-neemann »

mario52 wrote: Fri Feb 24, 2023 6:41 pm ...
there is probably a misunderstanding here. this video might clear it up

https://www.youtube.com/watch?v=CGGjZP41lxg


phpBB [video]
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
mario52
Veteran
Posts: 4690
Joined: Wed May 16, 2012 2:13 pm

Re: (WORKAROUND) Zoom to fit working plane?

Post by mario52 »

Hi
thomas-neemann wrote: Fri Feb 24, 2023 6:56 pm
try the new code in my precedent post

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
thomas-neemann
Veteran
Posts: 11894
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: (WORKAROUND) Zoom to fit working plane?

Post by thomas-neemann »

mario52 wrote: Fri Feb 24, 2023 9:01 pm ...
when I run it as a macro I get this


Python 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:36:16) [GCC 10.4.0] on linux
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> # App.setActiveDocument("Unbenannt3")
>>> # App.ActiveDocument=App.getDocument("Unbenannt3")
>>> # Gui.ActiveDocument=Gui.getDocument("Unbenannt3")
>>> App.closeDocument("Unbenannt4")
>>> ### Begin command Std_New
>>> App.newDocument("Unbenannt")
>>> # App.setActiveDocument("Unbenannt4")
>>> # App.ActiveDocument=App.getDocument("Unbenannt4")
>>> # Gui.ActiveDocument=Gui.getDocument("Unbenannt4")
>>> Gui.activeDocument().activeView().viewDefaultOrientation()
>>> ### End command Std_New
>>> FreeCAD.DraftWorkingPlane.alignToPointAndAxis(FreeCAD.Vector(0.0, 0.0, 0.0), FreeCAD.Vector(0, 0, 1), 0.0)
>>> FreeCADGui.Snapper.setGrid()
>>> Gui.runCommand('Std_DlgMacroExecute',0)
>>>


when i copy paste it into the python console i get this


Python 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:36:16) [GCC 10.4.0] on linux
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> # 24/02/2023
>>> # adapted for the workingPlane v2
>>> #https://forum.freecadweb.org/viewtopic. ... 20#p407855
>>> #[FEATURE REQUEST] Life-size view ?
>>> from pivy import coin
>>> #gridEvery = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetInt("gridEvery") # 20
>>> #gridSpacingF = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetFloat("gridSpacing") # 5
>>> gridSize = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetInt("gridSize") # 100
>>> gridSpacingS = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetString("gridSpacing") # 10.0 mm
>>> gridSpacingI = int(gridSpacingS.split(",")[0])
>>> ##
>>>
>>> Gui.activeDocument().activeView().viewTop()
>>>
>>> cam = Gui.ActiveDocument.ActiveView.getCameraNode()
>>> cam.position.setValue(App.Vector(0,0,0))
>>>
>>> vpSize = Gui.activeView().getSize()
>>> invHeight = min(vpSize[0], vpSize[1])
>>> vpDpi = Gui.getMainWindow().physicalDpiX()
>>> cam.height.setValue((invHeight*25.4/vpDpi)+(gridSize*gridSpacingI))
>>> cam.height.getValue()


in both cases the grid disappears
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
mario52
Veteran
Posts: 4690
Joined: Wed May 16, 2012 2:13 pm

Re: (WORKAROUND) Zoom to fit working plane?

Post by mario52 »

Hi

I don't know !

here it work fine , here with 2 different document open

paste in Python console or as a macro
Zoom_to_fit_working_plane04.gif
Zoom_to_fit_working_plane04.gif (728.98 KiB) Viewed 825 times
Zoom_to_fit_working_plane04.png
Zoom_to_fit_working_plane04.png (10.33 KiB) Viewed 825 times

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.21.0.31917 (Git)
Build type: Release
Branch: master
Hash: 4639283b459f9ff9093e289908cc003db8745b82
Python 3.10.9, Qt 5.15.6, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
thomas-neemann
Veteran
Posts: 11894
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: (WORKAROUND) Zoom to fit working plane?

Post by thomas-neemann »

mario52 wrote: Sat Feb 25, 2023 11:29 am ...

can it be that it runs differently under windows than under linux?
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
User avatar
thomas-neemann
Veteran
Posts: 11894
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: (WORKAROUND) Zoom to fit working plane?

Post by thomas-neemann »

mario52 wrote: Sat Feb 25, 2023 11:29 am ...
if you turn on toggle axis cross it works, if you turn it off again it still works until freecad restart

thank you very much
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
mario52
Veteran
Posts: 4690
Joined: Wed May 16, 2012 2:13 pm

Re: (SOLVED) Zoom to fit working plane?

Post by mario52 »

Hi
thomas-neemann wrote: Sat Feb 25, 2023 12:12 pm if you turn on toggle axis cross it works, if you turn it off again it still works until freecad restart
good also (after config and restart) with or without axis

Code: Select all

OS: Ubuntu 20.10 (KDE/plasma)
Word size of FreeCAD: 64-bit
Version: 0.21.30492 (Git) AppImage
Build type: Release
Branch: master
Hash: b4578fb3eae842eb510a1bc055d07d369a67ce94
Python 3.10.6, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
good day

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
thomas-neemann
Veteran
Posts: 11894
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: (SOLVED) Zoom to fit working plane?

Post by thomas-neemann »

mario52 wrote: Sat Feb 25, 2023 7:46 pm ....
strange. 0.21 doesn't work here either

Code: Select all

OS: Ubuntu 20.04.1 LTS (XFCE/xubuntu)
Word size of FreeCAD: 64-bit
Version: 0.21.0.31917 (Git) AppImage
Build type: Release
Branch: master
Hash: 4639283b459f9ff9093e289908cc003db8745b82
Python 3.10.9, Qt 5.15.6, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: German/Germany (de_DE)
Installed mods: 
  * 3D_Printing_Tools
  * Curves 0.6.6
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
Post Reply