当前位置: 首页>>代码示例>>Python>>正文


Python Part.Face方法代码示例

本文整理汇总了Python中Part.Face方法的典型用法代码示例。如果您正苦于以下问题:Python Part.Face方法的具体用法?Python Part.Face怎么用?Python Part.Face使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Part的用法示例。


在下文中一共展示了Part.Face方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: isPlanar

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def isPlanar(obj):
    if isCircularEdge(obj):
        return True
    shape = getElementShape(obj,Part.Face)
    if not shape:
        return False
    elif str(shape.Surface) == '<Plane object>':
        return True
    elif hasattr(shape.Surface,'Radius'):
        return False
    elif str(shape.Surface).startswith('<SurfaceOfRevolution'):
        return False
    else:
        _plane_norm,_plane_pos,error = fit_plane_to_surface1(shape.Surface)
        error_normalized = error / shape.BoundBox.DiagonalLength
        return error_normalized < 10**-6 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:18,代码来源:utils.py

示例2: Activated

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def Activated(self):
        faces = []
        sel = FreeCADGui.Selection.getSelectionEx()
        if sel == []:
            FreeCAD.Console.PrintError("Select some faces first !\n")
        for selobj in sel:
            if selobj.HasSubObjects:
                for i in range(len(selobj.SubObjects)):
                    if isinstance(selobj.SubObjects[i], Part.Face):
                        faces.append((selobj.Object, selobj.SubElementNames[i]))
            elif selobj.Object.Shape.Faces:
                for i in range(len(selobj.Object.Shape.Faces)):
                    faces.append((selobj.Object, "Face%d"%i))
                selobj.Object.ViewObject.Visibility = False
        if faces:
            self.makeSolidFeature(faces) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:18,代码来源:parametricSolid.py

示例3: __init__

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def __init__(self, face, direc = 'U', param = 0):
        self.face = None
        self.direction = 'U'
        self.parameter = 0
        if not isinstance(face, Part.Face):
            FreeCAD.Console.PrintMessage("Error. Not a face")
        else:
            self.bounds = face.ParameterRange
            self.face = face
        if not direc in 'UV':
            FreeCAD.Console.PrintMessage("Direction error")
        else:
            self.direction = direc
        if not isinstance(param, (float, int)):
            FreeCAD.Console.PrintMessage("Parameter error")
        else:
            self.parameter = param 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:19,代码来源:isocurves.py

示例4: Activated

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def Activated(self):
        s = FreeCADGui.Selection.getSelectionEx()
        vector, selObj1 = self.findVector(s)
        trimmingCurve, selObj2 = self.findCurve(selObj1[::-1])
        faces = self.findFaces(selObj2)
        
        if trimmingCurve and faces:
            for f in faces:
                obj=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","TrimmedFace") #add object to document
                trimFace(obj)
                trimFaceVP(obj.ViewObject)
                obj.Face = f[0]
                obj.Face[0].ViewObject.Visibility=False
                obj.PickedPoint = f[1]
                obj.Tool = trimmingCurve
                #obj.Tool[0].ViewObject.Visibility=False
                if vector:
                    obj.DirVector = vector
                    obj.DirVector.ViewObject.Visibility=False
                else:
                    obj.Direction = FreeCADGui.ActiveDocument.ActiveView.getViewDirection()
        
        FreeCAD.ActiveDocument.recompute() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:25,代码来源:TrimFace.py

示例5: __init__

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def __init__(self, obj):
        ''' Add the properties '''
        obj.addProperty("App::PropertyLinkSub",    "InputEdge",      "CurveOnSurface",   "Input edge")
        obj.addProperty("App::PropertyLinkSub",    "Face",           "CurveOnSurface",   "Support face")
        obj.addProperty("App::PropertyFloat",      "Tolerance",      "CurveOnSurface",   "Tolerance").Tolerance=0.0001
        obj.addProperty("App::PropertyBool",       "ReverseTangent", "Orientation",   "Reverse tangent").ReverseTangent = False
        obj.addProperty("App::PropertyBool",       "ReverseNormal",  "Orientation",   "Reverse normal").ReverseNormal = False
        obj.addProperty("App::PropertyBool",       "ReverseBinormal","Orientation",   "Reverse binormal").ReverseBinormal = False
        #obj.addProperty("Part::PropertyPartShape", "Shape",          "Base",   "Shape")
        obj.addProperty("App::PropertyEnumeration","Output",         "CurveOnSurface",   "Output type").Output = ["Curve only","Normal face","Binormal face"]
        obj.addProperty("App::PropertyInteger",    "Samples",        "CurveOnSurface", "Number of samples").Samples=100
        obj.addProperty("App::PropertyDistance",   "FaceWidth",      "CurveOnSurface", "Width of the output face").FaceWidth='1mm'
        obj.addProperty("App::PropertyBool",       "Symmetric",      "CurveOnSurface", "Face symmetric across curve").Symmetric = False
        obj.addProperty("App::PropertyBool",       "Closed",         "CurveOnSurface", "Close the curve").Closed = False
        obj.addProperty("App::PropertyBool",       "Reverse",        "CurveOnSurface", "Reverse the parametric orientation of the curve").Reverse = False
        obj.Output = "Curve only"
        obj.Proxy = self 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:19,代码来源:curveOnSurfaceFP.py

示例6: execute

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def execute(self, obj):
        edge = _utils.getShape(obj, 'InputEdge', 'Edge') # self.getEdge(obj)
        face = _utils.getShape(obj, 'Face', 'Face') # self.getFace(obj)
        
        cos = curveOnSurface.curveOnSurface(edge, face)
        if obj.Reverse:
            cos.reverse()
        if obj.Closed:
            cos.closed = True
        cos.reverseTangent = obj.ReverseTangent
        cos.reverseNormal = obj.ReverseNormal
        cos.reverseBinormal = obj.ReverseBinormal
        if obj.Output == "Normal face":
            obj.Shape = cos.normalFace(obj.Samples, float(obj.FaceWidth), obj.Tolerance, obj.Symmetric)
        elif obj.Output == "Binormal face":
            obj.Shape = cos.binormalFace(obj.Samples, float(obj.FaceWidth), obj.Tolerance, obj.Symmetric)
        else:
            obj.Shape = cos.getEdge()
        #obj.Placement.Base = face.Placement.Base
        return(cos) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:22,代码来源:curveOnSurfaceFP.py

示例7: Activated

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def Activated(self):
        search_type = Part.Face
        result = list()
        obj = None
        s = FreeCADGui.Selection.getSelectionEx()
        FreeCADGui.Selection.clearSelection()
        subs = list()
        for selo in s:
            if selo.HasSubObjects:
                obj = selo.Object
                shape = obj.Shape.copy()
                for subname in selo.SubElementNames:
                    sub = shape.getElement(subname)
                    if isinstance(sub, Part.Face):
                        subs += sub.Edges
                    else:
                        subs.append(sub)
                for sub in subs:
                    anc = shape.ancestorsOfType(sub, search_type)
                    result += anc
                    for a in anc:
                        FreeCADGui.Selection.addSelection(obj, self.get_subname(shape, a)) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:24,代码来源:adjacent_faces.py

示例8: build_faces

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def build_faces(self, wl, face):
        faces = []
        bs = BoundarySorter(wl, True)
        for i, wirelist in enumerate(bs.sort()):
            #print(wirelist)
            f = Part.Face(face, wirelist[0])
            if not f.isValid():
                debug("{:3}:Invalid initial face".format(i))
                f.validate()
            if len(wirelist) > 1:
                f.cutHoles(wirelist[1:])
                f.validate()
            if not f.isValid():
                debug("{:3}:Invalid final face".format(i))
            faces.append(f)
        return faces 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:18,代码来源:Sketch_On_Surface.py

示例9: Activated

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [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 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:21,代码来源:Sketch_On_Surface.py

示例10: execute

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def execute(self, fp):
    base=Part.Face(Part.Wire(Part.makeCircle(fp.D/2)))
    if fp.d>0:
      base=base.cut(Part.Face(Part.Wire(Part.makeCircle(fp.d/2))))
    if fp.n>0:
      hole=Part.Face(Part.Wire(Part.makeCircle(fp.f/2,FreeCAD.Vector(fp.df/2,0,0),FreeCAD.Vector(0,0,1))))
      hole.rotate(FreeCAD.Vector(0,0,0),FreeCAD.Vector(0,0,1),360.0/fp.n/2)
      for i in list(range(fp.n)):
        base=base.cut(hole)
        hole.rotate(FreeCAD.Vector(0,0,0),FreeCAD.Vector(0,0,1),360.0/fp.n)
    flange = base.extrude(FreeCAD.Vector(0,0,fp.t))
    try: # Flange2: raised-face and welding-neck
      if fp.trf>0 and fp.drf>0:
        rf=Part.makeCylinder(fp.drf/2,fp.trf,vO,vZ*-1).cut(Part.makeCylinder(fp.d/2,fp.trf,vO,vZ*-1))
        flange=flange.fuse(rf)
      if fp.dwn>0 and fp.twn>0 and fp.ODp>0:
        wn=Part.makeCone(fp.dwn/2,fp.ODp/2,fp.twn,vZ*float(fp.t)).cut(Part.makeCylinder(fp.d/2,fp.twn,vZ*float(fp.t)))
        flange=flange.fuse(wn)
    except:
      pass
    fp.Shape = flange
    fp.Ports=[FreeCAD.Vector(),FreeCAD.Vector(0,0,float(fp.t))]
    super(Flange,self).execute(fp) # perform common operations 
开发者ID:oddtopus,项目名称:flamingo,代码行数:25,代码来源:pipeFeatures.py

示例11: isOrtho

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def isOrtho(e1=None,e2=None):
  '"True" if two Edges or Vectors or the normal of Faces are orthogonal (with a margin)'
  v=[]
  if (e1==None or e2==None):
    if len(faces())>1:
      e1,e2=faces()[:2]
    elif len(edges())>1:
      e1,e2=edges()[:2]
  for e in [e1,e2]:
    if hasattr(e,'ShapeType'):
      if e.ShapeType=='Edge':
        v.append(e.tangentAt(0))
      elif e.ShapeType=='Face':
        v.append(e.normalAt(0,0))
    else:
      v.append(e)
  return round(v[0].dot(v[1]),2)==0 
开发者ID:oddtopus,项目名称:flamingo,代码行数:19,代码来源:frameCmd.py

示例12: isParallel

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def isParallel(e1=None,e2=None):
  '"True" if two Edges or Vectors or the normal of Faces are parallel (with a margin)'
  v=[]
  if (e1==None or e2==None):
    if len(faces())>1:
      e1,e2=faces()[:2]
    elif len(edges())>1:
      e1,e2=edges()[:2]
  for e in [e1,e2]:
    if hasattr(e,'ShapeType'):
      if e.ShapeType=='Edge':
        v.append(e.tangentAt(0))
      elif e.ShapeType=='Face':
        v.append(e.normalAt(0,0))
    else:
      v.append(e)
  return round(v[0].cross(v[1]).Length,2)==0 #v[0].cross(v[1]).Length==0 
开发者ID:oddtopus,项目名称:flamingo,代码行数:19,代码来源:frameCmd.py

示例13: makeSquareTool

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def makeSquareTool(s, m):
  # makes a cylinder with an inner square hole, used as cutting tool
  # create square face
  msq = Base.Matrix()
  msq.rotateZ(math.radians(90.0))
  polygon = []
  vsq = Base.Vector(s / 2.0, s / 2.0, -m * 0.1)
  for i in range(4):
     polygon.append(vsq)
     vsq = msq.multiply(vsq)
  polygon.append(vsq)
  square = Part.makePolygon(polygon)
  square = Part.Face(square)

  # create circle face
  circ = Part.makeCircle(s * 3.0, Base.Vector(0.0, 0.0, -m * 0.1))
  circ = Part.Face(Part.Wire(circ))

  # Create the face with the circle as outline and the square as hole
  face=circ.cut(square)
 
  # Extrude in z to create the final cutting tool
  exSquare = face.extrude(Base.Vector(0.0, 0.0, m * 1.2))
  # Part.show(exHex)
  return exSquare 
开发者ID:shaise,项目名称:FreeCAD_FastenersWB,代码行数:27,代码来源:FSNuts.py

示例14: calcInitialValues

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def calcInitialValues(self):
        if self.sub1.startswith('Face'):
            plane1 = getObjectFaceFromName(self.ob1, self.sub1)
        elif self.sub1.startswith('Edge'):
            #print(self.sub1)
            plane1 = Part.Face(Part.Wire(getObjectEdgeFromName(self.ob1, self.sub1)))
        if self.sub2.startswith('Face'):
            plane2 = getObjectFaceFromName(self.ob2, self.sub2)
        elif self.sub2.startswith('Edge'):
            plane2 = Part.Face(Part.Wire(getObjectEdgeFromName(self.ob2, self.sub2)))
        #plane2 = getObjectFaceFromName(self.ob2, self.sub2)
        axis1 = a2plib.getPlaneNormal(plane1.Surface)
        axis2 = a2plib.getPlaneNormal(plane2.Surface)
        angle = math.degrees(axis1.getAngle(axis2))
        if angle <= 90.0:
            self.direction = "aligned"
        else:
            self.direction = "opposed"
        self.offset = 0.0
        self.lockRotation = False 
开发者ID:kbwbe,项目名称:A2plus,代码行数:22,代码来源:a2p_constraints.py

示例15: recalculateMatingDirection

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Face [as 别名]
def recalculateMatingDirection(c):
        ob1 = c.Document.getObject(c.Object1)
        ob2 = c.Document.getObject(c.Object2)
        if c.SubElement1.startswith('Face'):
            plane1 = getObjectFaceFromName(ob1, c.SubElement1)
        elif c.SubElement1.startswith('Edge'):
            #print(self.sub1)
            plane1 = Part.Face(Part.Wire(getObjectEdgeFromName(ob1, c.SubElement1)))
        if c.SubElement2.startswith('Face'):
            plane2 = getObjectFaceFromName(ob2, c.SubElement2)
        elif c.SubElement2.startswith('Edge'):
            plane2 = Part.Face(Part.Wire(getObjectEdgeFromName(ob2, c.SubElement2)))
        axis1 = a2plib.getPlaneNormal(plane1.Surface)
        axis2 = a2plib.getPlaneNormal(plane2.Surface)
        angle = math.degrees(axis1.getAngle(axis2))
        if angle <= 90.0:
            c.directionConstraint = "aligned"
        else:
            c.directionConstraint = "opposed" 
开发者ID:kbwbe,项目名称:A2plus,代码行数:21,代码来源:a2p_constraints.py


注:本文中的Part.Face方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。