replace Part.Line with Part.LineSegment
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user