replace Part.Line with Part.LineSegment

This commit is contained in:
wmayer 2016-11-30 21:25:18 +01:00
parent e96370f820
commit 1855c80f36
40 changed files with 238 additions and 238 deletions

View File

@ -117,7 +117,7 @@ class _Axis:
ang = math.radians(obj.Angles[i])
p1 = Vector(dist,0,0)
p2 = Vector(dist+(l/math.cos(ang))*math.sin(ang),l,0)
geoms.append(Part.Line(p1,p2).toShape())
geoms.append(Part.LineSegment(p1,p2).toShape())
if geoms:
sh = Part.Compound(geoms)
sh.Placement = obj.Placement

View File

@ -192,13 +192,13 @@ class _ArchPipe(ArchComponent.Component):
e = w.Edges[0]
v = e.Vertexes[-1].Point.sub(e.Vertexes[0].Point).normalize()
v.multiply(obj.OffsetStart.Value)
e = Part.Line(e.Vertexes[0].Point.add(v),e.Vertexes[-1].Point).toShape()
e = Part.LineSegment(e.Vertexes[0].Point.add(v),e.Vertexes[-1].Point).toShape()
w = Part.Wire([e]+w.Edges[1:])
if obj.OffsetEnd.Value:
e = w.Edges[-1]
v = e.Vertexes[0].Point.sub(e.Vertexes[-1].Point).normalize()
v.multiply(obj.OffsetEnd.Value)
e = Part.Line(e.Vertexes[-1].Point.add(v),e.Vertexes[0].Point).toShape()
e = Part.LineSegment(e.Vertexes[-1].Point.add(v),e.Vertexes[0].Point).toShape()
w = Part.Wire(w.Edges[:-1]+[e])
p = self.getProfile(obj)
if not p:
@ -239,7 +239,7 @@ class _ArchPipe(ArchComponent.Component):
else:
if obj.Length.Value == 0:
return
w = Part.Wire([Part.Line(FreeCAD.Vector(0,0,0),FreeCAD.Vector(0,0,obj.Length.Value)).toShape()])
w = Part.Wire([Part.LineSegment(FreeCAD.Vector(0,0,0),FreeCAD.Vector(0,0,obj.Length.Value)).toShape()])
return w
def getProfile(self,obj):

View File

@ -124,7 +124,7 @@ def makeSolarDiagram(longitude,latitude,scale=1,complete=False):
p1 = FreeCAD.Vector(math.cos(a)*scale,math.sin(a)*scale,0)
p2 = FreeCAD.Vector(math.cos(a)*scale*0.125,math.sin(a)*scale*0.125,0)
p3 = FreeCAD.Vector(math.cos(a)*scale*1.08,math.sin(a)*scale*1.08,0)
circles.append(Part.Line(p1,p2).toShape())
circles.append(Part.LineSegment(p1,p2).toShape())
circlepos.append((ad,p3))
# build the sun curves at solstices and equinoxe

View File

@ -177,7 +177,7 @@ class _Stairs(ArchComponent.Component):
return
if (len(obj.Base.Shape.Edges) == 1):
edge = obj.Base.Shape.Edges[0]
if isinstance(edge.Curve,Part.Line):
if isinstance(edge.Curve,Part.LineSegment):
if obj.Landings == "At center":
landings = 1
self.makeStraightStairsWithLanding(obj,edge)
@ -192,7 +192,7 @@ class _Stairs(ArchComponent.Component):
else:
if not obj.Length.Value:
return
edge = Part.Line(Vector(0,0,0),Vector(obj.Length.Value,0,0)).toShape()
edge = Part.LineSegment(Vector(0,0,0),Vector(obj.Length.Value,0,0)).toShape()
if obj.Landings == "At center":
landings = 1
self.makeStraightStairsWithLanding(obj,edge)
@ -478,9 +478,9 @@ class _Stairs(ArchComponent.Component):
p2 = p1.add(DraftVecUtils.scale(vLength,landing-1).add(Vector(0,0,landing*hstep)))
p3 = p2.add(DraftVecUtils.scaleTo(vLength,obj.Width.Value))
p4 = p3.add(DraftVecUtils.scale(vLength,obj.NumberOfSteps-(landing+1)).add(Vector(0,0,(obj.NumberOfSteps-landing)*hstep)))
self.makeStraightStairs(obj,Part.Line(p1,p2).toShape(),landing)
self.makeStraightLanding(obj,Part.Line(p2,p3).toShape())
self.makeStraightStairs(obj,Part.Line(p3,p4).toShape(),obj.NumberOfSteps-landing)
self.makeStraightStairs(obj,Part.LineSegment(p1,p2).toShape(),landing)
self.makeStraightLanding(obj,Part.LineSegment(p2,p3).toShape())
self.makeStraightStairs(obj,Part.LineSegment(p3,p4).toShape(),obj.NumberOfSteps-landing)
def makeCurvedStairs(self,obj,edge):

View File

@ -555,7 +555,7 @@ class _Structure(ArchComponent.Component):
elif extdata[1].Length > 0:
if hasattr(nodes,"CenterOfMass"):
import Part
nodes = Part.Line(nodes.CenterOfMass,nodes.CenterOfMass.add(extdata[1])).toShape()
nodes = Part.LineSegment(nodes.CenterOfMass,nodes.CenterOfMass.add(extdata[1])).toShape()
offset = FreeCAD.Vector()
if hasattr(obj,"NodesOffset"):
offset = FreeCAD.Vector(0,0,obj.NodesOffset.Value)
@ -582,10 +582,10 @@ class _Structure(ArchComponent.Component):
if obj.Nodes:
import Part
for i in range(len(obj.Nodes)-1):
edges.append(Part.Line(obj.Placement.multVec(obj.Nodes[i]),obj.Placement.multVec(obj.Nodes[i+1])).toShape())
edges.append(Part.LineSegment(obj.Placement.multVec(obj.Nodes[i]),obj.Placement.multVec(obj.Nodes[i+1])).toShape())
if hasattr(obj.ViewObject,"NodeType"):
if (obj.ViewObject.NodeType == "Area") and (len(obj.Nodes) > 2):
edges.append(Part.Line(obj.Placement.multVec(obj.Nodes[-1]),obj.Placement.multVec(obj.Nodes[0])).toShape())
edges.append(Part.LineSegment(obj.Placement.multVec(obj.Nodes[-1]),obj.Placement.multVec(obj.Nodes[0])).toShape())
return edges

View File

@ -218,7 +218,7 @@ class Renderer:
if len(edge.Vertexes) > 1:
v1 = self.wp.getLocalCoords(edge.Vertexes[0].Point)
v2 = self.wp.getLocalCoords(edge.Vertexes[-1].Point)
return Part.Line(v1,v2).toShape()
return Part.LineSegment(v1,v2).toShape()
return edge
def flattenFace(self,face):

View File

@ -234,12 +234,12 @@ class _CommandWall:
FreeCADGui.Snapper.getPoint(last=self.points[0],callback=self.getPoint,movecallback=self.update,extradlg=self.taskbox())
elif len(self.points) == 2:
import Part
l = Part.Line(FreeCAD.DraftWorkingPlane.getLocalCoords(self.points[0]),FreeCAD.DraftWorkingPlane.getLocalCoords(self.points[1]))
l = Part.LineSegment(FreeCAD.DraftWorkingPlane.getLocalCoords(self.points[0]),FreeCAD.DraftWorkingPlane.getLocalCoords(self.points[1]))
self.tracker.finalize()
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Wall"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand('import Part')
FreeCADGui.doCommand('trace=Part.Line(FreeCAD.'+str(l.StartPoint)+',FreeCAD.'+str(l.EndPoint)+')')
FreeCADGui.doCommand('trace=Part.LineSegment(FreeCAD.'+str(l.StartPoint)+',FreeCAD.'+str(l.EndPoint)+')')
if not self.existing:
# no existing wall snapped, just add a default wall
self.addDefault(l)

View File

@ -126,10 +126,10 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None
def addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8):
"adds two rectangles to the given sketch"
idx = s.GeometryCount
s.addGeometry(Part.Line(p1,p2))
s.addGeometry(Part.Line(p2,p3))
s.addGeometry(Part.Line(p3,p4))
s.addGeometry(Part.Line(p4,p1))
s.addGeometry(Part.LineSegment(p1,p2))
s.addGeometry(Part.LineSegment(p2,p3))
s.addGeometry(Part.LineSegment(p3,p4))
s.addGeometry(Part.LineSegment(p4,p1))
s.addConstraint(Sketcher.Constraint('Coincident',idx,2,idx+1,1))
s.addConstraint(Sketcher.Constraint('Coincident',idx+1,2,idx+2,1))
s.addConstraint(Sketcher.Constraint('Coincident',idx+2,2,idx+3,1))
@ -138,10 +138,10 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None
s.addConstraint(Sketcher.Constraint('Horizontal',idx+2))
s.addConstraint(Sketcher.Constraint('Vertical',idx+1))
s.addConstraint(Sketcher.Constraint('Vertical',idx+3))
s.addGeometry(Part.Line(p5,p6))
s.addGeometry(Part.Line(p6,p7))
s.addGeometry(Part.Line(p7,p8))
s.addGeometry(Part.Line(p8,p5))
s.addGeometry(Part.LineSegment(p5,p6))
s.addGeometry(Part.LineSegment(p6,p7))
s.addGeometry(Part.LineSegment(p7,p8))
s.addGeometry(Part.LineSegment(p8,p5))
s.addConstraint(Sketcher.Constraint('Coincident',idx+4,2,idx+5,1))
s.addConstraint(Sketcher.Constraint('Coincident',idx+5,2,idx+6,1))
s.addConstraint(Sketcher.Constraint('Coincident',idx+6,2,idx+7,1))
@ -762,56 +762,56 @@ class _Window(ArchComponent.Component):
v2 = v1.add(DraftVecUtils.rotate(chord,math.pi/4,enorm))
v3 = v1.add(DraftVecUtils.rotate(chord,math.pi/2,enorm))
ssymbols.append(Part.Arc(p,v2,v3).toShape())
ssymbols.append(Part.Line(v3,v1).toShape())
vsymbols.append(Part.Line(v1,v4).toShape())
vsymbols.append(Part.Line(v4,ev2).toShape())
ssymbols.append(Part.LineSegment(v3,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
elif omode == 2: # Arc -90
v2 = v1.add(DraftVecUtils.rotate(chord,-math.pi/4,enorm))
v3 = v1.add(DraftVecUtils.rotate(chord,-math.pi/2,enorm))
ssymbols.append(Part.Arc(p,v2,v3).toShape())
ssymbols.append(Part.Line(v3,v1).toShape())
vsymbols.append(Part.Line(v1,v4).toShape())
vsymbols.append(Part.Line(v4,ev2).toShape())
ssymbols.append(Part.LineSegment(v3,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
elif omode == 3: # Arc 45
v2 = v1.add(DraftVecUtils.rotate(chord,math.pi/8,enorm))
v3 = v1.add(DraftVecUtils.rotate(chord,math.pi/4,enorm))
ssymbols.append(Part.Arc(p,v2,v3).toShape())
ssymbols.append(Part.Line(v3,v1).toShape())
vsymbols.append(Part.Line(v1,v4).toShape())
vsymbols.append(Part.Line(v4,ev2).toShape())
ssymbols.append(Part.LineSegment(v3,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
elif omode == 4: # Arc -45
v2 = v1.add(DraftVecUtils.rotate(chord,-math.pi/8,enorm))
v3 = v1.add(DraftVecUtils.rotate(chord,-math.pi/4,enorm))
ssymbols.append(Part.Arc(p,v2,v3).toShape())
ssymbols.append(Part.Line(v3,v1).toShape())
vsymbols.append(Part.Line(v1,v4).toShape())
vsymbols.append(Part.Line(v4,ev2).toShape())
ssymbols.append(Part.LineSegment(v3,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
elif omode == 5: # Arc 180
v2 = v1.add(DraftVecUtils.rotate(chord,math.pi/2,enorm))
v3 = v1.add(DraftVecUtils.rotate(chord,math.pi,enorm))
ssymbols.append(Part.Arc(p,v2,v3).toShape())
ssymbols.append(Part.Line(v3,v1).toShape())
vsymbols.append(Part.Line(v1,v4).toShape())
vsymbols.append(Part.Line(v4,ev2).toShape())
ssymbols.append(Part.LineSegment(v3,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
elif omode == 6: # Arc -180
v2 = v1.add(DraftVecUtils.rotate(chord,-math.pi/2,enorm))
v3 = v1.add(DraftVecUtils.rotate(chord,-math.pi,enorm))
ssymbols.append(Part.Arc(p,v2,v3).toShape())
ssymbols.append(Part.Line(v3,v1).toShape())
vsymbols.append(Part.Line(v1,v4).toShape())
vsymbols.append(Part.Line(v4,ev2).toShape())
ssymbols.append(Part.LineSegment(v3,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
elif omode == 7: # tri
v2 = v1.add(DraftVecUtils.rotate(chord,math.pi/2,enorm))
ssymbols.append(Part.Line(p,v2).toShape())
ssymbols.append(Part.Line(v2,v1).toShape())
vsymbols.append(Part.Line(v1,v4).toShape())
vsymbols.append(Part.Line(v4,ev2).toShape())
ssymbols.append(Part.LineSegment(p,v2).toShape())
ssymbols.append(Part.LineSegment(v2,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
elif omode == 8: # -tri
v2 = v1.add(DraftVecUtils.rotate(chord,-math.pi/2,enorm))
ssymbols.append(Part.Line(p,v2).toShape())
ssymbols.append(Part.Line(v2,v1).toShape())
vsymbols.append(Part.Line(v1,v4).toShape())
vsymbols.append(Part.Line(v4,ev2).toShape())
ssymbols.append(Part.LineSegment(p,v2).toShape())
ssymbols.append(Part.LineSegment(v2,v1).toShape())
vsymbols.append(Part.LineSegment(v1,v4).toShape())
vsymbols.append(Part.LineSegment(v4,ev2).toShape())
elif omode == 9: # sliding
pass
elif omode == 10: # -sliding

View File

@ -52,10 +52,10 @@ class ArchTest(unittest.TestCase):
s = Arch.makeStructure(length=2,width=3,height=5)
sk = FreeCAD.ActiveDocument.addObject('Sketcher::SketchObject','Sketch')
sk.Support = (s,["Face6"])
sk.addGeometry(Part.Line(FreeCAD.Vector(-0.85,1.25,0),FreeCAD.Vector(0.75,1.25,0)))
sk.addGeometry(Part.Line(FreeCAD.Vector(0.75,1.25,0),FreeCAD.Vector(0.75,-1.20,0)))
sk.addGeometry(Part.Line(FreeCAD.Vector(0.75,-1.20,0),FreeCAD.Vector(-0.85,-1.20,0)))
sk.addGeometry(Part.Line(FreeCAD.Vector(-0.85,-1.20,0),FreeCAD.Vector(-0.85,1.25,0)))
sk.addGeometry(Part.LineSegment(FreeCAD.Vector(-0.85,1.25,0),FreeCAD.Vector(0.75,1.25,0)))
sk.addGeometry(Part.LineSegment(FreeCAD.Vector(0.75,1.25,0),FreeCAD.Vector(0.75,-1.20,0)))
sk.addGeometry(Part.LineSegment(FreeCAD.Vector(0.75,-1.20,0),FreeCAD.Vector(-0.85,-1.20,0)))
sk.addGeometry(Part.LineSegment(FreeCAD.Vector(-0.85,-1.20,0),FreeCAD.Vector(-0.85,1.25,0)))
sk.addConstraint(Sketcher.Constraint('Coincident',0,2,1,1))
sk.addConstraint(Sketcher.Constraint('Coincident',1,2,2,1))
sk.addConstraint(Sketcher.Constraint('Coincident',2,2,3,1))
@ -90,10 +90,10 @@ class ArchTest(unittest.TestCase):
w = Arch.makeWall(l)
sk = FreeCAD.ActiveDocument.addObject('Sketcher::SketchObject','Sketch001')
sk.Support = (w,["Face3"])
sk.addGeometry(Part.Line(FreeCAD.Vector(-1.80,1.30,0),FreeCAD.Vector(-0.90,1.30,0)))
sk.addGeometry(Part.Line(FreeCAD.Vector(-0.90,1.30,0),FreeCAD.Vector(-0.90,0.25,0)))
sk.addGeometry(Part.Line(FreeCAD.Vector(-0.90,0.25,0),FreeCAD.Vector(-1.80,0.25,0)))
sk.addGeometry(Part.Line(FreeCAD.Vector(-1.80,0.25,0),FreeCAD.Vector(-1.80,1.30,0)))
sk.addGeometry(Part.LineSegment(FreeCAD.Vector(-1.80,1.30,0),FreeCAD.Vector(-0.90,1.30,0)))
sk.addGeometry(Part.LineSegment(FreeCAD.Vector(-0.90,1.30,0),FreeCAD.Vector(-0.90,0.25,0)))
sk.addGeometry(Part.LineSegment(FreeCAD.Vector(-0.90,0.25,0),FreeCAD.Vector(-1.80,0.25,0)))
sk.addGeometry(Part.LineSegment(FreeCAD.Vector(-1.80,0.25,0),FreeCAD.Vector(-1.80,1.30,0)))
sk.addConstraint(Sketcher.Constraint('Coincident',0,2,1,1))
sk.addConstraint(Sketcher.Constraint('Coincident',1,2,2,1))
sk.addConstraint(Sketcher.Constraint('Coincident',2,2,3,1))

View File

@ -1268,7 +1268,7 @@ def getIfcExtrusionData(obj,scale=1,nosubs=False):
for e in p.Edges:
if isinstance(e.Curve,Part.Circle):
curves = True
elif not isinstance(e.Curve,Part.Line):
elif not isinstance(e.Curve,Part.LineSegment):
print "Arch.getIfcExtrusionData: Warning: unsupported edge type in profile"
if curves:
# Composite profile
@ -1356,7 +1356,7 @@ def getIfcBrepFacesData(obj,scale=1,sub=False,tessellation=1):
curves = False
for face in sol.Faces:
for e in face.Edges:
if not isinstance(e.Curve,Part.Line):
if not isinstance(e.Curve,Part.LineSegment):
curves = True
if curves:
tris = sol.tessellate(tessellation)

View File

@ -60,7 +60,7 @@ def getIndices(shape,offset):
curves = None
for e in shape.Edges:
try:
if not isinstance(e.Curve,Part.Line):
if not isinstance(e.Curve,Part.LineSegment):
if not curves:
curves = shape.tessellate(1)
FreeCAD.Console.PrintWarning(translate("Arch","Found a shape containing curves, triangulating\n").decode('utf8'))

View File

@ -1551,8 +1551,8 @@ def offset(obj,delta,copy=False,bind=False,sym=False,occ=False):
s2 = newwire
w1 = s1.Edges
w2 = s2.Edges
w3 = Part.Line(s1.Vertexes[0].Point,s2.Vertexes[0].Point).toShape()
w4 = Part.Line(s1.Vertexes[-1].Point,s2.Vertexes[-1].Point).toShape()
w3 = Part.LineSegment(s1.Vertexes[0].Point,s2.Vertexes[0].Point).toShape()
w4 = Part.LineSegment(s1.Vertexes[-1].Point,s2.Vertexes[-1].Point).toShape()
newobj = FreeCAD.ActiveDocument.addObject("Part::Feature","Offset")
newobj.Shape = Part.Face(Part.Wire(w1+[w3]+w2+[w4]))
else:
@ -2920,7 +2920,7 @@ def upgrade(objects,delete=False,force=None):
newobj = FreeCAD.ActiveDocument.addObject("Part::Feature","Face")
newobj.Shape = f
else:
edges.append(Part.Line(p1,p0).toShape())
edges.append(Part.LineSegment(p1,p0).toShape())
w = Part.Wire(Part.__sortEdges__(edges))
newobj = FreeCAD.ActiveDocument.addObject("Part::Feature","Wire")
newobj.Shape = w
@ -3140,7 +3140,7 @@ def upgrade(objects,delete=False,force=None):
else:
# turn to Draft line
e = objects[0].Shape.Edges[0]
if isinstance(e.Curve,Part.Line):
if isinstance(e.Curve,Part.LineSegment):
result = turnToLine(objects[0])
if result: msg(translate("draft", "Found 1 linear object: converting to line\n"))
@ -3740,14 +3740,14 @@ class _ViewProviderDimension(_ViewProviderDraft):
base = None
proj = None
else:
base = Part.Line(self.p2,self.p3).toShape()
base = Part.LineSegment(self.p2,self.p3).toShape()
proj = DraftGeomUtils.findDistance(self.p1,base).negative()
if not base:
if DraftVecUtils.equals(self.p1,self.p4):
base = None
proj = None
else:
base = Part.Line(self.p1,self.p4).toShape()
base = Part.LineSegment(self.p1,self.p4).toShape()
proj = DraftGeomUtils.findDistance(obj.Dimline,base)
if proj:
self.p2 = self.p1.add(proj.negative())
@ -4570,15 +4570,15 @@ class _Wire(_DraftObject):
npts = []
v = p.sub(lp)
v = DraftVecUtils.scaleTo(v,v.Length/(obj.Subdivisions+1))
edges.append(Part.Line(lp,lp.add(v)).toShape())
edges.append(Part.LineSegment(lp,lp.add(v)).toShape())
lv = lp.add(v)
for j in range(obj.Subdivisions):
edges.append(Part.Line(lv,lv.add(v)).toShape())
edges.append(Part.LineSegment(lv,lv.add(v)).toShape())
lv = lv.add(v)
else:
edges.append(Part.Line(lp,p).toShape())
edges.append(Part.LineSegment(lp,p).toShape())
else:
edges.append(Part.Line(lp,p).toShape())
edges.append(Part.LineSegment(lp,p).toShape())
lp = p
try:
shape = Part.Wire(edges)

View File

@ -49,11 +49,11 @@ def precision():
return params.GetInt("precision")
def vec(edge):
"vec(edge) or vec(line): returns a vector from an edge or a Part.line"
"vec(edge) or vec(line): returns a vector from an edge or a Part.LineSegment"
# if edge is not straight, you'll get strange results!
if isinstance(edge,Part.Shape):
return edge.Vertexes[-1].Point.sub(edge.Vertexes[0].Point)
elif isinstance(edge,Part.Line):
elif isinstance(edge,Part.LineSegment):
return edge.EndPoint.sub(edge.StartPoint)
else:
return None
@ -62,7 +62,7 @@ def edg(p1,p2):
"edg(Vector,Vector): returns an edge from 2 vectors"
if isinstance(p1,FreeCAD.Vector) and isinstance(p2,FreeCAD.Vector):
if DraftVecUtils.equals(p1,p2): return None
else: return Part.Line(p1,p2).toShape()
else: return Part.LineSegment(p1,p2).toShape()
def getVerts(shape):
"getVerts(shape): returns a list containing vectors of each vertex of the shape"
@ -105,7 +105,7 @@ def isPtOnEdge(pt,edge) :
def hasCurves(shape):
"hasCurve(shape): checks if the given shape has curves"
for e in shape.Edges:
if not isinstance(e.Curve,Part.Line):
if not isinstance(e.Curve,Part.LineSegment):
return True
return False
@ -116,7 +116,7 @@ def isAligned(edge,axis="x"):
if len(edge.Vertexes) == 2:
if edge.Vertexes[0].X == edge.Vertexes[-1].X:
return True
elif isinstance(edge,Part.Line):
elif isinstance(edge,Part.LineSegment):
if edge.StartPoint.x == edge.EndPoint.x:
return True
elif axis == "y":
@ -124,7 +124,7 @@ def isAligned(edge,axis="x"):
if len(edge.Vertexes) == 2:
if edge.Vertexes[0].Y == edge.Vertexes[-1].Y:
return True
elif isinstance(edge,Part.Line):
elif isinstance(edge,Part.LineSegment):
if edge.StartPoint.y == edge.EndPoint.y:
return True
elif axis == "z":
@ -132,7 +132,7 @@ def isAligned(edge,axis="x"):
if len(edge.Vertexes) == 2:
if edge.Vertexes[0].Z == edge.Vertexes[-1].Z:
return True
elif isinstance(edge,Part.Line):
elif isinstance(edge,Part.LineSegment):
if edge.StartPoint.z == edge.EndPoint.z:
return True
return False
@ -159,9 +159,9 @@ def getQuad(face):
def areColinear(e1,e2):
"""areColinear(e1,e2): returns True if both edges are colinear"""
if not isinstance(e1.Curve,Part.Line):
if not isinstance(e1.Curve,Part.LineSegment):
return False
if not isinstance(e2.Curve,Part.Line):
if not isinstance(e2.Curve,Part.LineSegment):
return False
v1 = vec(e1)
v2 = vec(e2)
@ -188,7 +188,7 @@ def hasOnlyWires(shape):
def geomType(edge):
"returns the type of geom this edge is based on"
try:
if isinstance(edge.Curve,Part.Line):
if isinstance(edge.Curve,Part.LineSegment):
return "Line"
elif isinstance(edge.Curve,Part.Circle):
return "Circle"
@ -586,9 +586,9 @@ def isClockwise(edge,ref=None):
def isSameLine(e1,e2):
"""isSameLine(e1,e2): return True if the 2 edges are lines and have the same
points"""
if not isinstance(e1.Curve,Part.Line):
if not isinstance(e1.Curve,Part.LineSegment):
return False
if not isinstance(e2.Curve,Part.Line):
if not isinstance(e2.Curve,Part.LineSegment):
return False
if (DraftVecUtils.equals(e1.Vertexes[0].Point,e2.Vertexes[0].Point)) and \
(DraftVecUtils.equals(e1.Vertexes[-1].Point,e2.Vertexes[-1].Point)):
@ -751,7 +751,7 @@ def sortEdgesOld(lEdges, aVertex=None):
#There is no reason to limit this to lines only because every non-closed edge always
#has exactly two vertices (wmayer)
#for e in lEdges:
# if not isinstance(e.Curve,Part.Line):
# if not isinstance(e.Curve,Part.LineSegment):
# print("Warning: sortedges cannot treat wired containing curves yet.")
# return lEdges
@ -778,14 +778,14 @@ def sortEdgesOld(lEdges, aVertex=None):
return lEdges
else:
if geomType(result[3]) == "Line":
return [Part.Line(aVertex.Point,result[3].Vertexes[0].Point).toShape()]
return [Part.LineSegment(aVertex.Point,result[3].Vertexes[0].Point).toShape()]
elif geomType(result[3]) == "Circle":
mp = findMidpoint(result[3])
return [Part.Arc(aVertex.Point,mp,result[3].Vertexes[0].Point).toShape()]
elif geomType(result[3]) == "BSplineCurve" or\
geomType(result[3]) == "BezierCurve":
if isLine(result[3].Curve):
return [Part.Line(aVertex.Point,result[3].Vertexes[0].Point).toShape()]
return [Part.LineSegment(aVertex.Point,result[3].Vertexes[0].Point).toShape()]
else:
return lEdges
else:
@ -815,7 +815,7 @@ def sortEdgesOld(lEdges, aVertex=None):
else:
#print("inverting", result[3].Curve)
if geomType(result[3]) == "Line":
newedge = Part.Line(aVertex.Point,result[3].Vertexes[0].Point).toShape()
newedge = Part.LineSegment(aVertex.Point,result[3].Vertexes[0].Point).toShape()
olEdges += [newedge] + next
elif geomType(result[3]) == "Circle":
mp = findMidpoint(result[3])
@ -824,7 +824,7 @@ def sortEdgesOld(lEdges, aVertex=None):
elif geomType(result[3]) == "BSplineCurve" or \
geomType(result[3]) == "BezierCurve":
if isLine(result[3].Curve):
newedge = Part.Line(aVertex.Point,result[3].Vertexes[0].Point).toShape()
newedge = Part.LineSegment(aVertex.Point,result[3].Vertexes[0].Point).toShape()
olEdges += [newedge] + next
else:
olEdges += [result[3]] + next
@ -840,13 +840,13 @@ def invert(edge):
if len(edge.Vertexes) == 1:
return edge
if geomType(edge) == "Line":
return Part.Line(edge.Vertexes[-1].Point,edge.Vertexes[0].Point).toShape()
return Part.LineSegment(edge.Vertexes[-1].Point,edge.Vertexes[0].Point).toShape()
elif geomType(edge) == "Circle":
mp = findMidpoint(edge)
return Part.Arc(edge.Vertexes[-1].Point,mp,edge.Vertexes[0].Point).toShape()
elif geomType(edge) in ["BSplineCurve","BezierCurve"]:
if isLine(edge.Curve):
return Part.Line(edge.Vertexes[-1].Point,edge.Vertexes[0].Point).toShape()
return Part.LineSegment(edge.Vertexes[-1].Point,edge.Vertexes[0].Point).toShape()
print "DraftGeomUtils.invert: unable to invert ",edge.Curve
return edge
@ -970,7 +970,7 @@ def superWire(edgeslist,closed=False):
p2 = curr.Vertexes[-1].Point
if geomType(curr) == "Line":
print("line",p1,p2)
newedges.append(Part.Line(p1,p2).toShape())
newedges.append(Part.LineSegment(p1,p2).toShape())
elif geomType(curr) == "Circle":
p3 = findMidpoint(curr)
print("arc",p1,p3,p2)
@ -1055,7 +1055,7 @@ def offset(edge,vector,trim=False):
if geomType(edge) == "Line":
v1 = Vector.add(edge.Vertexes[0].Point, vector)
v2 = Vector.add(edge.Vertexes[-1].Point, vector)
return Part.Line(v1,v2).toShape()
return Part.LineSegment(v1,v2).toShape()
elif geomType(edge) == "Circle":
rad = edge.Vertexes[0].Point.sub(edge.Curve.Center)
curve = Part.Circle(edge.Curve)
@ -1170,8 +1170,8 @@ def offsetWire(wire,dvec,bind=False,occ=False):
nedges.append(nedge)
nedges = connect(nedges,closed)
if bind and not closed:
e1 = Part.Line(edges[0].Vertexes[0].Point,nedges[0].Vertexes[0].Point).toShape()
e2 = Part.Line(edges[-1].Vertexes[-1].Point,nedges[-1].Vertexes[-1].Point).toShape()
e1 = Part.LineSegment(edges[0].Vertexes[0].Point,nedges[0].Vertexes[0].Point).toShape()
e2 = Part.LineSegment(edges[-1].Vertexes[-1].Point,nedges[-1].Vertexes[-1].Point).toShape()
alledges = edges.extend(nedges)
alledges = alledges.extend([e1,e2])
w = Part.Wire(alledges)
@ -1218,7 +1218,7 @@ def connect(edges,closed=False):
v2 = curr.Vertexes[-1].Point
if geomType(curr) == "Line":
if v1 != v2:
nedges.append(Part.Line(v1,v2).toShape())
nedges.append(Part.LineSegment(v1,v2).toShape())
elif geomType(curr) == "Circle":
if v1 != v2:
nedges.append(Part.Arc(v1,findMidpoint(curr),v2).toShape())
@ -1314,12 +1314,12 @@ def angleBisection(edge1, edge2):
origin = int[0]
line1Dir.normalize()
dir = DraftVecUtils.rotate(line1Dir, ang)
return Part.Line(origin,origin.add(dir)).toShape()
return Part.LineSegment(origin,origin.add(dir)).toShape()
else:
diff = p3.sub(p1)
origin = p1.add(diff.multiply(0.5))
dir = p2.sub(p1); dir.normalize()
return Part.Line(origin,origin.add(dir)).toShape()
return Part.LineSegment(origin,origin.add(dir)).toShape()
else:
return None
@ -1428,8 +1428,8 @@ def bind(w1,w2):
return Part.Face([w2,w1])
else:
try:
w3 = Part.Line(w1.Vertexes[0].Point,w2.Vertexes[0].Point).toShape()
w4 = Part.Line(w1.Vertexes[-1].Point,w2.Vertexes[-1].Point).toShape()
w3 = Part.LineSegment(w1.Vertexes[0].Point,w2.Vertexes[0].Point).toShape()
w4 = Part.LineSegment(w1.Vertexes[-1].Point,w2.Vertexes[-1].Point).toShape()
return Part.Face(Part.Wire(w1.Edges+[w3]+w2.Edges+[w4]))
except:
print("DraftGeomUtils: unable to bind wires")
@ -1668,7 +1668,7 @@ def fillet(lEdges,r,chamfer=False):
'''Builds or completes a dictionnary containing edges with keys "Arc" and "Line"'''
if not existingCurveType :
existingCurveType = { 'Line' : [], 'Arc' : [] }
if issubclass(type(edge.Curve),Part.Line) :
if issubclass(type(edge.Curve),Part.LineSegment) :
existingCurveType['Line'] += [edge]
elif issubclass(type(edge.Curve),Part.Circle) :
existingCurveType['Arc'] += [edge]
@ -1724,7 +1724,7 @@ def fillet(lEdges,r,chamfer=False):
print("DraftGeomUtils.fillet : Error : radius value ", r," is too high")
return rndEdges
if chamfer:
rndEdges[1] = Part.Edge(Part.Line(arcPt1,arcPt3))
rndEdges[1] = Part.Edge(Part.LineSegment(arcPt1,arcPt3))
else:
rndEdges[1] = Part.Edge(Part.Arc(arcPt1,arcPt2,arcPt3))
@ -1732,11 +1732,11 @@ def fillet(lEdges,r,chamfer=False):
# fillet consumes entire first edge
rndEdges.pop(0)
else:
rndEdges[0] = Part.Edge(Part.Line(lVertexes[0].Point,arcPt1))
rndEdges[0] = Part.Edge(Part.LineSegment(lVertexes[0].Point,arcPt1))
if lVertexes[2].Point != arcPt3:
# fillet does not consume entire second edge
rndEdges += [Part.Edge(Part.Line(arcPt3,lVertexes[2].Point))]
rndEdges += [Part.Edge(Part.LineSegment(arcPt3,lVertexes[2].Point))]
return rndEdges
@ -1820,12 +1820,12 @@ def fillet(lEdges,r,chamfer=False):
arcAsEdge = arcFrom2Pts(V[-arcFirst],V[-myTrick],arcCenter,arcAxis)
V = [lineEnd.Point,arcPt1]
lineAsEdge = Part.Edge(Part.Line(V[-arcFirst],V[myTrick]))
lineAsEdge = Part.Edge(Part.LineSegment(V[-arcFirst],V[myTrick]))
rndEdges[not arcFirst] = arcAsEdge
rndEdges[arcFirst] = lineAsEdge
if chamfer:
rndEdges[1:1] = [Part.Edge(Part.Line(arcPt[- arcFirst],arcPt[- myTrick]))]
rndEdges[1:1] = [Part.Edge(Part.LineSegment(arcPt[- arcFirst],arcPt[- myTrick]))]
else:
rndEdges[1:1] = [Part.Edge(Part.Arc(arcPt[- arcFirst],arcPt[1],arcPt[- myTrick]))]
@ -1927,7 +1927,7 @@ def fillet(lEdges,r,chamfer=False):
rndEdges[0] = arcAsEdge[0]
rndEdges[1] = arcAsEdge[1]
if chamfer:
rndEdges[1:1] = [Part.Edge(Part.Line(arcPt[0],arcPt[2]))]
rndEdges[1:1] = [Part.Edge(Part.LineSegment(arcPt[0],arcPt[2]))]
else:
rndEdges[1:1] = [Part.Edge(Part.Arc(arcPt[0],arcPt[1],arcPt[2]))]
@ -2027,7 +2027,7 @@ def cleanProjection(shape,tessellate=True,seglength=.05):
newedges.append(Part.Wire(curvetowire(e,seglength)))
else:
if isLine(e.Curve):
l = Part.Line(e.Vertexes[0].Point,e.Vertexes[-1].Point).toShape()
l = Part.LineSegment(e.Vertexes[0].Point,e.Vertexes[-1].Point).toShape()
newedges.append(l)
else:
newedges.append(e.Curve.toShape(e.FirstParameter,e.LastParameter))
@ -2231,7 +2231,7 @@ def circleFrom2LinesRadius (edge1, edge2, radius):
if not int: return None
int = int[0]
bis12 = angleBisection(edge1,edge2)
bis21 = Part.Line(bis12.Vertexes[0].Point,DraftVecUtils.rotate(vec(bis12), math.pi/2.0))
bis21 = Part.LineSegment(bis12.Vertexes[0].Point,DraftVecUtils.rotate(vec(bis12), math.pi/2.0))
ang12 = abs(DraftVecUtils.angle(vec(edge1),vec(edge2)))
ang21 = math.pi - ang12
dist12 = radius / math.sin(ang12 * 0.5)
@ -2250,7 +2250,7 @@ def circleFrom2LinesRadius (edge1, edge2, radius):
def circleFrom3LineTangents (edge1, edge2, edge3):
"circleFrom3LineTangents(edge,edge,edge)"
def rot(ed):
return Part.Line(v1(ed),v1(ed).add(DraftVecUtils.rotate(vec(ed),math.pi/2))).toShape()
return Part.LineSegment(v1(ed),v1(ed).add(DraftVecUtils.rotate(vec(ed),math.pi/2))).toShape()
bis12 = angleBisection(edge1,edge2)
bis23 = angleBisection(edge2,edge3)
bis31 = angleBisection(edge3,edge1)
@ -2343,7 +2343,7 @@ def circleFrom2PointsRadius(p1, p2, radius):
"circleFrom2PointsRadiust(Vector, Vector, radius)"
if DraftVecUtils.equals(p1, p2): return None
p1_p2 = Part.Line(p1, p2).toShape()
p1_p2 = Part.LineSegment(p1, p2).toShape()
dist_p1p2 = DraftVecUtils.dist(p1, p1)
mid = findMidpoint(p1_p2)
if dist_p1p2 == 2*radius:
@ -2592,7 +2592,7 @@ def findHomotheticCenterOfCircles(circle1, circle2):
if DraftVecUtils.equals(circle1.Curve.Center, circle2.Curve.Center):
return None
cen1_cen2 = Part.Line(circle1.Curve.Center, circle2.Curve.Center).toShape()
cen1_cen2 = Part.LineSegment(circle1.Curve.Center, circle2.Curve.Center).toShape()
cenDir = vec(cen1_cen2); cenDir.normalize()
# Get the perpedicular vector.
@ -2667,7 +2667,7 @@ def findRadicalAxis(circle1, circle2):
# K_ .. A point somewhere between K and J (actually with a distance of 1 unit from K).
K_ = Vector,add(K, perpCenDir)
radicalAxis = Part.Line(K, Vector.add(origin, dir))
radicalAxis = Part.LineSegment(K, Vector.add(origin, dir))
if radicalAxis:
return radicalAxis

View File

@ -479,7 +479,7 @@ class Snapper:
self.extLine.p2(np)
self.extLine.on()
self.setCursor('extension')
ne = Part.Line(p0,np).toShape()
ne = Part.LineSegment(p0,np).toShape()
# storing extension line for intersection calculations later
if len(self.lastExtensions) == 0:
self.lastExtensions.append(ne)
@ -498,7 +498,7 @@ class Snapper:
if last:
ve = DraftGeomUtils.vec(e)
if not DraftVecUtils.isNull(ve):
de = Part.Line(last,last.add(ve)).toShape()
de = Part.LineSegment(last,last.add(ve)).toShape()
np = self.getPerpendicular(de,point)
if (np.sub(point)).Length < self.radius:
if self.tracker and not self.selectMode:
@ -564,7 +564,7 @@ class Snapper:
for v in vecs:
if not DraftVecUtils.isNull(v):
try:
de = Part.Line(last,last.add(v)).toShape()
de = Part.LineSegment(last,last.add(v)).toShape()
except Part.OCCError:
return point,None
np = self.getPerpendicular(de,point)
@ -655,7 +655,7 @@ class Snapper:
if last:
if DraftGeomUtils.geomType(shape) == "Line":
if self.constraintAxis:
tmpEdge = Part.Line(last,last.add(self.constraintAxis)).toShape()
tmpEdge = Part.LineSegment(last,last.add(self.constraintAxis)).toShape()
# get the intersection points
pt = DraftGeomUtils.findIntersection(tmpEdge,shape,True,True)
if pt:
@ -667,15 +667,15 @@ class Snapper:
"returns an ortho X extension snap location"
if self.isEnabled("extension") and self.isEnabled("ortho"):
if constrain and last and self.constraintAxis and self.extLine:
tmpEdge1 = Part.Line(last,last.add(self.constraintAxis)).toShape()
tmpEdge2 = Part.Line(self.extLine.p1(),self.extLine.p2()).toShape()
tmpEdge1 = Part.LineSegment(last,last.add(self.constraintAxis)).toShape()
tmpEdge2 = Part.LineSegment(self.extLine.p1(),self.extLine.p2()).toShape()
# get the intersection points
pt = DraftGeomUtils.findIntersection(tmpEdge1,tmpEdge2,True,True)
if pt:
return [pt[0],'ortho',pt[0]]
if eline:
try:
tmpEdge2 = Part.Line(self.extLine.p1(),self.extLine.p2()).toShape()
tmpEdge2 = Part.LineSegment(self.extLine.p1(),self.extLine.p2()).toShape()
# get the intersection points
pt = DraftGeomUtils.findIntersection(eline,tmpEdge2,True,True)
if pt:
@ -689,7 +689,7 @@ class Snapper:
if self.isEnabled("extension") and self.isEnabled("perpendicular"):
if last and self.extLine:
if self.extLine.p1() != self.extLine.p2():
tmpEdge = Part.Line(self.extLine.p1(),self.extLine.p2()).toShape()
tmpEdge = Part.LineSegment(self.extLine.p1(),self.extLine.p2()).toShape()
np = self.getPerpendicular(tmpEdge,last)
return [np,'perpendicular',np]
return None

View File

@ -536,7 +536,7 @@ class Line(Creator):
self.planetrack.set(self.node[0])
elif (len(self.node) == 2):
last = self.node[len(self.node)-2]
newseg = Part.Line(last,point).toShape()
newseg = Part.LineSegment(last,point).toShape()
self.obj.Shape = newseg
self.obj.ViewObject.Visibility = True
if self.isWire:
@ -545,7 +545,7 @@ class Line(Creator):
currentshape = self.obj.Shape.copy()
last = self.node[len(self.node)-2]
if not DraftVecUtils.equals(last,point):
newseg = Part.Line(last,point).toShape()
newseg = Part.LineSegment(last,point).toShape()
newshape=currentshape.fuse(newseg)
self.obj.Shape = newshape
msg(translate("draft", "Pick next point, or Finish (shift-F) or close (o):\n"))
@ -2933,7 +2933,7 @@ class Trimex(Modifier):
ray = self.newpoint.sub(v1)
ray.multiply(self.force/ray.Length)
self.newpoint = Vector.add(v1,ray)
newedges.append(Part.Line(self.newpoint,v2).toShape())
newedges.append(Part.LineSegment(self.newpoint,v2).toShape())
else:
center = edge.Curve.Center
rad = edge.Curve.Radius

View File

@ -279,7 +279,7 @@ class dimTracker(Tracker):
if DraftVecUtils.equals(p1,p4):
proj = None
else:
base = Part.Line(p1,p4).toShape()
base = Part.LineSegment(p1,p4).toShape()
proj = DraftGeomUtils.findDistance(self.p3,base)
if not proj:
p2 = p1

View File

@ -391,7 +391,7 @@ def drawLine(line,forceShape=False):
if (dxfCreateDraft or dxfCreateSketch) and (not forceShape):
return Draft.makeWire([v1,v2])
else:
return Part.Line(v1,v2).toShape()
return Part.LineSegment(v1,v2).toShape()
except Part.OCCError:
warn(line)
return None
@ -413,13 +413,13 @@ def drawPolyline(polyline,forceShape=False,num=None):
curves = True
cv = calcBulge(v1,polyline.points[p].bulge,v2)
if DraftVecUtils.isColinear([v1,cv,v2]):
try: edges.append(Part.Line(v1,v2).toShape())
try: edges.append(Part.LineSegment(v1,v2).toShape())
except Part.OCCError: warn(polyline,num)
else:
try: edges.append(Part.Arc(v1,cv,v2).toShape())
except Part.OCCError: warn(polyline,num)
else:
try: edges.append(Part.Line(v1,v2).toShape())
try: edges.append(Part.LineSegment(v1,v2).toShape())
except Part.OCCError: warn(polyline,num)
verts.append(v2)
if polyline.closed:
@ -431,7 +431,7 @@ def drawPolyline(polyline,forceShape=False,num=None):
if not DraftVecUtils.equals(v1,v2):
if DraftVecUtils.isColinear([v1,cv,v2]):
try:
edges.append(Part.Line(v1,v2).toShape())
edges.append(Part.LineSegment(v1,v2).toShape())
except Part.OCCError:
warn(polyline,num)
else:
@ -1886,7 +1886,7 @@ def export(objectslist,filename,nospline=False,lwPoly=False):
elif Draft.getType(ob) == "Dimension":
p1 = DraftVecUtils.tup(ob.Start)
p2 = DraftVecUtils.tup(ob.End)
base = Part.Line(ob.Start,ob.End).toShape()
base = Part.LineSegment(ob.Start,ob.End).toShape()
proj = DraftGeomUtils.findDistance(ob.Dimline,base)
if not proj:
pbase = DraftVecUtils.tup(ob.End)

View File

@ -142,7 +142,7 @@ def getline(data):
verts.append(getpoint(data[p:p+4]))
elif (data[p][0] == "P"):
verts.append(getpoint([data[p]]))
l = Part.Line(verts[0],verts[1])
l = Part.LineSegment(verts[0],verts[1])
return l.toShape()
def gettranslation(data):

View File

@ -603,7 +603,7 @@ class svgHandler(xml.sax.ContentHandler):
else:
currentvec = Vector(x,-y,0)
if not DraftVecUtils.equals(lastvec,currentvec):
seg = Part.Line(lastvec,currentvec).toShape()
seg = Part.LineSegment(lastvec,currentvec).toShape()
FreeCAD.Console.PrintMessage("line %s %s\n" %(lastvec,currentvec))
lastvec = currentvec
path.append(seg)
@ -614,7 +614,7 @@ class svgHandler(xml.sax.ContentHandler):
currentvec = lastvec.add(Vector(x,0,0))
else:
currentvec = Vector(x,lastvec.y,0)
seg = Part.Line(lastvec,currentvec).toShape()
seg = Part.LineSegment(lastvec,currentvec).toShape()
lastvec = currentvec
lastpole = None
path.append(seg)
@ -624,7 +624,7 @@ class svgHandler(xml.sax.ContentHandler):
currentvec = lastvec.add(Vector(0,-y,0))
else:
currentvec = Vector(lastvec.x,-y,0)
seg = Part.Line(lastvec,currentvec).toShape()
seg = Part.LineSegment(lastvec,currentvec).toShape()
lastvec = currentvec
lastpole = None
path.append(seg)
@ -692,7 +692,7 @@ class svgHandler(xml.sax.ContentHandler):
seg.reverse()
#obj = self.doc.addObject("Part::Feature",'DEBUG %s'%pathname) #DEBUG
#obj.Shape = seg #DEBUG
#seg = Part.Line(lastvec,currentvec).toShape() #DEBUG
#seg = Part.LineSegment(lastvec,currentvec).toShape() #DEBUG
lastvec = currentvec
lastpole = None
path.append(seg)
@ -730,7 +730,7 @@ class svgHandler(xml.sax.ContentHandler):
pole1.distanceToLine(lastvec,currentvec) < 10**(-1*(2+Draft.precision())) and \
pole2.distanceToLine(lastvec,currentvec) < 10**(-1*(2+Draft.precision())):
#print "straight segment"
seg = Part.Line(lastvec,currentvec).toShape()
seg = Part.LineSegment(lastvec,currentvec).toShape()
else:
#print "cubic bezier segment"
b = Part.BezierCurve()
@ -767,7 +767,7 @@ class svgHandler(xml.sax.ContentHandler):
if True and \
pole.distanceToLine(lastvec,currentvec) < 20**(-1*(2+Draft.precision())):
#print "straight segment"
seg = Part.Line(lastvec,currentvec).toShape()
seg = Part.LineSegment(lastvec,currentvec).toShape()
else:
#print "quadratic bezier segment"
b = Part.BezierCurve()
@ -780,7 +780,7 @@ class svgHandler(xml.sax.ContentHandler):
elif (d == "Z") or (d == "z"):
if not DraftVecUtils.equals(lastvec,firstvec):
try:
seg = Part.Line(lastvec,firstvec).toShape()
seg = Part.LineSegment(lastvec,firstvec).toShape()
except Part.OCCError:
pass
else:
@ -829,10 +829,10 @@ class svgHandler(xml.sax.ContentHandler):
p2 = Vector(data['x']+data['width'],-data['y'],0)
p3 = Vector(data['x']+data['width'],-data['y']-data['height'],0)
p4 = Vector(data['x'],-data['y']-data['height'],0)
edges.append(Part.Line(p1,p2).toShape())
edges.append(Part.Line(p2,p3).toShape())
edges.append(Part.Line(p3,p4).toShape())
edges.append(Part.Line(p4,p1).toShape())
edges.append(Part.LineSegment(p1,p2).toShape())
edges.append(Part.LineSegment(p2,p3).toShape())
edges.append(Part.LineSegment(p3,p4).toShape())
edges.append(Part.LineSegment(p4,p1).toShape())
else: #rounded edges
#ToTo: check for ry>rx !!!!
rx = data.get('rx')
@ -880,7 +880,7 @@ class svgHandler(xml.sax.ContentHandler):
for esh1,esh2 in zip(esh[-1:]+esh[:-1],esh):
p1,p2 = esh1.Vertexes[-1].Point,esh2.Vertexes[0].Point
if not DraftVecUtils.equals(p1,p2):
edges.append(Part.Line(esh1.Vertexes[-1].Point,esh2.Vertexes[0].Point).toShape()) #straight segments
edges.append(Part.LineSegment(esh1.Vertexes[-1].Point,esh2.Vertexes[0].Point).toShape()) #straight segments
edges.append(esh2) # elliptical segments
sh = Part.Wire(edges)
if self.fill: sh = Part.Face(sh)
@ -897,7 +897,7 @@ class svgHandler(xml.sax.ContentHandler):
if not pathname: pathname = 'Line'
p1 = Vector(data['x1'],-data['y1'],0)
p2 = Vector(data['x2'],-data['y2'],0)
sh = Part.Line(p1,p2).toShape()
sh = Part.LineSegment(p1,p2).toShape()
sh = self.applyTrans(sh)
obj = self.doc.addObject("Part::Feature",pathname)
obj.Shape = sh
@ -922,7 +922,7 @@ class svgHandler(xml.sax.ContentHandler):
for svgx,svgy in zip(points[2::2],points[3::2]):
currentvec = Vector(svgx,-svgy,0)
if not DraftVecUtils.equals(lastvec,currentvec):
seg = Part.Line(lastvec,currentvec).toShape()
seg = Part.LineSegment(lastvec,currentvec).toShape()
#print "polyline seg ",lastvec,currentvec
lastvec = currentvec
path.append(seg)

View File

@ -153,7 +153,7 @@ def Process_board_outline(doc,board_outline,drills,board_thickness):
out_shape.append(Part.Arc(per_point,mid_point(per_point,vertex,point[3]/2),vertex))
out_shape.append(Part.Arc(per_point,mid_point(per_point,vertex,-point[3]/2),vertex))
else:
out_shape.append(Part.Line(prev_vertex,vertex))
out_shape.append(Part.LineSegment(prev_vertex,vertex))
else:
out_shape=Part.Shape(out_shape)
out_shape=Part.Wire(out_shape.Edges)
@ -316,7 +316,7 @@ def Process_comp_outline(doc,comp_outline,comp_height):
out_shape.append(Part.Arc(per_point,mid_point(per_point,vertex,point[2]/2),vertex))
out_shape.append(Part.Arc(per_point,mid_point(per_point,vertex,-point[2]/2),vertex))
else:
out_shape.append(Part.Line(prev_vertex,vertex))
out_shape.append(Part.LineSegment(prev_vertex,vertex))
prev_vertex=vertex
out_shape=Part.Shape(out_shape)
out_shape=Part.Wire(out_shape.Edges)

View File

@ -385,7 +385,7 @@ def edgestofaces(edges,algo=3,eps=0.001):
p1 = w.Vertexes[-1].Point
edges2 = w.Edges[:]
try:
edges2.append(Part.Line(p1,p0).toShape())
edges2.append(Part.LineSegment(p1,p0).toShape())
w = Part.Wire(edges2)
#w = Part.Wire(fcgeo.sortEdges(edges2))
except OCCError:
@ -461,9 +461,9 @@ def superWireReverse(debuglist,closed=False):
nexte[0].Vertexes[-1*(not nexte[1])].Point)
else:
p2 = curr[0].Vertexes[-1*(curr[1])].Point
if isinstance(curr[0].Curve,Part.Line):
if isinstance(curr[0].Curve,Part.LineSegment):
print "line",p1,p2
newedges.append(Part.Line(p1,p2).toShape())
newedges.append(Part.LineSegment(p1,p2).toShape())
elif isinstance(curr[0].Curve,Part.Circle):
p3 = findMidpoint(curr[0])
print "arc",p1,p3,p2

View File

@ -17,8 +17,8 @@ def makeBottle(myWidth=50.0, myHeight=70.0, myThickness=30.0):
aPnt5=Base.Vector(myWidth/2.,0,0)
aArcOfCircle = Part.Arc(aPnt2,aPnt3,aPnt4)
aSegment1=Part.Line(aPnt1,aPnt2)
aSegment2=Part.Line(aPnt4,aPnt5)
aSegment1=Part.LineSegment(aPnt1,aPnt2)
aSegment2=Part.LineSegment(aPnt4,aPnt5)
aEdge1=aSegment1.toShape()
aEdge2=aArcOfCircle.toShape()
@ -82,9 +82,9 @@ def makeBoreHole():
# and the second one
VC2 = Base.Vector(40,0,0)
C2 = Part.Arc(V2,VC2,V3)
L1 = Part.Line(V1,V2)
L1 = Part.LineSegment(V1,V2)
# and the second one
L2 = Part.Line(V4,V3)
L2 = Part.LineSegment(V4,V3)
S1 = Part.Shape([C1,C2,L1,L2])
W=Part.Wire(S1.Edges)

View File

@ -33,10 +33,10 @@ import FreeCAD, FreeCADGui, os, sys, unittest, Part, PartGui
#
# def testBoxCase(self):
# self.Box = self.Doc.addObject('Part::SketchObject','SketchBox')
# self.Box.addGeometry(Part.Line(App.Vector(-99.230339,36.960674,0),App.Vector(69.432587,36.960674,0)))
# self.Box.addGeometry(Part.Line(App.Vector(69.432587,36.960674,0),App.Vector(69.432587,-53.196629,0)))
# self.Box.addGeometry(Part.Line(App.Vector(69.432587,-53.196629,0),App.Vector(-99.230339,-53.196629,0)))
# self.Box.addGeometry(Part.Line(App.Vector(-99.230339,-53.196629,0),App.Vector(-99.230339,36.960674,0)))
# self.Box.addGeometry(Part.LineSegment(App.Vector(-99.230339,36.960674,0),App.Vector(69.432587,36.960674,0)))
# self.Box.addGeometry(Part.LineSegment(App.Vector(69.432587,36.960674,0),App.Vector(69.432587,-53.196629,0)))
# self.Box.addGeometry(Part.LineSegment(App.Vector(69.432587,-53.196629,0),App.Vector(-99.230339,-53.196629,0)))
# self.Box.addGeometry(Part.LineSegment(App.Vector(-99.230339,-53.196629,0),App.Vector(-99.230339,36.960674,0)))
#
# def tearDown(self):
# #closing doc

View File

@ -133,7 +133,7 @@ class Hole():
wire = face.OuterWire
firstLine = None
for e in wire.Edges:
if type(e.Curve) == Part.Line:
if type(e.Curve) == Part.LineSegment:
if firstLine == None:
firstLine = e
firstDirection = e.Curve.EndPoint - e.Curve.StartPoint
@ -145,7 +145,7 @@ class Hole():
secondLineIndex = -1
for i in range(len(allEdges)):
try:
if type(allEdges[i].Curve) != Part.Line:
if type(allEdges[i].Curve) != Part.LineSegment:
continue
if (allEdges[i].Curve.StartPoint == firstLine.Curve.StartPoint and allEdges[i].Curve.EndPoint == firstLine.Curve.EndPoint) or (allEdges[i].Curve.EndPoint == firstLine.Curve.StartPoint and allEdges[i].Curve.StartPoint == firstLine.Curve.EndPoint):
firstLineIndex = i
@ -162,8 +162,8 @@ class Hole():
self.feature.PositionType = "Linear"
# Place the axis approximately in the center of the face
#p = face.CenterOfMass
#l1 = Part.Line(firstLine.Curve)
#l2 = Part.Line(e.Curve)
#l1 = Part.LineSegment(firstLine.Curve)
#l2 = Part.LineSegment(e.Curve)
#axis.Offset = p.distanceToLine(l1.StartPoint, l1.EndPoint - l1.StartPoint)
#axis.Offset2 = p.distanceToLine(l1.StartPoint, l2.EndPoint - l2.StartPoint)
# TODO: Ensure that the hole is inside the face!
@ -301,25 +301,25 @@ class Hole():
# Geo -1 is the X-axis
# Geo -2 is the Y-axis
# First external geometry is -3
sketch.addExternal(axis.Name,"Line") # Geo -3: Datum axis
sketch.addExternal(axis.Name,"LineSegment") # Geo -3: Datum axis
sketch.addExternal(support.Name, elements[0]) # Geo -4: Support face
# Note: Creating the sketch first with depth = 100.0 and then changing the constraint later seems to be more stable
tempDepth = 100.0
# Build the sketch
sketch.addGeometry(Part.Line(self.App.Vector(10.0,50.0,0),self.App.Vector(10.0,-50.0,0))) # Geo0: Rotation axis
sketch.addGeometry(Part.LineSegment(self.App.Vector(10.0,50.0,0),self.App.Vector(10.0,-50.0,0))) # Geo0: Rotation axis
sketch.toggleConstruction(0)
sketch.addGeometry(Part.Line(self.App.Vector(10.0,-10.0,0),self.App.Vector(10.0,-30.0,0))) # Geo1: Vertical axis of hole
sketch.addGeometry(Part.LineSegment(self.App.Vector(10.0,-10.0,0),self.App.Vector(10.0,-30.0,0))) # Geo1: Vertical axis of hole
sketch.addConstraint(Sketcher.Constraint('PointOnObject',1,1,0))# Datum0
sketch.addConstraint(Sketcher.Constraint('PointOnObject',1,2,0))# Datum1
sketch.addGeometry(Part.Line(self.App.Vector(10.0,-10.0,0),self.App.Vector(20.0,-10.0,0))) # Geo2: Top of hole
sketch.addGeometry(Part.LineSegment(self.App.Vector(10.0,-10.0,0),self.App.Vector(20.0,-10.0,0))) # Geo2: Top of hole
sketch.addConstraint(Sketcher.Constraint('Coincident',1,1,2,1)) # Datum2
sketch.addConstraint(Sketcher.Constraint('Perpendicular',2, 1)) # Datum3
sketch.addGeometry(Part.Line(self.App.Vector(20.0,-10.0,0),self.App.Vector(20.0,-25.0,0))) # Geo3: Vertical mantle of hole
sketch.addGeometry(Part.LineSegment(self.App.Vector(20.0,-10.0,0),self.App.Vector(20.0,-25.0,0))) # Geo3: Vertical mantle of hole
sketch.addConstraint(Sketcher.Constraint('Coincident',2,2,3,1)) # temporary
sketch.addConstraint(Sketcher.Constraint('Parallel',3, 1)) # Datum4
sketch.addConstraint(Sketcher.Constraint('Distance',3,2,1, 10.0)) # Datum5: Radius
sketch.addConstraint(Sketcher.Constraint('Distance',3,2,2, 15.0)) # Datum6: Depth
sketch.addGeometry(Part.Line(self.App.Vector(10.0,-30.0,0),self.App.Vector(20.0,-25.0,0))) # Geo4: 118 degree tip angle
sketch.addGeometry(Part.LineSegment(self.App.Vector(10.0,-30.0,0),self.App.Vector(20.0,-25.0,0))) # Geo4: 118 degree tip angle
sketch.addConstraint(Sketcher.Constraint('Coincident',4,1,1,2)) # Datum7
sketch.addConstraint(Sketcher.Constraint('Coincident',4,2,3,2)) # Datum8
# TODO: The tip angle of 118 degrees is for steel only. It should be taken from Part material data
@ -422,12 +422,12 @@ class Hole():
sketch.delConstraint(13)
sketch.addConstraint(Sketcher.Constraint('Distance',2, cradius)) # Datum13
p2 = sketch.Geometry[2].EndPoint
sketch.addGeometry(Part.Line(p2,self.App.Vector(p2.x,p2.y-20.0,0))) # Geo5: Vertical mantle of counterbore
sketch.addGeometry(Part.LineSegment(p2,self.App.Vector(p2.x,p2.y-20.0,0))) # Geo5: Vertical mantle of counterbore
sketch.addConstraint(Sketcher.Constraint('Coincident',2,2,5,1)) # Datum14
sketch.addConstraint(Sketcher.Constraint('Distance',3, 1, 2, cdepth)) # Datum15
sketch.addConstraint(Sketcher.Constraint('Parallel',5, 1)) # Datum16
p3 = sketch.Geometry[3].StartPoint
sketch.addGeometry(Part.Line(self.App.Vector(p2.x,p2.y-20.0, 0),p3)) # Geo6: bottom of counterbore
sketch.addGeometry(Part.LineSegment(self.App.Vector(p2.x,p2.y-20.0, 0),p3)) # Geo6: bottom of counterbore
sketch.addConstraint(Sketcher.Constraint('Coincident',5,2,6,1)) # Datum17
sketch.addConstraint(Sketcher.Constraint('Perpendicular',6, -3)) # Datum18
sketch.addConstraint(Sketcher.Constraint('Coincident',6,2,3,1)) # Datum19
@ -473,7 +473,7 @@ class Hole():
sketch.delConstraint(13)
sketch.addConstraint(Sketcher.Constraint('Distance',2, sradius)) # Datum13
p2 = sketch.Geometry[2].EndPoint
sketch.addGeometry(Part.Line(p2,self.App.Vector(p2.x,p2.y-20.0,0))) # Geo5: Chamfer of countersink
sketch.addGeometry(Part.LineSegment(p2,self.App.Vector(p2.x,p2.y-20.0,0))) # Geo5: Chamfer of countersink
sketch.addConstraint(Sketcher.Constraint('Coincident',2,2,5,1)) # Datum14
sketch.addConstraint(Sketcher.Constraint('Angle',5,2, 1,2, sangle)) # Datum15
sketch.addConstraint(Sketcher.Constraint('Coincident',3,1,5,2)) # Datum16

View File

@ -540,7 +540,7 @@ class TaskHole:
self.feature.Support = (feature, [element])
elif self.selectionMode == "LinearReference":
if shape.ShapeType == "Edge":
if shape.Curve.__class__ != Part.Line:
if shape.Curve.__class__ != Part.LineSegment:
FreeCAD.Console.PrintMessage("Selected edge must be linear\n")
return
if len(refs) > 1:
@ -565,7 +565,7 @@ class TaskHole:
axis.Document.recompute()
elif self.selectionMode == "LinearReference2":
if shape.ShapeType == "Edge":
if shape.Curve.__class__ != Part.Line:
if shape.Curve.__class__ != Part.LineSegment:
FreeCAD.Console.PrintMessage("Selected edge must be linear\n")
return
if len(refs) > 2:

View File

@ -86,10 +86,10 @@ class PartDesignGuiTestCases(unittest.TestCase):
self.BodySource.addFeature(self.Sketch)
geoList = []
geoList.append(Part.Line(App.Vector(2.0,8.0,0),App.Vector(8.0,8.0,0)))
geoList.append(Part.Line(App.Vector(8.0,8.0,0),App.Vector(8.0,2.0,0)))
geoList.append(Part.Line(App.Vector(8.0,2.0,0),App.Vector(2.0,2.0,0)))
geoList.append(Part.Line(App.Vector(2.0,2.0,0),App.Vector(2.0,8.0,0)))
geoList.append(Part.LineSegment(App.Vector(2.0,8.0,0),App.Vector(8.0,8.0,0)))
geoList.append(Part.LineSegment(App.Vector(8.0,8.0,0),App.Vector(8.0,2.0,0)))
geoList.append(Part.LineSegment(App.Vector(8.0,2.0,0),App.Vector(2.0,2.0,0)))
geoList.append(Part.LineSegment(App.Vector(2.0,2.0,0),App.Vector(2.0,8.0,0)))
self.Sketch.addGeometry(geoList,False)
conList = []
conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
@ -138,10 +138,10 @@ class PartDesignGuiTestCases(unittest.TestCase):
self.BodySource.addFeature(self.Sketch)
geoList = []
geoList.append(Part.Line(App.Vector(-10.000000,10.000000,0),App.Vector(10.000000,10.000000,0)))
geoList.append(Part.Line(App.Vector(10.000000,10.000000,0),App.Vector(10.000000,-10.000000,0)))
geoList.append(Part.Line(App.Vector(10.000000,-10.000000,0),App.Vector(-10.000000,-10.000000,0)))
geoList.append(Part.Line(App.Vector(-10.000000,-10.000000,0),App.Vector(-10.000000,10.000000,0)))
geoList.append(Part.LineSegment(App.Vector(-10.000000,10.000000,0),App.Vector(10.000000,10.000000,0)))
geoList.append(Part.LineSegment(App.Vector(10.000000,10.000000,0),App.Vector(10.000000,-10.000000,0)))
geoList.append(Part.LineSegment(App.Vector(10.000000,-10.000000,0),App.Vector(-10.000000,-10.000000,0)))
geoList.append(Part.LineSegment(App.Vector(-10.000000,-10.000000,0),App.Vector(-10.000000,10.000000,0)))
self.Sketch.addGeometry(geoList,False)
conList = []
conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
@ -192,10 +192,10 @@ class PartDesignGuiTestCases(unittest.TestCase):
#
# def testBoxCase(self):
# self.Box = self.Doc.addObject('PartDesign::SketchObject','SketchBox')
# self.Box.addGeometry(Part.Line(App.Vector(-99.230339,36.960674,0),App.Vector(69.432587,36.960674,0)))
# self.Box.addGeometry(Part.Line(App.Vector(69.432587,36.960674,0),App.Vector(69.432587,-53.196629,0)))
# self.Box.addGeometry(Part.Line(App.Vector(69.432587,-53.196629,0),App.Vector(-99.230339,-53.196629,0)))
# self.Box.addGeometry(Part.Line(App.Vector(-99.230339,-53.196629,0),App.Vector(-99.230339,36.960674,0)))
# self.Box.addGeometry(Part.LineSegment(App.Vector(-99.230339,36.960674,0),App.Vector(69.432587,36.960674,0)))
# self.Box.addGeometry(Part.LineSegment(App.Vector(69.432587,36.960674,0),App.Vector(69.432587,-53.196629,0)))
# self.Box.addGeometry(Part.LineSegment(App.Vector(69.432587,-53.196629,0),App.Vector(-99.230339,-53.196629,0)))
# self.Box.addGeometry(Part.LineSegment(App.Vector(-99.230339,-53.196629,0),App.Vector(-99.230339,36.960674,0)))
#
# def tearDown(self):
# #closing doc

View File

@ -70,17 +70,17 @@ class ShaftFeature:
if oldLength == 0:
# First segment of shaft
# Create centerline
self.sketch.addGeometry(Part.Line(self.App.Vector(0,0,0), self.App.Vector(self.totalLength,0,0)))
self.sketch.addGeometry(Part.LineSegment(self.App.Vector(0,0,0), self.App.Vector(self.totalLength,0,0)))
self.sketch.addConstraint(Sketcher.Constraint('DistanceX',0, self.totalLength)) # Constraint1
self.sketch.addConstraint(Sketcher.Constraint('DistanceY', -1,1,0,1,innerradius)) # Constraint2
self.sketch.addConstraint(Sketcher.Constraint('PointOnObject',0,1,-2)) # Constraint3
self.sketch.addConstraint(Sketcher.Constraint('Horizontal', 0)) # Constraint4
# Create first segment
self.sketch.addGeometry(Part.Line(self.App.Vector(0,innerradius,0), self.App.Vector(0,radius,0)))
self.sketch.addGeometry(Part.LineSegment(self.App.Vector(0,innerradius,0), self.App.Vector(0,radius,0)))
self.sketch.addConstraint(Sketcher.Constraint('DistanceY',-1,1,1,2,radius)) # Constraint5
self.sketch.addConstraint(Sketcher.Constraint('Coincident',0,1,1,1)) # Constraint6
self.sketch.addConstraint(Sketcher.Constraint('Vertical',1)) # Constraint7
self.sketch.addGeometry(Part.Line(self.App.Vector(0,radius,0), self.App.Vector(length,radius,0)))
self.sketch.addGeometry(Part.LineSegment(self.App.Vector(0,radius,0), self.App.Vector(length,radius,0)))
self.sketch.addConstraint(Sketcher.Constraint('DistanceX',2,length)) # Constraint8
self.sketch.addConstraint(Sketcher.Constraint('Coincident',2,1,1,2)) # Constraint9
self.sketch.addConstraint(Sketcher.Constraint('Horizontal',2)) # Constraint10
@ -91,17 +91,17 @@ class ShaftFeature:
# Adjust length of centerline
self.sketch.setDatum(0,self.totalLength)
# Add segment at the end
self.sketch.addGeometry(Part.Line(self.App.Vector(oldLength,self.lastRadius,0), self.App.Vector(oldLength,radius,0)))
self.sketch.addGeometry(Part.LineSegment(self.App.Vector(oldLength,self.lastRadius,0), self.App.Vector(oldLength,radius,0)))
self.sketch.addConstraint(Sketcher.Constraint('DistanceY', -1,1, segRadius, 2, radius))
self.sketch.addConstraint(Sketcher.Constraint('Coincident',segRadius,1,prevSegLength,2))
self.sketch.addConstraint(Sketcher.Constraint('Vertical',segRadius))
self.sketch.addGeometry(Part.Line(self.App.Vector(oldLength,radius,0), self.App.Vector(oldLength+length,radius,0)))
self.sketch.addGeometry(Part.LineSegment(self.App.Vector(oldLength,radius,0), self.App.Vector(oldLength+length,radius,0)))
self.sketch.addConstraint(Sketcher.Constraint('DistanceX',segLength,length))
self.sketch.addConstraint(Sketcher.Constraint('Coincident',segLength,1,segRadius,2))
self.sketch.addConstraint(Sketcher.Constraint('Horizontal',segLength))
# close the sketch
self.sketch.addGeometry(Part.Line(self.App.Vector(oldLength+length,radius,0), self.App.Vector(oldLength+length,innerradius,0)))
self.sketch.addGeometry(Part.LineSegment(self.App.Vector(oldLength+length,radius,0), self.App.Vector(oldLength+length,innerradius,0)))
self.sketch.addConstraint(Sketcher.Constraint('Coincident',0,2,segEnd,2))
self.sketch.addConstraint(Sketcher.Constraint('Coincident',segEnd,1,segLength,2))
self.lastRadius = radius

View File

@ -51,7 +51,7 @@ class FCWireBuilder(object):
"""Add a segment between self.pos and p"""
p = rotate(p, self.theta)
end = Base.Vector(*p)
self.wire.append(Part.Line(self.pos, end))
self.wire.append(Part.LineSegment(self.pos, end))
self.pos = end
def arc(self, p, r, sweep):

View File

@ -112,7 +112,7 @@ def edgesForCommands(cmds, startPt):
if cmd.Name in movecommands:
pt = pointFromCommand(cmd, lastPt)
if cmd.Name in movestraight:
edges.append(Part.Edge(Part.Line(lastPt, pt)))
edges.append(Part.Edge(Part.LineSegment(lastPt, pt)))
elif cmd.Name in movearc:
center = lastPt + pointFromCommand(cmd, FreeCAD.Vector(0,0,0), 'I', 'J', 'K')
A = lastPt - center
@ -210,7 +210,7 @@ class Chord (object):
return self.End - self.Start
def asLine(self):
return Part.Line(self.Start, self.End)
return Part.LineSegment(self.Start, self.End)
def asEdge(self):
return Part.Edge(self.asLine())
@ -434,7 +434,7 @@ class ObjectDressup:
debugPrint("smooth: (%.2f, %.2f)-(%.2f, %.2f)" % (edge.Vertexes[0].Point.x, edge.Vertexes[0].Point.y, edge.Vertexes[1].Point.x, edge.Vertexes[1].Point.y))
for e in wire.Edges:
self.dbg.append(e)
if type(e.Curve) == Part.Line:
if type(e.Curve) == Part.LineSegment:
debugPrint(" (%.2f, %.2f)-(%.2f, %.2f)" % (e.Vertexes[0].Point.x, e.Vertexes[0].Point.y, e.Vertexes[1].Point.x, e.Vertexes[1].Point.y))
else:
debugPrint(" (%.2f, %.2f)^%.2f" % (e.Curve.Center.x, e.Curve.Center.y, e.Curve.Radius))
@ -522,9 +522,9 @@ class ObjectDressup:
vb1 = FreeCAD.Vector(length, -self.toolRadius, 0)
vm2 = FreeCAD.Vector(length + self.toolRadius, 0, 0)
boneBot = Part.Line(vb1, vb0)
boneLid = Part.Line(vb0, vt0)
boneTop = Part.Line(vt0, vt1)
boneBot = Part.LineSegment(vb1, vb0)
boneLid = Part.LineSegment(vb0, vt0)
boneTop = Part.LineSegment(vt0, vt1)
# what we actually want is an Arc - but findIntersect only returns the coincident if one exists
# which really sucks because that's the one we're probably not interested in ....

View File

@ -46,7 +46,7 @@ def findholes(obj):
for h in facelist:
for w in h.Wires:
for c in w.Edges:
if ( isinstance(c.Curve,Part.Line)):
if ( isinstance(c.Curve,Part.LineSegment)):
v0=Base.Vector(c.Vertexes[0].X, c.Vertexes[0].Y, c.Vertexes[0].Z); v1=Base.Vector(c.Vertexes[1].X,c.Vertexes[1].Y, c.Vertexes[1].Z)
if (v1.sub(v0).x == 0) and (v1.sub(v0).y == 0):
lsp = Base.Vector(h.BoundBox.Center.x,h.BoundBox.Center.y,h.BoundBox.ZMax)

View File

@ -202,7 +202,7 @@ class ObjectDrilling:
for e in subobj.Edges:
if isinstance (e.Curve, Part.Circle):
cedge.append(e)
elif isinstance (e.Curve, Part.Line):
elif isinstance (e.Curve, Part.LineSegment):
ledge.append(e)
if len(cedge) == 2 and len(ledge) == 1:
drillable = True

View File

@ -43,7 +43,7 @@ def makeAreaVertex(seg):
segtype = int(seg.Curve.Axis.z) # 1=ccw arc,-1=cw arc
vertex = area.Vertex(segtype, area.Point(seg.valueAt(seg.LastParameter)[0], seg.valueAt(
seg.LastParameter)[1]), area.Point(seg.Curve.Center.x, seg.Curve.Center.y))
elif isinstance(seg.Curve, Part.Line):
elif isinstance(seg.Curve, Part.LineSegment):
point1 = seg.valueAt(seg.FirstParameter)[
0], seg.valueAt(seg.FirstParameter)[1]
point2 = seg.valueAt(seg.LastParameter)[

View File

@ -109,13 +109,13 @@ def silhouette(obj):
def isSameEdge(e1, e2):
"""isSameEdge(e1,e2): return True if the 2 edges are both lines or arcs/circles and have the same
points - inspired by Yorik's function isSameLine"""
if not (isinstance(e1.Curve, Part.Line) or isinstance(e1.Curve, Part.Circle)):
if not (isinstance(e1.Curve, Part.LineSegment) or isinstance(e1.Curve, Part.Circle)):
return False
if not (isinstance(e2.Curve, Part.Line) or isinstance(e2.Curve, Part.Circle)):
if not (isinstance(e2.Curve, Part.LineSegment) or isinstance(e2.Curve, Part.Circle)):
return False
if type(e1.Curve) != type(e2.Curve):
return False
if isinstance(e1.Curve, Part.Line):
if isinstance(e1.Curve, Part.LineSegment):
if (DraftVecUtils.equals(e1.Vertexes[0].Point, e2.Vertexes[0].Point)) and \
(DraftVecUtils.equals(e1.Vertexes[-1].Point, e2.Vertexes[-1].Point)):
return True
@ -232,7 +232,7 @@ def filterArcs(arcEdge):
splitlist.append(eseg2)
else:
splitlist.append(s)
elif isinstance(s.Curve, Part.Line):
elif isinstance(s.Curve, Part.LineSegment):
pass
return splitlist

View File

@ -247,7 +247,7 @@ public:
try {
Gui::Command::openCommand("Add sketch line");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)",
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)",
sketchgui->getObject()->getNameInDocument(),
EditCurve[0].x,EditCurve[0].y,EditCurve[1].x,EditCurve[1].y,
geometryCreationMode==Construction?"True":"False");
@ -465,10 +465,10 @@ public:
Gui::Command::openCommand("Add sketch box");
Gui::Command::doCommand(Gui::Command::Doc,
"geoList = []\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"App.ActiveDocument.%s.addGeometry(geoList,%s)\n"
"conList = []\n"
"conList.append(Sketcher.Constraint('Coincident',%i,2,%i,1))\n"
@ -969,7 +969,7 @@ public:
// open the transaction
Gui::Command::openCommand("Add line to sketch wire");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)",
"App.ActiveDocument.%s.addGeometry(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)",
sketchgui->getObject()->getNameInDocument(),
EditCurve[0].x,EditCurve[0].y,EditCurve[1].x,EditCurve[1].y,
geometryCreationMode==Construction?"True":"False");
@ -5324,8 +5324,8 @@ public:
"geoList = []\n"
"geoList.append(Part.ArcOfCircle(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f))\n"
"geoList.append(Part.ArcOfCircle(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f))\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"App.ActiveDocument.%s.addGeometry(geoList,%s)\n"
"conList = []\n"
"conList.append(Sketcher.Constraint('Tangent',%i,1,%i,1))\n"

View File

@ -917,7 +917,7 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg)
try{
if(!major)
{
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),True)",
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),True)",
Obj->getNameInDocument(),
majorpositiveend.x,majorpositiveend.y,majornegativeend.x,majornegativeend.y); // create line for major axis
@ -927,7 +927,7 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg)
}
if(!minor)
{
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),True)",
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),True)",
Obj->getNameInDocument(),
minorpositiveend.x,minorpositiveend.y,minornegativeend.x,minornegativeend.y); // create line for minor axis

View File

@ -37,12 +37,12 @@ def makeHexagonSimple(sketchName=None):
sketch = App.ActiveDocument.getObject(sketchName)
geoList = []
geoList.append(Part.Line(App.Vector(-20.00,34.64,0),App.Vector(20.00,34.64,0)))
geoList.append(Part.Line(App.Vector(20.00,34.64,0),App.Vector(47.082363,0.00,0)))
geoList.append(Part.Line(App.Vector(40.00,0.00,0),App.Vector(20.00,-34.64,0)))
geoList.append(Part.Line(App.Vector(20.00,-34.64,0),App.Vector(-20.00,-34.64,0)))
geoList.append(Part.Line(App.Vector(-20.00,-34.64,0),App.Vector(-40.00,0.00,0)))
geoList.append(Part.Line(App.Vector(-40.00,0.00,0),App.Vector(-20.00,34.64,0)))
geoList.append(Part.LineSegment(App.Vector(-20.00,34.64,0),App.Vector(20.00,34.64,0)))
geoList.append(Part.LineSegment(App.Vector(20.00,34.64,0),App.Vector(47.082363,0.00,0)))
geoList.append(Part.LineSegment(App.Vector(40.00,0.00,0),App.Vector(20.00,-34.64,0)))
geoList.append(Part.LineSegment(App.Vector(20.00,-34.64,0),App.Vector(-20.00,-34.64,0)))
geoList.append(Part.LineSegment(App.Vector(-20.00,-34.64,0),App.Vector(-40.00,0.00,0)))
geoList.append(Part.LineSegment(App.Vector(-40.00,0.00,0),App.Vector(-20.00,34.64,0)))
(l1,l2,l3,l4,l5,l6) = sketch.addGeometry(geoList)
conList = []

View File

@ -62,8 +62,8 @@ def makeRegularPolygon(
geoList = []
for i in range(0,sides-1):
geoList.append(Part.Line(pointList[i],pointList[i+1]))
geoList.append(Part.Line(pointList[sides-1],pointList[0]))
geoList.append(Part.LineSegment(pointList[i],pointList[i+1]))
geoList.append(Part.LineSegment(pointList[sides-1],pointList[0]))
geoList.append(Part.Circle(centerPoint,App.Vector(0,0,1),diffVec.Length))
geoIndices = sketch.addGeometry(geoList,construction)

View File

@ -24,10 +24,10 @@ import FreeCAD, os, sys, unittest, Part, Sketcher
App = FreeCAD
def CreateBoxSketchSet(SketchFeature):
SketchFeature.addGeometry(Part.Line(FreeCAD.Vector(-99.230339,36.960674,0),FreeCAD.Vector(69.432587,36.960674,0)))
SketchFeature.addGeometry(Part.Line(FreeCAD.Vector(69.432587,36.960674,0),FreeCAD.Vector(69.432587,-53.196629,0)))
SketchFeature.addGeometry(Part.Line(FreeCAD.Vector(69.432587,-53.196629,0),FreeCAD.Vector(-99.230339,-53.196629,0)))
SketchFeature.addGeometry(Part.Line(FreeCAD.Vector(-99.230339,-53.196629,0),FreeCAD.Vector(-99.230339,36.960674,0)))
SketchFeature.addGeometry(Part.LineSegment(FreeCAD.Vector(-99.230339,36.960674,0),FreeCAD.Vector(69.432587,36.960674,0)))
SketchFeature.addGeometry(Part.LineSegment(FreeCAD.Vector(69.432587,36.960674,0),FreeCAD.Vector(69.432587,-53.196629,0)))
SketchFeature.addGeometry(Part.LineSegment(FreeCAD.Vector(69.432587,-53.196629,0),FreeCAD.Vector(-99.230339,-53.196629,0)))
SketchFeature.addGeometry(Part.LineSegment(FreeCAD.Vector(-99.230339,-53.196629,0),FreeCAD.Vector(-99.230339,36.960674,0)))
# add the constraints
SketchFeature.addConstraint(Sketcher.Constraint('Coincident',0,2,1,1))
SketchFeature.addConstraint(Sketcher.Constraint('Coincident',1,2,2,1))
@ -42,11 +42,11 @@ def CreateBoxSketchSet(SketchFeature):
SketchFeature.addConstraint(Sketcher.Constraint('Distance',0,187.573036))
def CreateSlotPlateSet(SketchFeature):
SketchFeature.addGeometry(Part.Line(App.Vector(60.029362,-30.279360,0),App.Vector(-120.376335,-30.279360,0)))
SketchFeature.addGeometry(Part.LineSegment(App.Vector(60.029362,-30.279360,0),App.Vector(-120.376335,-30.279360,0)))
SketchFeature.addConstraint(Sketcher.Constraint('Horizontal',0))
SketchFeature.addGeometry(Part.Line(App.Vector(-120.376335,-30.279360,0),App.Vector(-70.193062,38.113884,0)))
SketchFeature.addGeometry(Part.LineSegment(App.Vector(-120.376335,-30.279360,0),App.Vector(-70.193062,38.113884,0)))
SketchFeature.addConstraint(Sketcher.Constraint('Coincident',0,2,1,1))
SketchFeature.addGeometry(Part.Line(App.Vector(-70.193062,38.113884,0),App.Vector(60.241116,37.478645,0)))
SketchFeature.addGeometry(Part.LineSegment(App.Vector(-70.193062,38.113884,0),App.Vector(60.241116,37.478645,0)))
SketchFeature.addConstraint(Sketcher.Constraint('Coincident',1,2,2,1))
SketchFeature.addConstraint(Sketcher.Constraint('Horizontal',2))
SketchFeature.addGeometry(Part.ArcOfCircle(Part.Circle(App.Vector(60.039921,3.811391,0),App.Vector(0,0,1),35.127132),-1.403763,1.419522))
@ -70,11 +70,11 @@ def CreateSlotPlateSet(SketchFeature):
def CreateSlotPlateInnerSet(SketchFeature):
SketchFeature.addGeometry(Part.Circle(App.Vector(195.055893,39.562252,0),App.Vector(0,0,1),29.846098))
SketchFeature.addGeometry(Part.Line(App.Vector(150.319031,13.449363,0),App.Vector(36.700474,13.139774,0)))
SketchFeature.addGeometry(Part.LineSegment(App.Vector(150.319031,13.449363,0),App.Vector(36.700474,13.139774,0)))
SketchFeature.addConstraint(Sketcher.Constraint('Horizontal',5))
SketchFeature.addGeometry(Part.Line(App.Vector(36.700474,13.139774,0),App.Vector(77.566010,63.292927,0)))
SketchFeature.addGeometry(Part.LineSegment(App.Vector(36.700474,13.139774,0),App.Vector(77.566010,63.292927,0)))
SketchFeature.addConstraint(Sketcher.Constraint('Coincident',5,2,6,1))
SketchFeature.addGeometry(Part.Line(App.Vector(77.566010,63.292927,0),App.Vector(148.151917,63.602505,0)))
SketchFeature.addGeometry(Part.LineSegment(App.Vector(77.566010,63.292927,0),App.Vector(148.151917,63.602505,0)))
SketchFeature.addConstraint(Sketcher.Constraint('Coincident',6,2,7,1))
SketchFeature.addConstraint(Sketcher.Constraint('Horizontal',7))
SketchFeature.addConstraint(Sketcher.Constraint('Parallel',1,6))

View File

@ -33,10 +33,10 @@ import FreeCAD, FreeCADGui, os, sys, unittest, Sketcher, SketcherGui
#
# def testBoxCase(self):
# self.Box = self.Doc.addObject('Sketcher::SketchObject','SketchBox')
# self.Box.addGeometry(Part.Line(App.Vector(-99.230339,36.960674,0),App.Vector(69.432587,36.960674,0)))
# self.Box.addGeometry(Part.Line(App.Vector(69.432587,36.960674,0),App.Vector(69.432587,-53.196629,0)))
# self.Box.addGeometry(Part.Line(App.Vector(69.432587,-53.196629,0),App.Vector(-99.230339,-53.196629,0)))
# self.Box.addGeometry(Part.Line(App.Vector(-99.230339,-53.196629,0),App.Vector(-99.230339,36.960674,0)))
# self.Box.addGeometry(Part.LineSegment(App.Vector(-99.230339,36.960674,0),App.Vector(69.432587,36.960674,0)))
# self.Box.addGeometry(Part.LineSegment(App.Vector(69.432587,36.960674,0),App.Vector(69.432587,-53.196629,0)))
# self.Box.addGeometry(Part.LineSegment(App.Vector(69.432587,-53.196629,0),App.Vector(-99.230339,-53.196629,0)))
# self.Box.addGeometry(Part.LineSegment(App.Vector(-99.230339,-53.196629,0),App.Vector(-99.230339,36.960674,0)))
#
# def tearDown(self):
# #closing doc

View File

@ -568,7 +568,7 @@ class SpreadsheetCases(unittest.TestCase):
InvoluteGearFeature.makeInvoluteGear('InvoluteGear')
self.doc.recompute()
sketch=self.doc.addObject('Sketcher::SketchObject','Sketch')
sketch.addGeometry(Part.Line(v(0,0,0),v(10,10,0)),False)
sketch.addGeometry(Part.LineSegment(v(0,0,0),v(10,10,0)),False)
sketch.addConstraint(Sketcher.Constraint('Distance',0,65.285388))
sketch.setExpression('Constraints[0]', 'InvoluteGear.NumberOfTeeth')
self.doc.recompute()
@ -583,7 +583,7 @@ class SpreadsheetCases(unittest.TestCase):
sheet.set('A1', '47,11')
self.doc.recompute()
index=sketch.addGeometry(Part.Line(v(0,0,0),v(10,10,0)),False)
index=sketch.addGeometry(Part.LineSegment(v(0,0,0),v(10,10,0)),False)
sketch.addConstraint(Sketcher.Constraint('Distance',index,14.0))
self.doc.recompute()
sketch.setExpression('Constraints[0]', u'Spreadsheet.Length')