Macro Align View to Face

From FreeCAD Documentation
Revision as of 16:10, 25 July 2019 by Mario52 (talk | contribs)

Macro Align View to Face

Beschreibung
Dieses Makro richtet die aktuelle Ansicht an einer ausgewählten Fläche aus

Versionsmakro : 1.0
Datum der letzten Änderung : 2014-03-12
FreeCAD version : All
Herunterladen : ToolBar Icon
Autor: Rockn
Autor
Rockn
Herunterladen
ToolBar Icon
Links
Macro-Version
1.0
Datum der letzten Änderung
2014-03-12
FreeCAD-Version(s)
All
Standardverknüpfung
None
Siehe auch
None

Beschreibung

Dieses Makro dreht die aktuelle Ansicht, um senkrecht auf eine ausgewählte Fläche eines vorhandenen Objekts zu zeigen.

Wie verwende ich

  1. Wählen Sie ein Gesicht auf einem Objekt aus
  2. Führen Sie das Makro aus

Skript

ToolBar Icon

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