Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This macro positioned your object perpendicularly to wire selected.
# -*- coding: utf-8 -*-
__title__ = "Macro Perpendicular To Wire"
__author__ = "Mario52"
__url__ = "https://www.freecadweb.org/wiki/index.php?title=Macro_Perpendicular_To_Wire"
__version__ = "00.02"
__date__ = "06/04/2019"
import Draft, Part
try:
sel = FreeCADGui.Selection.getSelection() # Select an object
lineSelected = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0] # first object the Path object or SubObjects
myCircle = sel[1] # second object
pointsDirection = []
pointsDirection = lineSelected.discretize(Number=500) # discretize the path line first selection
v=pointsDirection[0].sub(pointsDirection[1]) # avec vecteurs 1 et 2 (direction debut ligne)
r=App.Rotation(App.Vector(0,0,1),v)
pl=FreeCAD.Placement() # placement object
pl.Rotation.Q = r.Q
pl.Base = pointsDirection[0]
myCircle.Placement = pl
del pointsDirection[:]
FreeCAD.ActiveDocument.recompute()
except Exception:
print( "Select twoo objects 1:The path 2:The objet to align" )
@mario52a

This comment has been minimized.

Copy link
Owner Author

@mario52a mario52a commented Jan 30, 2017

This macro utility is intended for the use of the program FreeCAD http://www.freecadweb.org/
The icon for your toolbar, it is to place in your macros directory (in the same location of the macro)

macro_perpendicular_to_wire Rename in Macro_Perpendicular_To_Wire.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.