當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。