Python Part.makeLine() Examples

The following are 30 code examples of Part.makeLine(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module Part , or try the search function .
Example #1
Source File: makeroundedbox.py    From LCInterlocking with GNU Lesser General Public License v2.1 6 votes vote down vote up
def get_contours_with_arc(edge, arcs_segment_list):
    nb_face = len(edge)

    outer_contours = []
    inner_contours = []
    for index in range(nb_face):
        first_segment = edge[index][0]
        second_segment = edge[index][1]
        last_segment = edge[(index + 1) % nb_face][0]

        outer_contours.append(Part.makeLine(first_segment.A, second_segment.A))
        inner_contours.append(Part.makeLine(first_segment.B, second_segment.B))

        outer_contours.append(Part.Arc(second_segment.A, arcs_segment_list[index].A, last_segment.A).toShape())
        inner_contours.append(Part.Arc(second_segment.B, arcs_segment_list[index].B, last_segment.B).toShape())

    return inner_contours, outer_contours 
Example #2
Source File: fuzzy_wire.py    From CurvesWB with GNU Lesser General Public License v2.1 6 votes vote down vote up
def join_2_edges(e1,e2):
    d,pts,info = e1.distToShape(e2)
    if d < 1e-7: # edges are touching
        for i in info:
            if   (i[0] == "Vertex") and (i[3] == "Vertex"): # Contact type : end to end
                return (e1,e2)
            elif (i[0] == "Edge") and (i[3] == "Vertex"): # Contact type : edge to end
                return (longest_segment(e1,i[2]),e2)
            elif (i[0] == "Vertex") and (i[3] == "Edge"): # Contact type : end to edge
                return (e1,longest_segment(e2,i[5]))
            elif (i[0] == "Edge") and (i[3] == "Edge"): # Contact type : edge to edge
                return (longest_segment(e1,i[2]),longest_segment(e2,i[5]))
    else: # No contact : must add a join curve
        for pt,i in zip(pts,info):
            l = Part.makeLine(pt[0],pt[1])
            if   (i[0] == "Vertex") and (i[3] == "Vertex"): # Contact type : end to end
                return (e1,l,e2)
            elif (i[0] == "Edge") and (i[3] == "Vertex"): # Contact type : edge to end
                return (longest_segment(e1,i[2]),l,e2)
            elif (i[0] == "Vertex") and (i[3] == "Edge"): # Contact type : end to edge
                return (e1,l,longest_segment(e2,i[5]))
            elif (i[0] == "Edge") and (i[3] == "Edge"): # Contact type : edge to edge
                return (longest_segment(e1,i[2]),l,longest_segment(e2,i[5])) 
Example #3
Source File: makehinges.py    From LCInterlocking with GNU Lesser General Public License v2.1 6 votes vote down vote up
def draw_rounded_hinge(hinge_width, hinge_length, height):
    half_w = hinge_width/2.0
    half_l = hinge_length/2.0
    half_h = height / 2.0
    z_plane = -half_h
    v1 = FreeCAD.Vector(-half_w, -half_l, z_plane)
    v2 = FreeCAD.Vector(-half_w, half_l, z_plane)
    v3 = FreeCAD.Vector(half_w, half_l, z_plane)
    v4 = FreeCAD.Vector(half_w, -half_l, z_plane)
    vc1 = FreeCAD.Vector(0, -(half_l + half_w), z_plane)
    vc2 = FreeCAD.Vector(0, half_l+half_w, z_plane)
    c1 = Part.Arc(v1, vc1, v4).toShape()
    c2 = Part.Arc(v2, vc2, v3).toShape()
    l1 = Part.makeLine(v1, v2)
    l2 = Part.makeLine(v3, v4)
    wire = Part.Wire([c1, l1, c2, l2])
    hinge = wire.extrude(FreeCAD.Vector(0.0, 0.0, height))
    hinge_solid = Part.makeSolid(hinge)
    return hinge_solid 
Example #4
Source File: crosspart.py    From LCInterlocking with GNU Lesser General Public License v2.1 6 votes vote down vote up
def make_node_yz(width, height, thickness,  x_positive = True):

    p1 = FreeCAD.Vector(-thickness/2.0, 0, height / 2.0)
    p2 = FreeCAD.Vector(-thickness/2.0, 0, -height / 2.0)
    if x_positive is True:
        pa = FreeCAD.Vector(-thickness/2.0, width, 0.)
    else:
        pa = FreeCAD.Vector(-thickness/2.0, -width, 0.)

    l1 = Part.makeLine(p1, p2)
    a2 = Part.Arc(p2, pa, p1).toShape()
    wire = Part.Wire([l1, a2])
    face = Part.Face(wire)
    node = face.extrude(FreeCAD.Vector(thickness, 0, 0))

    return node

# noeud court = 1/4 hauteur
# noeud long = 1/2 hauteur
# 2 neouds court = 2 * 1/4 hauteur espace de 16 % de la hateur au centre 
Example #5
Source File: crosspart.py    From LCInterlocking with GNU Lesser General Public License v2.1 6 votes vote down vote up
def make_node_xz(width, height, thickness,  x_positive = True):

    p1 = FreeCAD.Vector(0., -thickness/2.0, height / 2.0)
    p2 = FreeCAD.Vector(0., -thickness/2.0, -height / 2.0)
    if x_positive is True:
        pa = FreeCAD.Vector(width, -thickness/2.0, 0.)
    else:
        pa = FreeCAD.Vector(-width, -thickness/2.0, 0.)

    l1 = Part.makeLine(p1, p2)
    a2 = Part.Arc(p2, pa, p1).toShape()
    wire = Part.Wire([l1, a2])
    face = Part.Face(wire)
    node = face.extrude(FreeCAD.Vector(0, thickness, 0))

    return node 
Example #6
Source File: crosspart.py    From LCInterlocking with GNU Lesser General Public License v2.1 6 votes vote down vote up
def make_cross_box(length, width, height, node_type, node_thickness):
    half_length = length / 2.0

    p1 = FreeCAD.Vector(half_length, 0, 0)
    p2 = FreeCAD.Vector(-half_length, 0, 0)
    p3 = FreeCAD.Vector(-half_length, 0, -height)
    p4 = FreeCAD.Vector(half_length, 0, -height)

    l1 = Part.makeLine(p1, p2)
    l2 = Part.makeLine(p2, p3)
    l3 = Part.makeLine(p3, p4)
    l4 = Part.makeLine(p4, p1)
    wire = Part.Wire([l1,l2,l3,l4])
    face = Part.Face(wire)
    face.translate(FreeCAD.Vector(0, -width / 2.0, 0))
    part = face.extrude(FreeCAD.Vector(0, width, 0))
    return part 
Example #7
Source File: SheetMetalCmd.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 6 votes vote down vote up
def smMakeReliefFace(edge, dir, gap, reliefW, reliefD, reliefType, op=''):
    p1 = edge.valueAt(edge.FirstParameter + gap)
    p2 = edge.valueAt(edge.FirstParameter + gap + reliefW )
    if reliefType == "Round" and reliefD > reliefW :
      p3 = edge.valueAt(edge.FirstParameter + gap + reliefW) + dir.normalize() * (reliefD-reliefW/2)
      p34 = edge.valueAt(edge.FirstParameter + gap + reliefW/2) + dir.normalize() * reliefD
      p4 = edge.valueAt(edge.FirstParameter + gap) + dir.normalize() * (reliefD-reliefW/2)
      e1 = Part.makeLine(p1, p2)
      e2 = Part.makeLine(p2, p3)
      e3 = Part.Arc(p3, p34, p4).toShape()
      e4 = Part.makeLine(p4, p1)
    else :
      p3 = edge.valueAt(edge.FirstParameter + gap + reliefW) + dir.normalize() * reliefD
      p4 = edge.valueAt(edge.FirstParameter + gap) + dir.normalize() * reliefD
      e1 = Part.makeLine(p1, p2)
      e2 = Part.makeLine(p2, p3)
      e3 = Part.makeLine(p3, p4)
      e4 = Part.makeLine(p4, p1)

    w = Part.Wire([e1,e2,e3,e4])
    face = Part.Face(w)
    if hasattr(face, 'mapShapes'):
        face.mapShapes([(edge,face)],[],op)
    return face 
Example #8
Source File: TestCadObjects.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 6 votes vote down vote up
def testFuse(self):
        """
        Tests fusing one face to another.
        """
        # Face 1
        edge1 = Part.makeLine((0, 0, 0), (0, 10, 0))
        edge2 = Part.makeLine((0, 10, 0), (10, 10, 0))
        edge3 = Part.makeLine((10, 10, 0), (10, 0, 0))
        edge4 = Part.makeLine((10, 0, 0), (0, 0, 0))
        wire1 = Part.Wire([edge1,edge2,edge3,edge4])
        face1 = Part.Face(wire1)
        cqFace1 = Face(face1)

        # Face 2 (face to cut out of face 1)
        edge1 = Part.makeCircle(4.0)
        wire1 = Part.Wire([edge1])
        face2 = Part.Face(wire1)
        cqFace2 = Face(face2)

        # Face resulting from fuse
        cqFace3 = cqFace1.fuse(cqFace2)

        self.assertEquals(len(cqFace3.Faces()), 3)
        self.assertEquals(len(cqFace3.Edges()), 8) 
Example #9
Source File: Asm4_Measure.py    From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 6 votes vote down vote up
def drawLine( self, pt1, pt2, name='aLine', width=3 ):
        global taskUI
        if pt1!=pt2:
            line = Part.makeLine( pt1, pt2 )
            wire = App.ActiveDocument.addObject('Part::FeaturePython', name)
            wire.ViewObject.Proxy = setCustomIcon(wire, taskUI.lineIcon )
            wire.Shape = Part.Wire(line)
            wire.ViewObject.LineWidth = width
            wire.ViewObject.LineColor = ( 1.0, 1.0, 1.0 )
            wire.ViewObject.PointSize = 10
            wire.ViewObject.PointColor= ( 0.0, 0.0, 1.0 )
            self.addToDims(wire)
        else:
            point = App.ActiveDocument.addObject('Part::FeaturePython', 'aPoint')
            point.ViewObject.Proxy = setCustomIcon(point, taskUI.pointIcon )
            point.Shape = Part.Vertex(Part.Point( pt1 ))
            point.ViewObject.PointSize = 10
            point.ViewObject.PointColor= ( 0.0, 0.0, 1.0 )
            self.addToDims(point) 
Example #10
Source File: TestCadObjects.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 6 votes vote down vote up
def testIntersect(self):
        """
        Tests finding the intersection of two faces.
        """
        # Face 1
        edge1 = Part.makeLine((0, 0, 0), (0, 10, 0))
        edge2 = Part.makeLine((0, 10, 0), (10, 10, 0))
        edge3 = Part.makeLine((10, 10, 0), (10, 0, 0))
        edge4 = Part.makeLine((10, 0, 0), (0, 0, 0))
        wire1 = Part.Wire([edge1,edge2,edge3,edge4])
        face1 = Part.Face(wire1)
        cqFace1 = Face(face1)

        # Face 2 (face to cut out of face 1)
        edge1 = Part.makeCircle(4.0)
        wire1 = Part.Wire([edge1])
        face2 = Part.Face(wire1)
        cqFace2 = Face(face2)

        # Face resulting from the intersection
        cqFace3 = cqFace1.intersect(cqFace2)

        self.assertEquals(len(cqFace3.Faces()), 1)
        self.assertEquals(len(cqFace3.Edges()), 3) 
Example #11
Source File: kicad.py    From fcad_pcb with MIT License 6 votes vote down vote up
def make_oval(size,params=None):
    _ = params
    if size.x == size.y:
        return make_circle(size)
    if size.x < size.y:
        r = size.x*0.5
        size.y -= size.x
        s  = ((0,0.5),(-0.5,0.5),(-0.5,-0.5),(0,-0.5),(0.5,-0.5),(0.5,0.5))
        a = (0,180,180,360)
    else:
        r = size.y*0.5
        size.x -= size.y
        s = ((-0.5,0),(-0.5,-0.5),(0.5,-0.5),(0.5,0),(0.5,0.5),(-0.5,0.5))
        a = (90,270,-90,-270)
    pts = [product(size,Vector(*v)) for v in s]
    return Part.Wire([
            Part.makeCircle(r,pts[0],Vector(0,0,1),a[0],a[1]),
            Part.makeLine(pts[1],pts[2]),
            Part.makeCircle(r,pts[3],Vector(0,0,1),a[2],a[3]),
            Part.makeLine(pts[4],pts[5])]) 
Example #12
Source File: TestCadObjects.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 5 votes vote down vote up
def testCut(self):
        """
        Tests cutting one face from another.
        """
        # Face 1
        edge1 = Part.makeLine((0, 0, 0), (0, 10, 0))
        edge2 = Part.makeLine((0, 10, 0), (10, 10, 0))
        edge3 = Part.makeLine((10, 10, 0), (10, 0, 0))
        edge4 = Part.makeLine((10, 0, 0), (0, 0, 0))
        wire1 = Part.Wire([edge1,edge2,edge3,edge4])
        face1 = Part.Face(wire1)
        cqFace1 = Face(face1)

        # Face 2 (face to cut out of face 1)
        edge1 = Part.makeLine((0, 0, 0), (0, 5, 0))
        edge2 = Part.makeLine((0, 5, 0), (5, 5, 0))
        edge3 = Part.makeLine((5, 5, 0), (5, 0, 0))
        edge4 = Part.makeLine((5, 0, 0), (0, 0, 0))
        wire1 = Part.Wire([edge1,edge2,edge3,edge4])
        face2 = Part.Face(wire1)
        cqFace2 = Face(face2)

        # Face resulting from cut
        cqFace3 = cqFace1.cut(cqFace2)

        self.assertEquals(len(cqFace3.Faces()), 1)
        self.assertEquals(len(cqFace3.Edges()), 6) 
Example #13
Source File: TestCadObjects.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 5 votes vote down vote up
def testFace(self):
        """
        Test basic face functions, cast and instantiation
        """
        edge1 = Part.makeLine((0, 0, 0), (0, 10, 0))
        edge2 = Part.makeLine((0, 10, 0), (10, 10, 0))
        edge3 = Part.makeLine((10, 10, 0), (10, 0, 0))
        edge4 = Part.makeLine((10, 0, 0), (0, 0, 0))
        wire1 = Part.Wire([edge1,edge2,edge3,edge4])
        face1 = Part.Face(wire1)

        mplanec = Face.cast(face1)
        mplane = Face(face1)

        self.assertTupleAlmostEquals((5.0, 5.0, 0.0), mplane.Center().toTuple(), 3) 
Example #14
Source File: shapes.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 5 votes vote down vote up
def makeLine(cls, v1, v2):
        """
            Create a line between two points
            :param v1: Vector that represents the first point
            :param v2: Vector that represents the second point
            :return: A linear edge between the two provided points
        """
        return Edge(FreeCADPart.makeLine(v1.toTuple(), v2.toTuple())) 
Example #15
Source File: SheetMetalFoldCmd.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 5 votes vote down vote up
def smthk(obj, foldface) :
  normal = foldface.normalAt(0,0)
  theVol = obj.Volume
  if theVol < 0.0001:
      SMError("Shape is not a real 3D-object or to small for a metal-sheet!")
  else:
      # Make a first estimate of the thickness
      estimated_thk = theVol/(obj.Area / 2.0)
  p1 = foldface.Vertexes[0].Point
  p2 = p1 + estimated_thk * -1.3 * normal
  e1 = Part.makeLine(p1, p2)
  thkedge = obj.common(e1)
  thk = thkedge.Length
  return thk 
Example #16
Source File: SheetMetalUnfolder.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 5 votes vote down vote up
def radial_vector(point, axis_pnt, axis):
  chord = axis_pnt.sub(point)
  norm = axis.cross(chord)
  perp = axis.cross(norm)
  # FreeCAD.Console.PrintLog( str(chord) + ' ' + str(norm) + ' ' + str(perp)+'\n')
  dist_rv = DraftVecUtils.project(chord,perp)
  #test_line = Part.makeLine(axis_pnt.add(dist_rv),axis_pnt)
  # test_line = Part.makeLine(axis_pnt.add(perp),axis_pnt)
  # test_line = Part.makeLine(point, axis_pnt)
  # Part.show(test_line)
  return perp.normalize() 
Example #17
Source File: SheetMetalUnfolder.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 5 votes vote down vote up
def generateBendShell2(self, bend_node):
    '''
    This function takes a cylindrical bend part of sheet metal and
    returns a flat version of that bend part.
    '''
    theCenter = bend_node.bendCenter   # theCyl.Surface.Center
    theAxis = bend_node.axis           # theCyl.Surface.Axis
    # theRadius = theCyl.Surface.Radius # need to include the k-Factor

    zeroVert = bend_node.p_edge.Vertexes[0]
    nullVec = radial_vector(zeroVert.Point, theCenter, theAxis)
    #nullVec_line = Part.makeLine(theCenter, theCenter + nullVec*bend_node.innerRadius)
    #Part.show(nullVec_line, 'nullVec_line'+ str(bend_node.idx+1)+'_')
    #tanVec_line = Part.makeLine(zeroVert.Point, zeroVert.Point + bend_node.tan_vec*bend_node.innerRadius)
    #Part.show(tanVec_line, 'tanVec_line'+ str(bend_node.idx+1)+'_')

    # calculate the unbend points in the bend_ node.vertexDict
    self.unbendVertDict(bend_node, theCenter, theAxis, nullVec)


    bendFaceList = bend_node.nfIndexes[:]
    bendFaceList.remove(bend_node.idx)
    bendFaceList.remove(bend_node.c_face_idx)

    flat_shell = []
    flat_shell.append(self.unbendFace(bend_node.idx, bend_node, nullVec, 'top'))
    flat_shell.append(self.unbendFace(bend_node.c_face_idx, bend_node, nullVec, 'counter'))


    for i in bendFaceList:
      bFace = self.unbendFace(i, bend_node, nullVec)
      flat_shell.append(bFace)
      #Part.show(bFace, 'bFace'+str(i +1))
      #for v in bFace.Vertexes:
      #  print 'Face'+str(i+1) + ' ' + str(v.X) + ' ' + str(v.Y) + ' ' + str(v.Z)

    foldwires = self.makeFoldLines(bend_node, nullVec)
    #print 'face idx: ', bend_node.idx +1, ' folds: ', foldwires
    return flat_shell, foldwires 
Example #18
Source File: makehinges.py    From LCInterlocking with GNU Lesser General Public License v2.1 5 votes vote down vote up
def create_solid_corner(hinge):
    inner_arc_point = hinge.arc_middle_segment.B
    outter_arc_point = hinge.arc_middle_segment.A

    l1 = Part.makeLine(hinge.seg_face_1.A, hinge.seg_face_1.B)
    a2 = Part.Arc(hinge.seg_face_1.B, inner_arc_point, hinge.seg_face_2.B).toShape()
    l3 = Part.makeLine(hinge.seg_face_2.B, hinge.seg_face_2.A)
    a4 = Part.Arc(hinge.seg_face_2.A, outter_arc_point, hinge.seg_face_1.A).toShape()
    wire = Part.Wire([l1, a2, l3, a4])
    face = Part.Face(wire)

    hinge.solid = face.extrude(hinge.extrustion_vector)
    #Part.show(hinge.solid)
    return 
Example #19
Source File: TestCadObjects.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 5 votes vote down vote up
def testRuledSurface(self):
        """
        Tests making a ruled surface from two edges/wires.
        """
        edge1 = Shape(Part.makeLine((0, 0, 5), (0, 10, 5)))
        edge2 = Shape(Part.makeLine((5, 5, 0), (10, 10, 0)))

        surf1 = Face.makeRuledSurface(edge1, edge2)

        self.assertEquals(surf1.ShapeType(), 'Face')
        self.assertTrue(surf1.isValid()) 
Example #20
Source File: ExplodedAssembly.py    From ExplodedAssembly with GNU General Public License v2.0 5 votes vote down vote up
def updateTrajectoryLines():
    EAFolder = FreeCAD.ActiveDocument.ExplodedAssembly.Group
    # remove all the previous trajectory lines
    for traj in EAFolder:
        for lines in traj.Group:
            FreeCAD.ActiveDocument.removeObject(lines.Name)

    # re-draw all trajectories
    for traj in EAFolder:
        lines_compound = []
        objects = []
        for name in traj.names:
            objects.append(FreeCAD.ActiveDocument.getObject(name))

        inc_D = traj.Distance
        dir_vectors = []
        rot_centers = []
        for s in range(len(objects)):
            dir_vectors.append(FreeCAD.Vector(tuple(traj.dir_vectors[s])))
            rot_centers.append(FreeCAD.Vector(tuple(traj.rot_centers[s])))

        for n in range(len(objects)):
            pa = rot_centers[n]# objects[n].Placement.Base
            pb = rot_centers[n] + dir_vectors[n]*inc_D
            lines_compound.append(Part.makeLine(pa, pb))

        l_obj = FreeCAD.ActiveDocument.addObject('Part::Feature','trajectory_line')
        l_obj.Shape = Part.makeCompound(lines_compound)
        l_obj.ViewObject.DrawStyle = "Dashed"
        l_obj.ViewObject.LineWidth = 1.0
        traj.addObject(l_obj)

    FreeCAD.Gui.updateGui() 
Example #21
Source File: kicad.py    From fcad_pcb with MIT License 5 votes vote down vote up
def make_gr_line(params):
    return Part.makeLine(makeVect(params.start),makeVect(params.end)) 
Example #22
Source File: FSNuts.py    From FreeCAD_FastenersWB with GNU General Public License v2.0 5 votes vote down vote up
def nutMakeLine2D(x1, z1, x2, z2):
  return Part.makeLine(FreeCAD.Base.Vector(x1,0,z1),FreeCAD.Base.Vector(x2,0,z2)) 
Example #23
Source File: FastenerBase.py    From FreeCAD_FastenersWB with GNU General Public License v2.0 5 votes vote down vote up
def GetFace(self):
    self.edges.append(Part.makeLine(self.lastPoint, self.firstPoint))
    w = Part.Wire(self.edges)
    return Part.Face(w) 
Example #24
Source File: FastenerBase.py    From FreeCAD_FastenersWB with GNU General Public License v2.0 5 votes vote down vote up
def AddPoint(self, x, z):
    curPoint = FreeCAD.Base.Vector(x,0,z)
    if (self.firstPoint == None):
      self.firstPoint = curPoint
    else:
      self.edges.append(Part.makeLine(self.lastPoint, curPoint))
    self.lastPoint = curPoint
    #FreeCAD.Console.PrintLog("Add Point: " + str(curPoint) + "\n")
    
    # add an arc starting at last point and going through x1,z1 and x2,z2 
Example #25
Source File: frameCmd.py    From flamingo with GNU Lesser General Public License v3.0 5 votes vote down vote up
def vec2edge(point,direct):
  '''
  vec2edge(point,direct)
  Returns an edge placed at point with the orientation and length of direct.
  '''
  from Part import makeLine
  return makeLine(point,point+direct) 
Example #26
Source File: pipeFeatures.py    From flamingo with GNU Lesser General Public License v3.0 5 votes vote down vote up
def execute(self, fp):
    fp.thread="M"+str(float(fp.d))
    c=Part.makeCircle(fp.C/2,FreeCAD.Vector(0,0,0),FreeCAD.Vector(0,0,1),0,180)
    l1=Part.makeLine((fp.C/2,0,0),(fp.C/2,fp.C/2-fp.H,0))
    l2=Part.makeLine((-fp.C/2,0,0),(-fp.C/2,fp.C/2-fp.H,0))
    p=Part.Face(Part.Wire(Part.makeCircle(fp.d/2,c.valueAt(c.FirstParameter),c.tangentAt(c.FirstParameter))))
    path=Part.Wire([c,l1,l2])
    fp.Shape=path.makePipe(p)
    fp.Ports=[FreeCAD.Vector(0,0,1)] 
Example #27
Source File: reparametrize.py    From CurvesWB with GNU Lesser General Public License v2.1 5 votes vote down vote up
def show_lines(e1, e2, params, title=""):
    lines = list()
    for q1,q2 in params:
        lines.append(Part.makeLine(e1.valueAt(q1), e2.valueAt(q2)))
    com = Part.Compound(lines)
    Part.show(com, title) 
Example #28
Source File: ribbon.py    From CurvesWB with GNU Lesser General Public License v2.1 5 votes vote down vote up
def getNotches(self, num=20, l=1.0):
        notches = list()
        for i in range(num):
            par = 1.0*i / (num-1)
            p1, p2 = self.valueAt(par)
            ls = Part.LineSegment(p1, p2)
            p3 = ls.value(ls.FirstParameter - l)
            p4 = ls.value(ls.LastParameter + l)
            nls = Part.makeLine(p3, p4)
            sh1 = self.rail1.face.project([nls])
            sh2 = self.rail2.face.project([nls])
            if (len(sh1.Edges) > 0) and (len(sh2.Edges) > 0):
                notches.append((sh1.Edges[0], sh2.Edges[0]))
        return(notches) 
Example #29
Source File: manipulators.py    From CurvesWB with GNU Lesser General Public License v2.1 5 votes vote down vote up
def tangent_update(self):
        v = Part.Vertex(self.point)
        p = v.distToShape(self.snap_shape)[1][0][1]
        try:
            par = self.snap_shape.Curve.parameter(p)
        except:
            print("Failed to get curve parameter")
            par = self.snap_shape.FirstParameter
        #print(par)
        tan = self.snap_shape.tangentAt(par)
        e = Part.makeLine(p, p+tan)
        self.tangent =  e.Curve.toShape(-2e10, 2e10) 
Example #30
Source File: assembly.py    From FreeCAD_assembly3 with GNU General Public License v3.0 5 votes vote down vote up
def execute(self,obj):
        length = obj.Length.Value
        width = obj.Width.Value
        if not length:
            if not width:
                obj.Shape = Part.Vertex(FreeCAD.Vector())
            else:
                obj.Shape = Part.makeLine(FreeCAD.Vector(0,-width/2,0),
                        FreeCAD.Vector(0,width/2,0))
        elif not width:
            obj.Shape = Part.makeLine(FreeCAD.Vector(-length/2,0,0),
                    FreeCAD.Vector(length/2,0,0))
        else:
            obj.Shape = Part.makePlane(length,width,
                    FreeCAD.Vector(-length/2,-width/2,0))