Macro Align View to Face/es: Difference between revisions

From FreeCAD Documentation
(Created page with "==Cómo usar== # Seleccionar una cara en un objeto # Ejecutar la macro")
(Updating to match new version of source page)
Line 1: Line 1:
<languages/>
<languages/>
<div class="mw-translate-fuzzy">
{{Macro/es
{{Macro/es
|Name=Macro Align View to Face
|Name=Macro Align View to Face
Line 8: Line 9:
|Date=2014-03-12
|Date=2014-03-12
}}
}}
</div>


==Descripción==
==Descripción==
Line 24: Line 26:
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# Set the current view perpendicular to the selected face
# Set the current view perpendicular to the selected face
# Place la vue perpendiculairement à la face selectionnee
# Place la vue perpendiculairement a la face selectionnee
# 2013 Jonathan Wiedemann, 2016 Werner Mayer
# 2013 Jonathan Wiedemann, 2016 Werner Mayer



Revision as of 19:44, 7 June 2019

Vista de alineación de macro a cara

Descripción
Esta macro alinea la vista actual a una cara seleccionada

Versión macro : 1.0
Fecha última modificación : 2014-03-12
Autor : Rockn
Autor
Rockn
Descargar
None
Enlace
Versión Macro
1.0
Fecha última modificación
2014-03-12
Versión(es) FreeCAD
None
Acceso directo predeterminado
None
Ver también
None

Descripción

Esta macro gira la vista actual para apuntar perpendicularmente a una cara seleccionada de un objeto existente.

Cómo usar

  1. Seleccionar una cara en un objeto
  2. Ejecutar la 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")