Macro Align View to Face/fr: Difference between revisions

From FreeCAD Documentation
mNo edit summary
(Updating to match new version of source page)
Line 1: Line 1:
<languages/>
<languages/>
<div class="mw-translate-fuzzy">
{{Macro/fr
{{Macro/fr
|Name=Macro Align View to Face
|Name=Macro Align View to Face
Line 9: Line 10:
|FCVersion=All
|FCVersion=All
}}
}}
</div>


==Description==
==Description==
Line 19: Line 21:


==Script==
==Script==

ToolBar Icon [[Image:Macro_Align_View_to_Face.png]]


'''Macro_Align_View_to_Face.FCMacro'''
'''Macro_Align_View_to_Face.FCMacro'''

Revision as of 16:08, 25 July 2019

Macro Align View to Face

Description
Cette macro aligne la vue sur la face sélectionnée

Version macro : 2.0
Date dernière modification : 2016-03-06
Version FreeCAD : All
Téléchargement : ToolBar Icon
Auteur: Rockn
Auteur
Rockn
Téléchargement
ToolBar Icon
Liens
Version Macro
2.0
Dernière modification
2016-03-06
Version(s) FreeCAD
All
Raccourci clavier
None
Voir aussi
None

Description

Cette macro pivote la vue courante perpendiculairement sur la face sélectionnée d'un objet existant.

Utilisation

  1. Sélectionnez la face d'un objet.
  2. Lancez la macro

Script

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