本文整理汇总了Python中PathScripts.PathGeom.PathGeom.edgeForCmd方法的典型用法代码示例。如果您正苦于以下问题:Python PathGeom.edgeForCmd方法的具体用法?Python PathGeom.edgeForCmd怎么用?Python PathGeom.edgeForCmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathScripts.PathGeom.PathGeom
的用法示例。
在下文中一共展示了PathGeom.edgeForCmd方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test30
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import edgeForCmd [as 别名]
def test30(self):
"""Verify proper geometry for arcs with rising and fall ing Z-axis are created."""
#print("------ rising helix -------")
p1 = Vector(0, 1, 0)
p2 = Vector(1, 0, 2)
self.assertCurve(
PathGeom.edgeForCmd(
Path.Command('G2', {'X': p2.x, 'Y': p2.y, 'Z': p2.z, 'I': 0, 'J': -1, 'K': 1}), p1),
p1, Vector(1/math.sqrt(2), 1/math.sqrt(2), 1), p2)
p1 = Vector(-1, 0, 0)
p2 = Vector(0, -1, 2)
self.assertCurve(
PathGeom.edgeForCmd(
Path.Command('G3', {'X': p2.x, 'Y': p2.y, 'Z': p2.z, 'I': 1, 'J': 0, 'K': 1}), p1),
p1, Vector(-1/math.sqrt(2), -1/math.sqrt(2), 1), p2)
#print("------ falling helix -------")
p1 = Vector(0, -1, 2)
p2 = Vector(-1, 0, 0)
self.assertCurve(
PathGeom.edgeForCmd(
Path.Command('G2', {'X': p2.x, 'Y': p2.y, 'Z': p2.z, 'I': 0, 'J': 1, 'K': -1}), p1),
p1, Vector(-1/math.sqrt(2), -1/math.sqrt(2), 1), p2)
p1 = Vector(-1, 0, 2)
p2 = Vector(0, -1, 0)
self.assertCurve(
PathGeom.edgeForCmd(
Path.Command('G3', {'X': p2.x, 'Y': p2.y, 'Z': p2.z, 'I': 1, 'J': 0, 'K': -1}), p1),
p1, Vector(-1/math.sqrt(2), -1/math.sqrt(2), 1), p2)
示例2: test20
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import edgeForCmd [as 别名]
def test20(self):
"""Verify proper geometry for arcs in the XY-plane are created."""
p1 = Vector(0, -1, 2)
p2 = Vector(-1, 0, 2)
self.assertArc(
PathGeom.edgeForCmd(
Path.Command('G2', {'X': p2.x, 'Y': p2.y, 'Z': p2.z, 'I': 0, 'J': 1, 'K': 0}), p1),
p1, p2, 'CW')
self.assertArc(
PathGeom.edgeForCmd(
Path.Command('G3', {'X': p1.x, 'Y': p1.y, 'z': p1.z, 'I': -1, 'J': 0, 'K': 0}), p2),
p2, p1, 'CCW')
示例3: GetPathSolid
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import edgeForCmd [as 别名]
def GetPathSolid(self, tool, cmd, pos):
toolPath = PathGeom.edgeForCmd(cmd, pos)
# curpos = e1.valueAt(e1.LastParameter)
startDir = toolPath.tangentAt(0)
startDir[2] = 0.0
endPos = toolPath.valueAt(toolPath.LastParameter)
endDir = toolPath.tangentAt(toolPath.LastParameter)
try:
startDir.normalize()
endDir.normalize()
except:
return (None, endPos)
# height = self.height
# hack to overcome occ bugs
rad = tool.Diameter / 2.0 - 0.001 * pos[2]
# rad = rad + 0.001 * self.icmd
if type(toolPath.Curve) is Part.Circle and toolPath.Curve.Radius <= rad:
rad = toolPath.Curve.Radius - 0.01 * (pos[2] + 1)
return (None, endPos)
# create the path shell
toolProf = self.CreateToolProfile(tool, startDir, pos, rad)
rotmat = Base.Matrix()
rotmat.move(pos.negative())
rotmat.rotateZ(math.pi)
rotmat.move(pos)
mirroredProf = toolProf.transformGeometry(rotmat)
fullProf = Part.Wire([toolProf, mirroredProf])
pathWire = Part.Wire(toolPath)
try:
pathShell = pathWire.makePipeShell([fullProf], False, True)
except:
if self.debug:
Part.show(pathWire)
Part.show(fullProf)
return (None, endPos)
# create the start cup
startCup = toolProf.revolve(pos, Vector(0, 0, 1), -180)
# create the end cup
endProf = self.CreateToolProfile(tool, endDir, endPos, rad)
endCup = endProf.revolve(endPos, Vector(0, 0, 1), 180)
fullShell = Part.makeShell(startCup.Faces + pathShell.Faces + endCup.Faces)
return (Part.makeSolid(fullShell).removeSplitter(), endPos)
示例4: GetPathSolidOld
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import edgeForCmd [as 别名]
def GetPathSolidOld(self, tool, cmd, curpos):
e1 = PathGeom.edgeForCmd(cmd, curpos)
# curpos = e1.valueAt(e1.LastParameter)
n1 = e1.tangentAt(0)
n1[2] = 0.0
try:
n1.normalize()
except:
return (None, e1.valueAt(e1.LastParameter))
height = self.height
rad = tool.Diameter / 2.0 - 0.001 * curpos[2] # hack to overcome occ bug
if type(e1.Curve) is Part.Circle and e1.Curve.Radius <= rad: # hack to overcome occ bug
rad = e1.Curve.Radius - 0.001
# return (None, e1.valueAt(e1.LastParameter))
xf = n1[0] * rad
yf = n1[1] * rad
xp = curpos[0]
yp = curpos[1]
zp = curpos[2]
v1 = Vector(yf + xp, -xf + yp, zp)
v2 = Vector(yf + xp, -xf + yp, zp + height)
v3 = Vector(-yf + xp, xf + yp, zp + height)
v4 = Vector(-yf + xp, xf + yp, zp)
# vc1 = Vector(xf + xp, yf + yp, zp)
# vc2 = Vector(xf + xp, yf + yp, zp + height)
l1 = Part.makeLine(v1, v2)
l2 = Part.makeLine(v2, v3)
# l2 = Part.Edge(Part.Arc(v2, vc2, v3))
l3 = Part.makeLine(v3, v4)
l4 = Part.makeLine(v4, v1)
# l4 = Part.Edge(Part.Arc(v4, vc1, v1))
w1 = Part.Wire([l1, l2, l3, l4])
w2 = Part.Wire(e1)
try:
ex1 = w2.makePipeShell([w1], True, True)
except:
# Part.show(w1)
# Part.show(w2)
return (None, e1.valueAt(e1.LastParameter))
cyl1 = Part.makeCylinder(rad, height, curpos)
curpos = e1.valueAt(e1.LastParameter)
cyl2 = Part.makeCylinder(rad, height, curpos)
ex1s = Part.Solid(ex1)
f1 = ex1s.fuse([cyl1, cyl2]).removeSplitter()
return (f1, curpos)
示例5: test10
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import edgeForCmd [as 别名]
def test10(self):
"""Verify proper geometry objects for G1 and G01 commands are created."""
spt = Vector(1,2,3)
self.assertLine(PathGeom.edgeForCmd(Path.Command('G1', {'X': 7, 'Y': 2, 'Z': 3}), spt), spt, Vector(7, 2, 3))
self.assertLine(PathGeom.edgeForCmd(Path.Command('G01', {'X': 1, 'Y': 3, 'Z': 5}), spt), spt, Vector(1, 3, 5))
示例6: RapidMove
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import edgeForCmd [as 别名]
def RapidMove(self, cmd, curpos):
path = PathGeom.edgeForCmd(cmd, curpos) # hack to overcome occ bug
if path is None:
return curpos
return path.valueAt(path.LastParameter)