Macro Align Face Object to View: Difference between revisions

From FreeCAD Documentation
(translate)
(Use {{MacroCode}})
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<languages/>
<translate>
<translate>
<!--T:1-->
{{Macro|Icon=Text-x-python|Name=Macro Align Face Object to View|Description=This macro directs the face of the object on the side of the ActiveView.|Author=Mario52}}
{{Macro
|Name=Macro Align Face Object to View
|Icon=Macro_Align_Face_Object_to_View.png
|Description=This macro directs the face of the object on the side of the ActiveView.
|Author=Mario52
|Version=0.1
|Date=2015-01-16
|Download=[https://www.freecadweb.org/wiki/images/d/d5/Macro_Align_Face_Object_to_View.png ToolBar Icon]
|FCVersion=All
|SeeAlso=[[File:FCCamera 00.png|32px|FCCamera]] [[Macro_FCCamera|Macro_FCCamera]]
}}


==Description==
==Description== <!--T:2-->
This macro directs the face of the object on the side of the ActiveView (camera).
This macro directs the face of the object on the side of the ActiveView (camera).
In the case of the face of a borehole (or internal or cylinder) face drilling facing the screen
In the case of the face of a borehole (or internal or cylinder) face drilling facing the screen


==Usage== <!--T:3-->
==How to use==
* Select your object and run the macro
* Select your object and run the macro
* Your object will be of the camera
* Your object will be of the camera


==Script==
==Script== <!--T:4-->
</translate>
</translate>
ToolBar Icon [[Image:Macro_Align_Face_Object_to_View.png]]

'''Macro_Align_Face_Object_to_View.FCMacro'''
'''Macro_Align_Face_Object_to_View.FCMacro'''


{{Code|code=
{{MacroCode|code=
# This macro directs the face of the object on the side of the ActiveView (camera)
# This macro directs the face of the object on the side of the ActiveView (camera)
# extact
# extact FCCamera
# 16/01/2015
# 16/01/2015


__title__="FCCamera"
__title__="Macro_Align_Face_Object_to_View"
__author__ = "Mario52"
__author__ = "Mario52"


Line 26: Line 40:


try:
try:
v=Gui.Selection.getSelectionEx()[0].SubObjects[0].Surface.Axis
v=Gui.Selection.getSelectionEx()[0].SubObjects[0].Surface.Axis # to Axis
dir = Gui.Selection.getSelectionEx()[0].SubObjects[0].normalAt(0,0)
# v = Gui.Selection.getSelectionEx()[0].SubObjects[0].normalAt(0,0) # normalAt
r=App.Rotation(App.Vector(0,0,1),v)
r=App.Rotation(App.Vector(0,0,1),v)
Gui.ActiveDocument.ActiveView.setCameraOrientation(r.Q)
Gui.ActiveDocument.ActiveView.setCameraOrientation(r.Q)
Line 35: Line 49:
}}
}}


==Links==


Original macro by wmayer [http://forum.freecadweb.org/viewtopic.php?f=3&t=7029&p=56735&hilit=Shape.Face4#p56735 Looking for some helpful GUI-commands]


{{clear}}
{{clear}}
<languages/>

Revision as of 22:56, 7 May 2020

Other languages:

Macro Align Face Object to View

Description
This macro directs the face of the object on the side of the ActiveView.

Macro version: 0.1
Last modified: 2015-01-16
FreeCAD version: All
Download: ToolBar Icon
Author: Mario52
Author
Mario52
Download
ToolBar Icon
Links
Macro Version
0.1
Date last modified
2015-01-16
FreeCAD Version(s)
All
Default shortcut
None
See also
FCCamera Macro_FCCamera

Description

This macro directs the face of the object on the side of the ActiveView (camera). In the case of the face of a borehole (or internal or cylinder) face drilling facing the screen

Usage

  • Select your object and run the macro
  • Your object will be of the camera

Script

ToolBar Icon

Macro_Align_Face_Object_to_View.FCMacro

# This macro directs the face of the object on the side of the ActiveView (camera)
# extact FCCamera
# 16/01/2015

__title__="Macro_Align_Face_Object_to_View"
__author__ = "Mario52"

import pivy
from pivy import coin

try:
    v=Gui.Selection.getSelectionEx()[0].SubObjects[0].Surface.Axis    # to Axis
#    v = Gui.Selection.getSelectionEx()[0].SubObjects[0].normalAt(0,0) # normalAt
    r=App.Rotation(App.Vector(0,0,1),v)
    Gui.ActiveDocument.ActiveView.setCameraOrientation(r.Q)
except Exception:
    App.Console.PrintError("Select a face and run the macro"+"\n")

Links

Original macro by wmayer Looking for some helpful GUI-commands