本文整理匯總了Python中Part.Line方法的典型用法代碼示例。如果您正苦於以下問題:Python Part.Line方法的具體用法?Python Part.Line怎麽用?Python Part.Line使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Part
的用法示例。
在下文中一共展示了Part.Line方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: compute_path_cp
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def compute_path_cp(self):
free_turns = self.turns-2
skew = Part.LineSegment(Vector(2*pi,self.wire_diam,0),Vector((self.turns-1)*2*pi,self.length-self.wire_diam,0))
tan = skew.tangent(skew.FirstParameter)[0]
tan.normalize()
tan.multiply(self.wire_diam/2.)
p1 = Vector(-tan.y,tan.x,0)
ls = Part.Line(skew.StartPoint+p1,skew.EndPoint-p1)
h1 = Part.Line(Vector(0,self.wire_diam/2.,0),Vector(1,self.wire_diam/2.,0))
h2 = Part.Line(Vector(0,self.length-self.wire_diam/2.,0),Vector(1,self.length-self.wire_diam/2.,0))
pts = [Vector2d(0,self.wire_diam/2.)]
i1 = h1.intersect(ls)[0]
i2 = h2.intersect(ls)[0]
pts.append(Vector2d(i1.X,i1.Y))
pts.append(Vector2d(i2.X,i2.Y))
pts.append(Vector2d(self.turns*2*pi,self.length-self.wire_diam/2.))
return pts
示例2: selectAction
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def selectAction(self):
edged = [objex for objex in FreeCADGui.Selection.getSelectionEx() if frameCmd.edges([objex])]
if edged:
self.Axis=frameCmd.edges([edged[0]])[0]
self.deleteArrow()
from polarUtilsCmd import arrow
where=FreeCAD.Placement()
where.Base=self.Axis.valueAt(self.Axis.LastParameter)
where.Rotation=FreeCAD.Rotation(FreeCAD.Vector(0,0,1),self.Axis.tangentAt(self.Axis.LastParameter))
size=[self.Axis.Length/20.0,self.Axis.Length/10.0,self.Axis.Length/20.0]
self.arrow=arrow(pl=where,scale=size,offset=self.Axis.Length/10.0)
if self.Axis.curvatureAt(0):
O=self.Axis.centerOfCurvatureAt(0)
n=self.Axis.tangentAt(0).cross(self.Axis.normalAt(0))
from Part import Edge, Line
self.Axis=(Edge(Line(FreeCAD.Vector(O),FreeCAD.Vector(O+n))))
self.form.lab1.setText(edged[0].Object.Label+": edge")
示例3: PathToShape
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def PathToShape(point_list):
# creates a compound of faces from a NiCr point list to representate the wire
# trajectory
comp = []
for i in range(len(point_list[0])-1):
pa_0 = FreeCAD.Vector(tuple(point_list[0][i]))
pa_1 = FreeCAD.Vector(tuple(point_list[0][i+1]))
pb_0 = FreeCAD.Vector(tuple(point_list[1][i]))
pb_1 = FreeCAD.Vector(tuple(point_list[1][i+1]))
l0 = Part.Line(pa_0, pa_1).toShape()
l1 = Part.Line(pb_0, pb_1).toShape()
f = Part.makeLoft([l0, l1])
comp.append(f)
return Part.makeCompound(comp)
# routing between WirePaths (wirepath path link)
示例4: __init__
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def __init__(self, obj):
"""
An Edge
"""
self.wrapped = obj
# self.startPoint = None
# self.endPoint = None
self.edgetypes = {
FreeCADPart.ArcOfCircle: 'ARC',
FreeCADPart.Circle: 'CIRCLE'
}
if hasattr(FreeCADPart,"Line"):
self.edgetypes[FreeCADPart.Line] = 'LINE'
if hasattr(FreeCADPart,"LineSegment"):
self.edgetypes[FreeCADPart.LineSegment] = 'LINE'
# Helps identify this solid through the use of an ID
self.label = ""
示例5: isLine
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def isLine(param):
return isinstance(param,(Part.Line,Part.LineSegment))
示例6: getVertexes
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def getVertexes(shape):
v = shape.Vertexes
if v or shape.countElement('Edge')!=1:
return v
curve = shape.Edge1.Curve
if isinstance(curve,Part.Line):
return [Part.Vertex(curve.Location),
Part.Vertex(curve.Location+curve.Direction)]
return []
示例7: tangentTo
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def tangentTo(self, t, pt):
v = self.valueAt(t)
n = self.normalAt(t)
tanPlane = Part.Plane(v,n)
line = Part.Line(pt, pt.add(n))
ptOnPlane = tanPlane.intersect(line)
res = []
if isinstance(ptOnPlane,tuple):
for el in ptOnPlane:
if isinstance(el,(tuple,list)):
for e in el:
if isinstance(e,Part.Point):
res.append(FreeCAD.Vector(e.X,e.Y,e.Z).sub(v))
return(res)
示例8: disegna
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def disegna(sk, pos):
'arg1=sketch, arg2=pos (list of 3-uple): draws the segments of "pos" in "sketch" and close the polygon'
import FreeCAD, Part, Sketcher
lines=[]
while len(pos)>1:
lines.append(sk.addGeometry(Part.Line(FreeCAD.Vector(pos[0]),FreeCAD.Vector(pos[1]))))
pos.pop(0)
for i in range(len(lines)-1):
sk.addConstraint(Sketcher.Constraint('Coincident',lines[i],2,lines[i+1],1))
sk.addConstraint(Sketcher.Constraint('Coincident',lines[len(lines)-1],2,lines[0],1))
FreeCAD.activeDocument().recompute()
return lines
示例9: __init__
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def __init__(self, wireFlag=True):
DraftTools.Line.__init__(self,wireFlag)
self.Activated()
dialogPath=join(dirname(abspath(__file__)),"dialogs","hackedline.ui")
self.hackedUI=FreeCADGui.PySideUic.loadUi(dialogPath)
self.hackedUI.btnRot.clicked.connect(self.rotateWP)
self.hackedUI.btnOff.clicked.connect(self.offsetWP)
self.hackedUI.btnXY.clicked.connect(lambda: self.alignWP(FreeCAD.Vector(0,0,1)))
self.hackedUI.btnXZ.clicked.connect(lambda: self.alignWP(FreeCAD.Vector(0,1,0)))
self.hackedUI.btnYZ.clicked.connect(lambda: self.alignWP(FreeCAD.Vector(1,0,0)))
self.ui.layout.addWidget(self.hackedUI)
示例10: getPrincipalAx
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def getPrincipalAx(self, ax='Z'):
self.deleteArrow()
from Part import Edge,Line
O=FreeCAD.Vector()
l=Line(O,FreeCAD.Vector(0,0,1000))
if ax=='X':
l=Line(O,FreeCAD.Vector(1000,0,0))
elif ax=='Y':
l=Line(O,FreeCAD.Vector(0,1000,0))
self.Axis=Edge(l)
self.form.lab1.setText("Principal: "+ax)
示例11: isLine
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def isLine(param):
if hasattr(Part,"LineSegment"):
return isinstance(param,(Part.Line,Part.LineSegment))
else:
return isinstance(param,Part.Line)
#------------------------------------------------------------------------------
示例12: drawVector
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def drawVector(fromPoint,toPoint, color):
if fromPoint == toPoint: return
doc = FreeCAD.ActiveDocument
l = Part.LineSegment()
l.StartPoint = fromPoint
l.EndPoint = toPoint
line = doc.addObject("Part::Feature","Line")
line.Shape = l.toShape()
line.ViewObject.LineColor = color
line.ViewObject.LineWidth = 1
c = Part.makeCone(0,1,4)
cone = doc.addObject("Part::Feature","ArrowHead")
cone.Shape = c
cone.ViewObject.ShapeColor = color
#
mov = Base.Vector(0,0,0)
zAxis = Base.Vector(0,0,-1)
rot = FreeCAD.Rotation(zAxis,toPoint.sub(fromPoint))
cent = Base.Vector(0,0,0)
conePlacement = FreeCAD.Placement(mov,rot,cent)
cone.Placement = conePlacement.multiply(cone.Placement)
cone.Placement.move(toPoint)
doc.recompute()
#------------------------------------------------------------------------------
示例13: make_rounded_shape
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def make_rounded_shape(material_face, material_plane, width, pos_y, use_laser_kerf = True):
part_thickness = material_face.thickness
other_part_thickness_with_tolerance = material_plane.thickness + material_plane.thickness_tolerance
corrected_width = width
if use_laser_kerf:
corrected_width = corrected_width + material_face.laser_beam_diameter
half_width = corrected_width / 2.0
z = part_thickness/2.0
th = other_part_thickness_with_tolerance
p1 = FreeCAD.Vector(0., -half_width, z)
p2 = FreeCAD.Vector(0.3 * th, -half_width, z)
cp2_1 = FreeCAD.Vector(0.9 * th, -half_width, z)
p3 = FreeCAD.Vector(0.9 * th, 0, z)
cp3_1 = FreeCAD.Vector(0.9 * th, half_width / 4.0, z)
cp3_2 = FreeCAD.Vector(1.6 * th, half_width / 4.0, z)
p4 = FreeCAD.Vector(1.6 * th, half_width / 2.0, z)
p5 = FreeCAD.Vector(1.6 * th, half_width, z)
cp5_1 = FreeCAD.Vector(1.6 * th, 1.2 * half_width, z)
p6 = FreeCAD.Vector(1.04 * th, 1.2 * half_width, z)
p7 = FreeCAD.Vector(th, half_width, z)
p8 = FreeCAD.Vector(0, half_width, z)
l1 = Part.Line(p1, p2)
c2 = make_bezier_curve([p2, cp2_1, p3])
c3 = make_bezier_curve([p3, cp3_1, cp3_2, p4])
l4 = Part.Line(p4, p5)
c5 = make_bezier_curve([p5, cp5_1, p6])
l6 = Part.Line(p6, p7)
l7 = Part.Line(p7, p8)
l8 = Part.Line(p8, p1)
shape = Part.Shape([l1, c2, c3, l4, c5, l6, l7, l8])
wire = Part.Wire(shape.Edges)
face = Part.Face(wire)
part = face.extrude(FreeCAD.Vector(0, 0, -part_thickness))
part.translate(FreeCAD.Vector(0, pos_y, 0))
#Part.show(part)
return part
示例14: smMakeFace
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def smMakeFace(vertex, face, edges, relief):
if edges[0].Vertexes[0].isSame(vertex) :
Edgedir1 = edges[0].Vertexes[1].Point - edges[0].Vertexes[0].Point
else :
Edgedir1 = edges[0].Vertexes[0].Point - edges[0].Vertexes[1].Point
Edgedir1.normalize()
if edges[1].Vertexes[0].isSame(vertex) :
Edgedir2 = edges[1].Vertexes[1].Point - edges[1].Vertexes[0].Point
else :
Edgedir2 = edges[1].Vertexes[0].Point - edges[1].Vertexes[1].Point
Edgedir2.normalize()
normal = face.normalAt(0,0)
Edgedir3 = normal.cross(Edgedir1)
Edgedir4 = normal.cross(Edgedir2)
p1 = vertex.Point
p2 = p1 + relief * Edgedir1
p3 = p2 + relief * Edgedir3
if not(face.isInside(p3,0.0,True)) :
p3 = p2 + relief * Edgedir3 * -1
p6 = p1 + relief * Edgedir2
p5 = p6 + relief * Edgedir4
if not(face.isInside(p5, 0.0,True)) :
p5 = p6 + relief * Edgedir4 * -1
#print([p1,p2,p3,p5,p6,p1])
e1 = Part.makeLine(p2, p3)
#Part.show(e1,'e1')
e2 = Part.makeLine(p5, p6)
#Part.show(e2,'e2')
section = e1.section(e2)
#Part.show(section1,'section1')
if section.Vertexes :
wire = Part.makePolygon([p1,p2,p3,p6,p1])
else :
p41 = p3 + relief * Edgedir1 * -1
p42 = p5 + relief * Edgedir2 * -1
e1 = Part.Line(p3, p41).toShape()
#Part.show(e1,'e1')
e2 = Part.Line(p42, p5).toShape()
#Part.show(e2,'e2')
section = e1.section(e2)
#Part.show(section1,'section1')
p4 = section.Vertexes[0].Point
wire = Part.makePolygon([p1,p2,p3,p4,p5,p6,p1])
extface = Part.Face(wire)
return extface
示例15: make_rounded_shape_for_groove
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Line [as 別名]
def make_rounded_shape_for_groove(material_face, material_plane, width, pos_y, use_laser_kerf = True):
part_thickness = material_face.thickness
other_part_thickness_with_tolerance = material_plane.thickness + material_plane.thickness_tolerance
corrected_width = width
if use_laser_kerf:
corrected_width = corrected_width + material_face.laser_beam_diameter
half_width = corrected_width / 2.0
z = part_thickness/2.0
th = other_part_thickness_with_tolerance
p1 = FreeCAD.Vector(0., -half_width, z)
p2 = FreeCAD.Vector(th, -half_width, z)
p3 = FreeCAD.Vector(1.04 * th, -1.15 * half_width, z)
p4 = FreeCAD.Vector(1.4 * th, -1.15 * half_width, z)
cp4_1 = FreeCAD.Vector(1.6 * th, -half_width / 4.0, z)
p5 = FreeCAD.Vector(th, half_width / 4.0, z)
p6 = FreeCAD.Vector(th, 0.7 * half_width, z)
cp6_1 = FreeCAD.Vector(th, half_width, z)
p7 = FreeCAD.Vector(0.7 * th, half_width, z)
p8 = FreeCAD.Vector(0, half_width, z)
l1 = Part.Line(p1, p2)
l2 = Part.Line(p2, p3)
l3 = Part.Line(p3, p4)
c4 = make_bezier_curve([p4, cp4_1, p5])
l5 = Part.Line(p5, p6)
c6 = make_bezier_curve([p6, cp6_1, p7])
p7 = Part.Line(p7, p8)
p8 = Part.Line(p8, p1)
shape = Part.Shape([l1, l2, l3, c4, l5, c6, p7, p8])
wire = Part.Wire(shape.Edges)
face = Part.Face(wire)
part = face.extrude(FreeCAD.Vector(0, 0, -part_thickness))
part.translate(FreeCAD.Vector(0, pos_y, 0))
#Part.show(part)
part = helper.make_dog_bone_on_limits_on_xz(part, part_thickness)
return part