Last active
August 12, 2021 23:50
-
-
Save mario52a/60d240ed6845f97f67a1423603a774f0 to your computer and use it in GitHub Desktop.
This macro positioned your object perpendicularly to wire selected.
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
# -*- 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" ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)
Rename in Macro_Perpendicular_To_Wire.png