本文整理汇总了Python中Part.makeLine方法的典型用法代码示例。如果您正苦于以下问题:Python Part.makeLine方法的具体用法?Python Part.makeLine怎么用?Python Part.makeLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part.makeLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: join_2_edges
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def join_2_edges(e1,e2):
d,pts,info = e1.distToShape(e2)
if d < 1e-7: # edges are touching
for i in info:
if (i[0] == "Vertex") and (i[3] == "Vertex"): # Contact type : end to end
return (e1,e2)
elif (i[0] == "Edge") and (i[3] == "Vertex"): # Contact type : edge to end
return (longest_segment(e1,i[2]),e2)
elif (i[0] == "Vertex") and (i[3] == "Edge"): # Contact type : end to edge
return (e1,longest_segment(e2,i[5]))
elif (i[0] == "Edge") and (i[3] == "Edge"): # Contact type : edge to edge
return (longest_segment(e1,i[2]),longest_segment(e2,i[5]))
else: # No contact : must add a join curve
for pt,i in zip(pts,info):
l = Part.makeLine(pt[0],pt[1])
if (i[0] == "Vertex") and (i[3] == "Vertex"): # Contact type : end to end
return (e1,l,e2)
elif (i[0] == "Edge") and (i[3] == "Vertex"): # Contact type : edge to end
return (longest_segment(e1,i[2]),l,e2)
elif (i[0] == "Vertex") and (i[3] == "Edge"): # Contact type : end to edge
return (e1,l,longest_segment(e2,i[5]))
elif (i[0] == "Edge") and (i[3] == "Edge"): # Contact type : edge to edge
return (longest_segment(e1,i[2]),l,longest_segment(e2,i[5]))
示例2: make_oval
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def make_oval(size,params=None):
_ = params
if size.x == size.y:
return make_circle(size)
if size.x < size.y:
r = size.x*0.5
size.y -= size.x
s = ((0,0.5),(-0.5,0.5),(-0.5,-0.5),(0,-0.5),(0.5,-0.5),(0.5,0.5))
a = (0,180,180,360)
else:
r = size.y*0.5
size.x -= size.y
s = ((-0.5,0),(-0.5,-0.5),(0.5,-0.5),(0.5,0),(0.5,0.5),(-0.5,0.5))
a = (90,270,-90,-270)
pts = [product(size,Vector(*v)) for v in s]
return Part.Wire([
Part.makeCircle(r,pts[0],Vector(0,0,1),a[0],a[1]),
Part.makeLine(pts[1],pts[2]),
Part.makeCircle(r,pts[3],Vector(0,0,1),a[2],a[3]),
Part.makeLine(pts[4],pts[5])])
示例3: drawLine
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def drawLine( self, pt1, pt2, name='aLine', width=3 ):
global taskUI
if pt1!=pt2:
line = Part.makeLine( pt1, pt2 )
wire = App.ActiveDocument.addObject('Part::FeaturePython', name)
wire.ViewObject.Proxy = setCustomIcon(wire, taskUI.lineIcon )
wire.Shape = Part.Wire(line)
wire.ViewObject.LineWidth = width
wire.ViewObject.LineColor = ( 1.0, 1.0, 1.0 )
wire.ViewObject.PointSize = 10
wire.ViewObject.PointColor= ( 0.0, 0.0, 1.0 )
self.addToDims(wire)
else:
point = App.ActiveDocument.addObject('Part::FeaturePython', 'aPoint')
point.ViewObject.Proxy = setCustomIcon(point, taskUI.pointIcon )
point.Shape = Part.Vertex(Part.Point( pt1 ))
point.ViewObject.PointSize = 10
point.ViewObject.PointColor= ( 0.0, 0.0, 1.0 )
self.addToDims(point)
示例4: testFuse
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def testFuse(self):
"""
Tests fusing one face to another.
"""
# Face 1
edge1 = Part.makeLine((0, 0, 0), (0, 10, 0))
edge2 = Part.makeLine((0, 10, 0), (10, 10, 0))
edge3 = Part.makeLine((10, 10, 0), (10, 0, 0))
edge4 = Part.makeLine((10, 0, 0), (0, 0, 0))
wire1 = Part.Wire([edge1,edge2,edge3,edge4])
face1 = Part.Face(wire1)
cqFace1 = Face(face1)
# Face 2 (face to cut out of face 1)
edge1 = Part.makeCircle(4.0)
wire1 = Part.Wire([edge1])
face2 = Part.Face(wire1)
cqFace2 = Face(face2)
# Face resulting from fuse
cqFace3 = cqFace1.fuse(cqFace2)
self.assertEquals(len(cqFace3.Faces()), 3)
self.assertEquals(len(cqFace3.Edges()), 8)
示例5: testIntersect
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def testIntersect(self):
"""
Tests finding the intersection of two faces.
"""
# Face 1
edge1 = Part.makeLine((0, 0, 0), (0, 10, 0))
edge2 = Part.makeLine((0, 10, 0), (10, 10, 0))
edge3 = Part.makeLine((10, 10, 0), (10, 0, 0))
edge4 = Part.makeLine((10, 0, 0), (0, 0, 0))
wire1 = Part.Wire([edge1,edge2,edge3,edge4])
face1 = Part.Face(wire1)
cqFace1 = Face(face1)
# Face 2 (face to cut out of face 1)
edge1 = Part.makeCircle(4.0)
wire1 = Part.Wire([edge1])
face2 = Part.Face(wire1)
cqFace2 = Face(face2)
# Face resulting from the intersection
cqFace3 = cqFace1.intersect(cqFace2)
self.assertEquals(len(cqFace3.Faces()), 1)
self.assertEquals(len(cqFace3.Edges()), 3)
示例6: smMakeReliefFace
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def smMakeReliefFace(edge, dir, gap, reliefW, reliefD, reliefType, op=''):
p1 = edge.valueAt(edge.FirstParameter + gap)
p2 = edge.valueAt(edge.FirstParameter + gap + reliefW )
if reliefType == "Round" and reliefD > reliefW :
p3 = edge.valueAt(edge.FirstParameter + gap + reliefW) + dir.normalize() * (reliefD-reliefW/2)
p34 = edge.valueAt(edge.FirstParameter + gap + reliefW/2) + dir.normalize() * reliefD
p4 = edge.valueAt(edge.FirstParameter + gap) + dir.normalize() * (reliefD-reliefW/2)
e1 = Part.makeLine(p1, p2)
e2 = Part.makeLine(p2, p3)
e3 = Part.Arc(p3, p34, p4).toShape()
e4 = Part.makeLine(p4, p1)
else :
p3 = edge.valueAt(edge.FirstParameter + gap + reliefW) + dir.normalize() * reliefD
p4 = edge.valueAt(edge.FirstParameter + gap) + dir.normalize() * reliefD
e1 = Part.makeLine(p1, p2)
e2 = Part.makeLine(p2, p3)
e3 = Part.makeLine(p3, p4)
e4 = Part.makeLine(p4, p1)
w = Part.Wire([e1,e2,e3,e4])
face = Part.Face(w)
if hasattr(face, 'mapShapes'):
face.mapShapes([(edge,face)],[],op)
return face
示例7: make_cross_box
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def make_cross_box(length, width, height, node_type, node_thickness):
half_length = length / 2.0
p1 = FreeCAD.Vector(half_length, 0, 0)
p2 = FreeCAD.Vector(-half_length, 0, 0)
p3 = FreeCAD.Vector(-half_length, 0, -height)
p4 = FreeCAD.Vector(half_length, 0, -height)
l1 = Part.makeLine(p1, p2)
l2 = Part.makeLine(p2, p3)
l3 = Part.makeLine(p3, p4)
l4 = Part.makeLine(p4, p1)
wire = Part.Wire([l1,l2,l3,l4])
face = Part.Face(wire)
face.translate(FreeCAD.Vector(0, -width / 2.0, 0))
part = face.extrude(FreeCAD.Vector(0, width, 0))
return part
示例8: make_node_xz
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def make_node_xz(width, height, thickness, x_positive = True):
p1 = FreeCAD.Vector(0., -thickness/2.0, height / 2.0)
p2 = FreeCAD.Vector(0., -thickness/2.0, -height / 2.0)
if x_positive is True:
pa = FreeCAD.Vector(width, -thickness/2.0, 0.)
else:
pa = FreeCAD.Vector(-width, -thickness/2.0, 0.)
l1 = Part.makeLine(p1, p2)
a2 = Part.Arc(p2, pa, p1).toShape()
wire = Part.Wire([l1, a2])
face = Part.Face(wire)
node = face.extrude(FreeCAD.Vector(0, thickness, 0))
return node
示例9: make_node_yz
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def make_node_yz(width, height, thickness, x_positive = True):
p1 = FreeCAD.Vector(-thickness/2.0, 0, height / 2.0)
p2 = FreeCAD.Vector(-thickness/2.0, 0, -height / 2.0)
if x_positive is True:
pa = FreeCAD.Vector(-thickness/2.0, width, 0.)
else:
pa = FreeCAD.Vector(-thickness/2.0, -width, 0.)
l1 = Part.makeLine(p1, p2)
a2 = Part.Arc(p2, pa, p1).toShape()
wire = Part.Wire([l1, a2])
face = Part.Face(wire)
node = face.extrude(FreeCAD.Vector(thickness, 0, 0))
return node
# noeud court = 1/4 hauteur
# noeud long = 1/2 hauteur
# 2 neouds court = 2 * 1/4 hauteur espace de 16 % de la hateur au centre
示例10: draw_rounded_hinge
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def draw_rounded_hinge(hinge_width, hinge_length, height):
half_w = hinge_width/2.0
half_l = hinge_length/2.0
half_h = height / 2.0
z_plane = -half_h
v1 = FreeCAD.Vector(-half_w, -half_l, z_plane)
v2 = FreeCAD.Vector(-half_w, half_l, z_plane)
v3 = FreeCAD.Vector(half_w, half_l, z_plane)
v4 = FreeCAD.Vector(half_w, -half_l, z_plane)
vc1 = FreeCAD.Vector(0, -(half_l + half_w), z_plane)
vc2 = FreeCAD.Vector(0, half_l+half_w, z_plane)
c1 = Part.Arc(v1, vc1, v4).toShape()
c2 = Part.Arc(v2, vc2, v3).toShape()
l1 = Part.makeLine(v1, v2)
l2 = Part.makeLine(v3, v4)
wire = Part.Wire([c1, l1, c2, l2])
hinge = wire.extrude(FreeCAD.Vector(0.0, 0.0, height))
hinge_solid = Part.makeSolid(hinge)
return hinge_solid
示例11: get_contours_with_arc
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def get_contours_with_arc(edge, arcs_segment_list):
nb_face = len(edge)
outer_contours = []
inner_contours = []
for index in range(nb_face):
first_segment = edge[index][0]
second_segment = edge[index][1]
last_segment = edge[(index + 1) % nb_face][0]
outer_contours.append(Part.makeLine(first_segment.A, second_segment.A))
inner_contours.append(Part.makeLine(first_segment.B, second_segment.B))
outer_contours.append(Part.Arc(second_segment.A, arcs_segment_list[index].A, last_segment.A).toShape())
inner_contours.append(Part.Arc(second_segment.B, arcs_segment_list[index].B, last_segment.B).toShape())
return inner_contours, outer_contours
示例12: updateTrajectoryLines
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def updateTrajectoryLines():
EAFolder = FreeCAD.ActiveDocument.ExplodedAssembly.Group
# remove all the previous trajectory lines
for traj in EAFolder:
for lines in traj.Group:
FreeCAD.ActiveDocument.removeObject(lines.Name)
# re-draw all trajectories
for traj in EAFolder:
lines_compound = []
objects = []
for name in traj.names:
objects.append(FreeCAD.ActiveDocument.getObject(name))
inc_D = traj.Distance
dir_vectors = []
rot_centers = []
for s in range(len(objects)):
dir_vectors.append(FreeCAD.Vector(tuple(traj.dir_vectors[s])))
rot_centers.append(FreeCAD.Vector(tuple(traj.rot_centers[s])))
for n in range(len(objects)):
pa = rot_centers[n]# objects[n].Placement.Base
pb = rot_centers[n] + dir_vectors[n]*inc_D
lines_compound.append(Part.makeLine(pa, pb))
l_obj = FreeCAD.ActiveDocument.addObject('Part::Feature','trajectory_line')
l_obj.Shape = Part.makeCompound(lines_compound)
l_obj.ViewObject.DrawStyle = "Dashed"
l_obj.ViewObject.LineWidth = 1.0
traj.addObject(l_obj)
FreeCAD.Gui.updateGui()
示例13: execute
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def execute(self,obj):
length = obj.Length.Value
width = obj.Width.Value
if not length:
if not width:
obj.Shape = Part.Vertex(FreeCAD.Vector())
else:
obj.Shape = Part.makeLine(FreeCAD.Vector(0,-width/2,0),
FreeCAD.Vector(0,width/2,0))
elif not width:
obj.Shape = Part.makeLine(FreeCAD.Vector(-length/2,0,0),
FreeCAD.Vector(length/2,0,0))
else:
obj.Shape = Part.makePlane(length,width,
FreeCAD.Vector(-length/2,-width/2,0))
示例14: tangent_update
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def tangent_update(self):
v = Part.Vertex(self.point)
p = v.distToShape(self.snap_shape)[1][0][1]
try:
par = self.snap_shape.Curve.parameter(p)
except:
print("Failed to get curve parameter")
par = self.snap_shape.FirstParameter
#print(par)
tan = self.snap_shape.tangentAt(par)
e = Part.makeLine(p, p+tan)
self.tangent = e.Curve.toShape(-2e10, 2e10)
示例15: getNotches
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeLine [as 别名]
def getNotches(self, num=20, l=1.0):
notches = list()
for i in range(num):
par = 1.0*i / (num-1)
p1, p2 = self.valueAt(par)
ls = Part.LineSegment(p1, p2)
p3 = ls.value(ls.FirstParameter - l)
p4 = ls.value(ls.LastParameter + l)
nls = Part.makeLine(p3, p4)
sh1 = self.rail1.face.project([nls])
sh2 = self.rail2.face.project([nls])
if (len(sh1.Edges) > 0) and (len(sh2.Edges) > 0):
notches.append((sh1.Edges[0], sh2.Edges[0]))
return(notches)