Skip to content

Instantly share code, notes, and snippets.

@mario52a
Created February 25, 2015 16:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mario52a/77e020fd20fb213fd5f9 to your computer and use it in GitHub Desktop.
Save mario52a/77e020fd20fb213fd5f9 to your computer and use it in GitHub Desktop.
This small macro create a line giving as an argument the XYZ coordinates, length, and angle
# -*- coding: utf-8 -*-
# créer une ligne avec une coordonnée une longueur et un angle sur le plan X Y
# create line with coordinate length and angle to plane X Y
import FreeCAD, FreeCADGui, Draft
from math import cos, sin, radians
#from FreeCAD import Base
def line_length(x1 = 0.0, y1 = 0.0, z1 = 0.0, length = 10.0, angle = 0.0):
x2 = x1 + (length * cos(radians(angle)))
y2 = y1 + (length * sin(radians(angle)))
z2 = z1 #+ ()
Draft.makeWire([FreeCAD.Vector(x1,y1,z1),FreeCAD.Vector(x2,y2,z2)])
x1 = 0.0 # Edit coordinate x1 origin
y1 = 0.0 # Edit coordinate y1 origin
z1 = 0.0 # Edit coordinate z1 origin
length = 50.0 # Edit length
angle = 45.0 # Edit angle plane XY
#line_length(x1, y1, z1, length, angle)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment