Macro Align Object to View

From FreeCAD Documentation
This page is a translated version of the page Macro Align Object to View and the translation is 100% complete.
Other languages:

Macro Align Object to View

Description
Cette macro aligne l'objet sélectionné sur la vue 3D.

Version macro : 0.1
Date dernière modification : 2015-01-16
Version FreeCAD : All
Téléchargement : ToolBar Icon
Auteur: Mario52
Auteur
Mario52
Téléchargement
ToolBar Icon
Liens
Version Macro
0.1
Dernière modification
2015-01-16
Version(s) FreeCAD
All
Raccourci clavier
None
Voir aussi
FCCamera Macro_FCCamera

Description

Cette macro aligne l'objet sélectionné sur la vue 3D.

Utilisation

  • Dirigez votre vue, sélectionnez votre objet et lancez la macro
  • Votre objet est dirigé sur la position de la caméra

Script

ToolBar Icon

Macro_Align_Object_to_View.FCMacro

# This macro place your object selected to the position ActiveView (camera)
# extact FCCamera
# 16/01/2015

__title__  ="Align Object to View"
__author__ = "Mario52"
__date__   = "16/01/2015"
__version__= "0.1"

import pivy
from pivy import coin

sel = FreeCADGui.Selection.getSelection()
Nameelement = sel[0].Name
App.Console.PrintMessage(str(Nameelement)+"\n")

pl = FreeCAD.Placement()
pl.Rotation = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation()
pl.Base = FreeCAD.Vector(0.0,0.0,0.0)

App.ActiveDocument.getObject(Nameelement).Placement=pl

Exemple

Credits

Merci rentlau_64 pour avoir simplifié le code