Last active
April 12, 2016 22:09
-
-
Save mangtronix/c88989b3ab2aa96865ca8bfe18f2839c to your computer and use it in GitHub Desktop.
FreeCAD macro to orient objects to top view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assuming a simple shapes like a triangle, orient to top view. Doesn't handle Z position. | |
# | |
# Usage: | |
# Select shapes and execute macro (e.g. Macro->Macros->Execute) | |
# | |
# mangtronix | |
# 2016-04-14 | |
from FreeCAD import Base | |
for feature in Gui.Selection.getSelection(): | |
if hasattr(feature, "Shape"): | |
normal = feature.Shape.normalAt(0,0) | |
feature.Placement.Rotation = Base.Rotation(normal, Base.Vector(0,0,1)) | |
# Switch to top view and view objects | |
Gui.activeDocument().activeView().viewTop() | |
Gui.SendMsgToActiveView("ViewSelection") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment