Python Part.Face() Examples
The following are 30
code examples of Part.Face().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
Part
, or try the search function
.
Example #1
Source File: shapes.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def geomType(self): """ Gets the underlying geometry type :return: a string according to the geometry type. Implementations can return any values desired, but the values the user uses in type filters should correspond to these. As an example, if a user does:: CQ(object).faces("%mytype") The expectation is that the geomType attribute will return 'mytype' The return values depend on the type of the shape: Vertex: always 'Vertex' Edge: LINE, ARC, CIRCLE, SPLINE Face: PLANE, SPHERE, CONE Solid: 'Solid' Shell: 'Shell' Compound: 'Compound' Wire: 'Wire' """ return self.wrapped.ShapeType
Example #2
Source File: isocurves.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
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
Example #3
Source File: a2p_constraints.py From A2plus with GNU Lesser General Public License v2.1 | 6 votes |
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
Example #4
Source File: a2p_constraints.py From A2plus with GNU Lesser General Public License v2.1 | 6 votes |
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"
Example #5
Source File: FSNuts.py From FreeCAD_FastenersWB with GNU General Public License v2.0 | 6 votes |
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
Example #6
Source File: TrimFace.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
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()
Example #7
Source File: curveOnSurfaceFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
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
Example #8
Source File: curveOnSurfaceFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
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)
Example #9
Source File: parametricSolid.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
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)
Example #10
Source File: frameCmd.py From flamingo with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #11
Source File: TestCadObjects.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def testIntersect(self): """ Tests finding the intersection of two faces. """ # Face 1 edge1 = Part.makeLine((0, 0, 0), (0, 10, 0)) edge2 = Part.makeLine((0, 10, 0), (10, 10, 0)) edge3 = Part.makeLine((10, 10, 0), (10, 0, 0)) edge4 = Part.makeLine((10, 0, 0), (0, 0, 0)) wire1 = Part.Wire([edge1,edge2,edge3,edge4]) face1 = Part.Face(wire1) cqFace1 = Face(face1) # Face 2 (face to cut out of face 1) edge1 = Part.makeCircle(4.0) wire1 = Part.Wire([edge1]) face2 = Part.Face(wire1) cqFace2 = Face(face2) # Face resulting from the intersection cqFace3 = cqFace1.intersect(cqFace2) self.assertEquals(len(cqFace3.Faces()), 1) self.assertEquals(len(cqFace3.Edges()), 3)
Example #12
Source File: adjacent_faces.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
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))
Example #13
Source File: Sketch_On_Surface.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
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
Example #14
Source File: frameCmd.py From flamingo with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #15
Source File: Sketch_On_Surface.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
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
Example #16
Source File: pipeFeatures.py From flamingo with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #17
Source File: shapes.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
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)
Example #18
Source File: SheetMetalBend.py From FreeCAD_SheetMetal with GNU General Public License v3.0 | 6 votes |
def updateElement(self): if self.obj: sel = FreeCADGui.Selection.getSelectionEx()[0] if sel.HasSubObjects: obj = sel.Object for elt in sel.SubElementNames: if "Face" in elt or "Edge" in elt: face = self.obj.baseObject found = False if (face[0] == obj.Name): if isinstance(face[1],tuple): for subf in face[1]: if subf == elt: found = True else: if (face[1][0] == elt): found = True if not found: self.obj.baseObject = (sel.Object, sel.SubElementNames) self.update()
Example #19
Source File: shapes.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def makePlane(cls, length, width, basePnt=(0, 0, 0), dir=(0, 0, 1)): basePnt = Vector(basePnt) dir = Vector(dir) return Face(FreeCADPart.makePlane(length, width, basePnt.wrapped, dir.wrapped))
Example #20
Source File: frameCmd.py From flamingo with GNU Lesser General Public License v3.0 | 5 votes |
def extendTheBeam(beam,target): '''arg1=beam, arg2=target: extend the beam to a plane, normal to its axis, defined by target. If target is a Vertex or a Vector, the plane is the one that includes the point defined by target. If target is a Face, the plane is the one that includes the intersection between the axis of beam and the plane of the face. Else, the plane is the one normal to the axis of beam that includes the CenterOfMass of target''' distBase=distTop=0 vBase=beam.Placement.Base vBeam=beamAx(beam) h=beam.Height vTop=vBase+vBeam.multiply(h) if type(target)==FreeCAD.Vector: distBase=vBase.distanceToPlane(target,vBeam) distTop=vTop.distanceToPlane(target,vBeam) elif target.ShapeType=="Vertex": distBase=vBase.distanceToPlane(target.Point,vBeam) distTop=vTop.distanceToPlane(target.Point,vBeam) elif target.ShapeType=="Face": if not isOrtho(target,vBeam): from Part import Point Pint=Point(intersectionPlane(beam.Placement.Base,beamAx(beam),target)).toShape() distBase=vBase.distanceToPlane(Pint.Point,vBeam) distTop=vTop.distanceToPlane(Pint.Point,vBeam) elif hasattr(target,"CenterOfMass"): distBase=vBase.distanceToPlane(target.CenterOfMass,vBeam) distTop=vTop.distanceToPlane(target.CenterOfMass,vBeam) if distBase*distTop>0: if abs(distBase)>abs(distTop): beam.Height+=FreeCAD.Units.Quantity(str(abs(distTop))+"mm") else: beam.Height+=FreeCAD.Units.Quantity(str(abs(distBase))+"mm") vMove=vBeam.normalize().multiply(-distBase) beam.Placement.move(vMove) else: if abs(distBase)>abs(distTop): beam.Height-=FreeCAD.Units.Quantity(str(abs(distTop))+"mm") else: beam.Height-=FreeCAD.Units.Quantity(str(abs(distBase))+"mm") vMove=vBeam.normalize().multiply(-distBase) beam.Placement.move(vMove) #FreeCAD.activeDocument().recompute()
Example #21
Source File: shapes.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def Faces(self): return [Face(i) for i in self.wrapped.Faces]
Example #22
Source File: shapes.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def geomType(self): t = type(self.wrapped.Surface) if t in self.facetypes: return self.facetypes[t] else: return "Unknown Face Surface Type: %s" % str(t)
Example #23
Source File: shapes.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def Area(self): """ Returns the area of a shape, but only if it is a face """ if self.wrapped.ShapeType == 'Face': return self.wrapped.Area else: raise ValueError("shape type must be 'Face' to calculate the area")
Example #24
Source File: frameFeatures.py From flamingo with GNU Lesser General Public License v3.0 | 5 votes |
def updateSections(self): self.sectList.clear() result=FreeCAD.ActiveDocument.findObjects("App::DocumentObjectGroup","Profiles_set") if result: self.sectList.addItems([o.Label for o in result[0].OutList if hasattr(o,'Shape') and ((type(o.Shape)==Part.Wire and o.Shape.isClosed()) or (type(o.Shape)==Part.Face and type(o.Shape.Surface)==Part.Plane))]) if self.sectList.count(): self.sectList.setCurrentRow(0) else: FreeCAD.Console.PrintError('No set of profiles in this document.\nCreate the sections first.\n')
Example #25
Source File: frameCmd.py From flamingo with GNU Lesser General Public License v3.0 | 5 votes |
def rotTheBeam(beam,faceBase,faceAlign): '''arg1=beam, arg2=faceBase, arg3=faceToMakeParallel: rotate the beams to make the flanges parallel to that of first selection.''' from Part import Face if type(faceBase)==Face: n1=faceBase.normalAt(0,0) elif type(faceBase)==FreeCAD.Base.Vector: n1=faceBase n2=faceAlign.normalAt(0,0) rot=FreeCAD.Rotation(n2,n1) beam.Placement.Rotation=rot.multiply(beam.Placement.Rotation)
Example #26
Source File: frameCmd.py From flamingo with GNU Lesser General Public License v3.0 | 5 votes |
def intersectionPlane(base=None,v=None,face=None): ''' intersectionPlane(base,v,face) Returns the point (vector) at the intersection of a line and a plane. base (vector): the base point to be projected v (vector): the direction of the line that intersect the plane face (Face): the face that defines the plane to be intersect ''' # only for quick testing: if base==v==face==None: face = faces()[0] beam=beams()[0] base=beam.Placement.Base v=beamAx(beam) if isOrtho(v,face): FreeCAD.Console.PrintError('Direction of projection and Face are parallel.\n') return None else: # equation of plane: ax+by+cz+d=0 a,b,c=list(face.normalAt(0,0)) d=-face.CenterOfMass.dot(face.normalAt(0,0)) #FreeCAD.Console.PrintMessage('a=%.2f b=%.2f c=%.2f d=%.2f\n' %(a,b,c,d)) ## definition of line #FreeCAD.Console.PrintMessage('base=(%.2f,%.2f,%.2f)\n' %(base.x,base.y,base.z)) #FreeCAD.Console.PrintMessage('v=(%.2f,%.2f,%.2f)\n' %(v.x,v.y,v.z)) ##intersection k=-1*(a*base.x+b*base.y+c*base.z+d)/(a*v.x+b*v.y+c*v.z) #FreeCAD.Console.PrintMessage('k=%f\n' %float(k)) P=base+v*k return rounded(P)
Example #27
Source File: pipeFeatures.py From flamingo with GNU Lesser General Public License v3.0 | 5 votes |
def execute(self, fp): fp.thread="M"+str(float(fp.d)) c=Part.makeCircle(fp.C/2,FreeCAD.Vector(0,0,0),FreeCAD.Vector(0,0,1),0,180) l1=Part.makeLine((fp.C/2,0,0),(fp.C/2,fp.C/2-fp.H,0)) l2=Part.makeLine((-fp.C/2,0,0),(-fp.C/2,fp.C/2-fp.H,0)) p=Part.Face(Part.Wire(Part.makeCircle(fp.d/2,c.valueAt(c.FirstParameter),c.tangentAt(c.FirstParameter)))) path=Part.Wire([c,l1,l2]) fp.Shape=path.makePipe(p) fp.Ports=[FreeCAD.Vector(0,0,1)]
Example #28
Source File: pipeFeatures.py From flamingo with GNU Lesser General Public License v3.0 | 5 votes |
def execute(self, fp): if fp.BendAngle<180: if fp.thk>fp.OD/2: fp.thk=fp.OD/2 fp.ID=fp.OD-2*fp.thk fp.Profile=str(fp.OD)+"x"+str(fp.thk) CenterOfBend=FreeCAD.Vector(fp.BendRadius,fp.BendRadius,0) ## make center-line ## R=Part.makeCircle(fp.BendRadius,CenterOfBend,FreeCAD.Vector(0,0,1),225-float(fp.BendAngle)/2,225+float(fp.BendAngle)/2) ## move the cl so that Placement.Base is the center of elbow ## from math import pi, cos, sqrt d=(fp.BendRadius*sqrt(2)-fp.BendRadius/cos(fp.BendAngle/180*pi/2)) P=FreeCAD.Vector(-d*cos(pi/4),-d*cos(pi/4),0) R.translate(P) ## calculate Ports position ## fp.Ports=[R.valueAt(R.FirstParameter),R.valueAt(R.LastParameter)] ## make the shape of the elbow ## c=Part.makeCircle(fp.OD/2,fp.Ports[0],R.tangentAt(R.FirstParameter)*-1) b=Part.makeSweepSurface(R,c) p1=Part.Face(Part.Wire(c)) p2=Part.Face(Part.Wire(Part.makeCircle(fp.OD/2,fp.Ports[1],R.tangentAt(R.LastParameter)))) sol=Part.Solid(Part.Shell([b,p1,p2])) planeFaces=[f for f in sol.Faces if type(f.Surface)==Part.Plane] #elbow=sol.makeThickness(planeFaces,-fp.thk,1.e-3) #fp.Shape = elbow if fp.thk<fp.OD/2: fp.Shape=sol.makeThickness(planeFaces,-fp.thk,1.e-3) else: fp.Shape=sol super(Elbow,self).execute(fp) # perform common operations
Example #29
Source File: frameFeatures.py From flamingo with GNU Lesser General Public License v3.0 | 5 votes |
def trim(self): FreeCAD.ActiveDocument.openTransaction('Trim FB') for target in self.targets: for b in frameCmd.beams(): if hasattr(b,'tailOffset') and hasattr(b,'headOffset'): edge=b.Support[0][0].Shape.getElement(b.Support[0][1][0]) ax=edge.tangentAt(0).normalize() #frameCmd.beamAx(b).normalize() tail=edge.valueAt(0) #b.Placement.Base head=edge.valueAt(edge.LastParameter) #tail+ax*float(b.Height) if target.ShapeType=="Vertex": P=target.Point elif target.ShapeType=="Face" and not frameCmd.isOrtho(target,ax): P=frameCmd.intersectionPlane(tail,ax,target) elif hasattr(target,"CenterOfMass"): P=target.CenterOfMass else: P=None if P: #print P #print ax.Length deltaTail=(P-tail).dot(ax) deltaHead=(P-head).dot(ax) #print "D-tail = %.1f; D-head = %.1f" %(deltaTail,deltaHead) if abs(deltaTail)<abs(deltaHead): b.tailOffset=-deltaTail else: b.headOffset=deltaHead refresh() FreeCAD.ActiveDocument.commitTransaction()
Example #30
Source File: utils.py From FreeCAD_assembly3 with GNU General Public License v3.0 | 5 votes |
def isInfinite(shape): # A face without edge or an edge without vertex is considered infinite if shape.countElement('Face'): return not shape.countElement('Edge') elif shape.countElement('Edge'): return not shape.countElement('Vertex')