本文整理汇总了Python中Part.Shape方法的典型用法代码示例。如果您正苦于以下问题:Python Part.Shape方法的具体用法?Python Part.Shape怎么用?Python Part.Shape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part.Shape方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getElement
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def getElement(shape, element):
res = None
if not isinstance(shape, Part.Shape):
try:
res = getElementShape(shape, element)
if res and not res.isNull():
return res
except Exception:
return
try:
res = shape.getElement(element, True)
except TypeError:
try:
# older FC does not accept the second 'silent' argument
res = shape.getElement(element)
except Exception:
return
except Exception:
return
if res and not res.isNull():
return res
示例2: getShape
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def getShape(self, fp):
if fp.Source is None:
return None, None
if fp.Source[1] == []: # No subshape given, take wire 1
if fp.Source[0].Shape.Wires:
w = fp.Source[0].Shape.Wire1
e = w.approximate(1e-7, 1e-5, len(w.Edges), 7).toShape()
#double tol2d = gp::Resolution();
#double tol3d = 0.0001;
#int maxseg=10, maxdeg=3;
#static char* kwds_approx[] = {"Tol2d","Tol3d","MaxSegments","MaxDegree",NULL};
else:
return None, None
else:
e = _utils.getShape(fp, "Source", "Edge")
w = False
return e, w
示例3: Activated
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def Activated(self):
edges = []
sel = FreeCADGui.Selection.getSelectionEx()
if sel == []:
FreeCAD.Console.PrintError("Select the edges to split first !\n")
for selobj in sel:
if selobj.HasSubObjects:
for i in range(len(selobj.SubObjects)):
if isinstance(selobj.SubObjects[i], Part.Edge):
self.makeSplitFeature((selobj.Object, selobj.SubElementNames[i]))
if selobj.Object.Shape:
if len(selobj.Object.Shape.Edges) == 1:
selobj.Object.ViewObject.Visibility = False
else:
self.makeSplitFeature((selobj.Object, []))
if hasattr(selobj.Object,"ViewObject"):
selobj.Object.ViewObject.Visibility = False
示例4: update_shape
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def update_shape(self):
e1 = _utils.getShape(self.Object, "Edge1", "Edge")
e2 = _utils.getShape(self.Object, "Edge2", "Edge")
if e1 and e2:
bc = nurbs_tools.blendCurve(e1,e2)
v = Part.Vertex(self.m1.point)
proj = v.distToShape(self.m1.snap_shape)[1][0][1]
bc.param1 = e1.Curve.parameter(proj)
#bc.param1 = (pa1 - self.m1.snap_shape.FirstParameter) / (self.m1.snap_shape.LastParameter - self.m1.snap_shape.FirstParameter)
bc.scale1 = self.t1.parameter
bc.cont1 = self.Object.Proxy.getContinuity(self.c1.text[0])
v = Part.Vertex(self.m2.point)
proj = v.distToShape(self.m2.snap_shape)[1][0][1]
bc.param2 = e2.Curve.parameter(proj)
#bc.param2 = (pa2 - self.m2.snap_shape.FirstParameter) / (self.m2.snap_shape.LastParameter - self.m2.snap_shape.FirstParameter)
bc.scale2 = self.t2.parameter
bc.cont2 = self.Object.Proxy.getContinuity(self.c2.text[0])
bc.maxDegree = self.Object.DegreeMax
bc.compute()
self.Object.Shape = bc.Curve.toShape()
return bc
示例5: __init__
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def __init__(self, points, sh=None):
super(MarkerOnShape, self).__init__(points, True)
self._shape = None
self._sublink = None
self._tangent = None
self._translate = coin.SoTranslation()
self._text_font = coin.SoFont()
self._text_font.name = "Arial:Bold"
self._text_font.size = 13.0
self._text = coin.SoText2()
self._text_switch = coin.SoSwitch()
self._text_switch.addChild(self._translate)
self._text_switch.addChild(self._text_font)
self._text_switch.addChild(self._text)
self.on_drag_start.append(self.add_text)
self.on_drag_release.append(self.remove_text)
self.addChild(self._text_switch)
if isinstance(sh,Part.Shape):
self.snap_shape = sh
elif isinstance(sh,(tuple,list)):
self.sublink = sh
示例6: __init__
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def __init__(self, points, sh=None):
super(MarkerOnShape, self).__init__(points, True)
self._shape = None
self._sublink = None
self._tangent = None
self._text_translate = coin.SoTranslation()
self._text = coin.SoText2()
self._text_switch = coin.SoSwitch()
self._text_switch.addChild(self._text_translate)
self._text_switch.addChild(self._text)
self.on_drag_start.append(self.add_text)
self.on_drag_release.append(self.remove_text)
self.addChild(self._text_switch)
if isinstance(sh,Part.Shape):
self.snap_shape = sh
elif isinstance(sh,(tuple,list)):
self.sublink = sh
示例7: get_guide_params
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def get_guide_params():
sel = Gui.Selection.getSelectionEx()
pts = list()
for so in sel:
pts.extend(so.PickedPoints)
edges = list()
for so in sel:
for sen in so.SubElementNames:
n = eval(sen.lstrip("Edge"))
e = so.Object.Shape.Edges[n-1]
edges.append(e)
inter = list()
for pt in pts:
sol = None
min = 1e50
for e in edges:
d,points,info = e.distToShape(Part.Vertex(pt))
if d < min:
min = d
sol = [e,e.Curve.parameter(points[0][0])]
inter.append(sol)
return(inter)
示例8: Activated
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def Activated(self):
doc = FreeCAD.ActiveDocument
sketch, face_link = self.get_selection()
if not sketch and not face_link:
FreeCAD.Console.PrintMessage("Please select a face (in the 3D view) or a sketch\n")
return
if not sketch:
sketch = doc.addObject('Sketcher::SketchObject','Mapped_Sketch')
sketch.Support = face_link
n = eval(face_link[1][0].lstrip('Face'))
fa = face_link[0].Shape.Faces[n-1]
build_sketch(sketch, fa)
doc.recompute()
sos = doc.addObject("Part::FeaturePython","Sketch On Surface")
sketchOnSurface(sos)
sos.Sketch = sketch
sosVP(sos.ViewObject)
doc.recompute()
sketch.ViewObject.Visibility = False
示例9: run_FreeCAD_Nurbs
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def run_FreeCAD_Nurbs(self):
#shape=FreeCAD.ActiveDocument.Cone.Shape.Face1
#shape=FreeCAD.ActiveDocument.Sphere.Shape.Face1
shape=self.getPinObject("shape")
if shape is None:
sayErOb(self,"no shape")
return
return
n=shape.toNurbs()
say(n.Faces)
say(n.Edges)
sf=n.Face1.Surface
ssff=Part.BSplineSurface()
ssff.buildFromPolesMultsKnots(sf.getPoles(),
sf.getUMultiplicities(), sf.getVMultiplicities(),
sf.getUKnots(),sf.getVKnots(),False,False,sf.UDegree,sf.VDegree)
ff=ssff.toShape()
self.setPinObject("Shape_out",ff)
示例10: mapEdgesLines
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def mapEdgesLines( uvedges,face):
if face == None:
sayW("no face")
return Part.Shape()
col=[]
say("face",face)
umin,umax,vmin,vmax=face.ParameterRange
sf=face.Surface
for edge in uvedges:
ua,va,ub,vb=edge
ua=umin+ua*(umax-umin)
va=vmin+va*(vmax-vmin)
ub=umin+ub*(umax-umin)
vb=vmin+vb*(vmax-vmin)
pa=sf.value(ua,va)
pb=sf.value(ub,vb)
say(pa)
col += [Part.makePolygon([pa,pb])]
shape=Part.Compound(col)
return shape
示例11: cylindricprojection
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def cylindricprojection(self,*args, **kwargs):
s=App.activeDocument().ReflectLines001.Shape
eds=[]
for e in s.Edges:
pts2=[]
pts=e.discretize(100)
for p in pts:
h=p.y
arc=np.arctan2(p.x,p.z)
r=FreeCAD.Vector(p.x,p.z).Length
R=150
p2=FreeCAD.Vector(np.sin(arc)*R,h,np.cos(arc)*R)
pts2 += [p2]
Part.show(Part.makePolygon(pts2))
#--------------------------
示例12: __init__
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def __init__(self, obj,name="valve",fileName='ballDN15.stp',ports='0:0:0'):
#obj.Proxy = self
super(AnyThing,self).__init__(obj)
# define common properties
obj.PType="Any"
# define specific properties
obj.addProperty("App::PropertyString","FileName","AnyThing","The file of the shape (inside ./shapes)").FileName=fileName
portslist=list()
if ports:
for port in ports.split('/'):
portslist.append(FreeCAD.Vector([float(i) for i in port.split(":")]))
obj.Ports=portslist
if fileName:
s=Part.Shape()
path=join(dirname(abspath(__file__)),"shapes",fileName)
if exists(path):
s.read(path)
obj.Shape=s
else:
FreeCAD.Console.PrintError("%s file doesn't exist" %fileName)
示例13: rotate
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def rotate(self, startVector, endVector, angleDegrees):
"""
Rotates a shape around an axis
:param startVector: start point of rotation axis either a 3-tuple or a Vector
:param endVector: end point of rotation axis, either a 3-tuple or a Vector
:param angleDegrees: angle to rotate, in degrees
:return: a copy of the shape, rotated
"""
if type(startVector) == tuple:
startVector = Vector(startVector)
if type(endVector) == tuple:
endVector = Vector(endVector)
tmp = self.wrapped.copy()
tmp.rotate(startVector.wrapped, endVector.wrapped, angleDegrees)
return Shape.cast(tmp)
示例14: transformGeometry
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def transformGeometry(self, tMatrix):
"""
tMatrix is a matrix object.
returns a copy of the object, but with geometry transformed instead of just
rotated.
WARNING: transformGeometry will sometimes convert lines and circles to splines,
but it also has the ability to handle skew and stretching transformations.
If your transformation is only translation and rotation, it is safer to use transformShape,
which doesn't change the underlying type of the geometry, but cannot handle skew transformations
"""
tmp = self.wrapped.copy()
tmp = tmp.transformGeometry(tMatrix)
return Shape.cast(tmp)
示例15: sweep
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Shape [as 别名]
def sweep(cls, outerWire, innerWires, path, makeSolid=True, isFrenet=False):
"""
Attempt to sweep the list of wires into a prismatic solid along the provided path
:param outerWire: the outermost wire
:param innerWires: a list of inner wires
:param path: The wire to sweep the face resulting from the wires over
:return: a Solid object
"""
# FreeCAD allows this in one operation, but others might not
freeCADWires = [outerWire.wrapped]
for w in innerWires:
freeCADWires.append(w.wrapped)
# f = FreeCADPart.Face(freeCADWires)
wire = FreeCADPart.Wire([path.wrapped])
result = wire.makePipeShell(freeCADWires, makeSolid, isFrenet)
return Shape.cast(result)