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

@@ -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):