Skip to content

Instantly share code, notes, and snippets.

@mangtronix
Last active April 12, 2016 22:09
Show Gist options
  • Save mangtronix/c88989b3ab2aa96865ca8bfe18f2839c to your computer and use it in GitHub Desktop.
Save mangtronix/c88989b3ab2aa96865ca8bfe18f2839c to your computer and use it in GitHub Desktop.
FreeCAD macro to orient objects to top view
# 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