Macro Align View to Face: Difference between revisions
No edit summary |
(Marked this version for translation) |
||
Line 19: | Line 19: | ||
This macro rotates the current view to point perpendicularly at a selected face of an existing object. |
This macro rotates the current view to point perpendicularly at a selected face of an existing object. |
||
==Usage== |
==Usage== <!--T:7--> |
||
<!--T:4--> |
<!--T:4--> |
||
Line 27: | Line 27: | ||
==Script== <!--T:5--> |
==Script== <!--T:5--> |
||
<!--T:8--> |
|||
ToolBar Icon [[Image:Macro_Align_View_to_Face.png]] |
ToolBar Icon [[Image:Macro_Align_View_to_Face.png]] |
||
Revision as of 08:48, 2 July 2022
Description |
---|
This macro aligns the current view to a selected face Macro version: 2.0 Last modified: 2016-03-06 FreeCAD version: All Download: ToolBar Icon Author: Rockn |
Author |
Rockn |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
2.0 |
Date last modified |
2016-03-06 |
FreeCAD Version(s) |
All |
Default shortcut |
None |
See also |
None |
Description
This macro rotates the current view to point perpendicularly at a selected face of an existing object.
Usage
- Select a face on an object
- Run the macro
Script
Macro_Align_View_to_Face.FCMacro
# -*- coding: utf-8 -*- # Set the current view perpendicular to the selected face # Place la vue perpendiculairement a la face selectionnee # 2013 Jonathan Wiedemann, 2016 Werner Mayer from pivy import coin def pointAt(normal, up): z = normal y = up x = y.cross(z) y = z.cross(x) rot = App.Matrix() rot.A11 = x.x rot.A21 = x.y rot.A31 = x.z rot.A12 = y.x rot.A22 = y.y rot.A32 = y.z rot.A13 = z.x rot.A23 = z.y rot.A33 = z.z return App.Placement(rot).Rotation s=Gui.Selection.getSelectionEx() obj=s[0] faceSel = obj.SubObjects[0] dir = faceSel.normalAt(0,0) cam = FreeCADGui.ActiveDocument.ActiveView.getCameraNode() if dir.z == 1 : rot = pointAt(dir, App.Vector(0.0,1.0,0.0)) elif dir.z == -1 : rot = pointAt(dir, App.Vector(0.0,1.0,0.0)) else : rot = pointAt(dir, App.Vector(0.0,0.0,1.0)) cam.orientation.setValue(rot.Q) Gui.SendMsgToActiveView("ViewSelection")