Python Part.Wire() Examples
The following are 30
code examples of Part.Wire().
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: kicad.py From fcad_pcb with MIT License | 6 votes |
def make_oval(size,params=None): _ = params if size.x == size.y: return make_circle(size) if size.x < size.y: r = size.x*0.5 size.y -= size.x s = ((0,0.5),(-0.5,0.5),(-0.5,-0.5),(0,-0.5),(0.5,-0.5),(0.5,0.5)) a = (0,180,180,360) else: r = size.y*0.5 size.x -= size.y s = ((-0.5,0),(-0.5,-0.5),(0.5,-0.5),(0.5,0),(0.5,0.5),(-0.5,0.5)) a = (90,270,-90,-270) pts = [product(size,Vector(*v)) for v in s] return Part.Wire([ Part.makeCircle(r,pts[0],Vector(0,0,1),a[0],a[1]), Part.makeLine(pts[1],pts[2]), Part.makeCircle(r,pts[3],Vector(0,0,1),a[2],a[3]), Part.makeLine(pts[4],pts[5])])
Example #2
Source File: TestCadObjects.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def testFuse(self): """ Tests fusing one face to another. """ # 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 fuse cqFace3 = cqFace1.fuse(cqFace2) self.assertEquals(len(cqFace3.Faces()), 3) self.assertEquals(len(cqFace3.Edges()), 8)
Example #3
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 #4
Source File: TestCadObjects.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def testWireMakeHelixDefault(self): (pitch, height, radius) = (1., 5., 2.) wire = Wire.makeHelix(pitch=pitch, height=height, radius=radius) edge = wire.Edges()[0] # Assert: helix length is correct # expectation, default is a cylindrical helix helix_horiz = (((2 * pi) * radius) * (height / pitch)) helix_vert = height self.assertAlmostEqual(edge.Length(), sqrt(helix_horiz**2 + helix_vert**2), 4) # Assert: bounding box is accurate # mainly checking that helix is in the positive Z direction. # not happy with the accuracy of BoundingBox (see places=2 below), but that's out of cadquery's scope bb = edge.BoundingBox() self.assertTupleAlmostEquals((bb.xmin, bb.xmax), (-radius, radius), 2) self.assertTupleAlmostEquals((bb.ymin, bb.ymax), (-radius, radius), 2) self.assertTupleAlmostEquals((bb.zmin, bb.zmax), (0, height), 3)
Example #5
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 #6
Source File: Asm4_Measure.py From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 | 6 votes |
def drawLine( self, pt1, pt2, name='aLine', width=3 ): global taskUI if pt1!=pt2: line = Part.makeLine( pt1, pt2 ) wire = App.ActiveDocument.addObject('Part::FeaturePython', name) wire.ViewObject.Proxy = setCustomIcon(wire, taskUI.lineIcon ) wire.Shape = Part.Wire(line) wire.ViewObject.LineWidth = width wire.ViewObject.LineColor = ( 1.0, 1.0, 1.0 ) wire.ViewObject.PointSize = 10 wire.ViewObject.PointColor= ( 0.0, 0.0, 1.0 ) self.addToDims(wire) else: point = App.ActiveDocument.addObject('Part::FeaturePython', 'aPoint') point.ViewObject.Proxy = setCustomIcon(point, taskUI.pointIcon ) point.Shape = Part.Vertex(Part.Point( pt1 )) point.ViewObject.PointSize = 10 point.ViewObject.PointColor= ( 0.0, 0.0, 1.0 ) self.addToDims(point)
Example #7
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 #8
Source File: _utils.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
def ancestors(shape, sub): '''list_of_shapes = ancestors(shape, sub) Returns the closest ancestors of "sub" in "shape"''' def cleanup(shape): s = str(shape) ss = s.split()[0] return ss.split('<')[1] shd = (Part.Vertex, Part.Edge, Part.Wire, Part.Face, Part.Shell, Part.Solid, Part.CompSolid, Part.Compound) for i in range(len(shd)-1): if isinstance(sub, shd[i]): for j in range(i+1,len(shd)): manc = shape.ancestorsOfType(sub, shd[j]) if manc: print("{} belongs to {} {}.".format(cleanup(sub), len(manc), cleanup(manc[0]))) return manc
Example #9
Source File: kicad.py From fcad_pcb with MIT License | 6 votes |
def _makeCustomPad(self, params): wires = [] for key in params.primitives: wire,width = makePrimitve(key, getattr(params.primitives, key)) if not width: if isinstance(wire, Part.Edge): wire = Part.Wire(wire) wires.append(wire) else: wire = Path.Area(Accuracy=self.arc_fit_accuracy,Thicken=wire.isClosed(), Offset=width*0.5).add(wire).getShape() wires += wire.Wires if not wires: return if len(wires) == 1: return wires[0] return Part.makeCompound(wires)
Example #10
Source File: pipeshellProfileFP.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
def execute(self, obj): #curvesWB = FreeCADGui.activeWorkbench() proptype = obj.getTypeIdOfProperty("Profile") if proptype == 'App::PropertyLink': sh = obj.Profile.Shape.copy() mat = obj.Profile.Shape.Placement.toMatrix() obj.Shape = sh.transformGeometry(mat) elif proptype == 'App::PropertyLinkSubList': edges = self.getEdgeList( obj, "Profile") #vert = self.getVertex( obj, "Location") if edges: w = Part.Wire(Part.__sortEdges__(edges)) if w: obj.Shape = w else: FreeCAD.Console.PrintError("\nFailed to build wire\n") else: FreeCAD.Console.PrintError("\nFailed to extract edges\n")
Example #11
Source File: pipeForms.py From flamingo with GNU Lesser General Public License v3.0 | 6 votes |
def getBase(self): if self.combo.currentText()!="<new>": pl=FreeCAD.ActiveDocument.getObjectsByLabel(self.combo.currentText())[0] sel=FreeCADGui.Selection.getSelection() if sel: base=sel[0] isWire=hasattr(base,'Shape') and base.Shape.Edges #type(base.Shape)==Part.Wire isSketch=hasattr(base,'TypeId') and base.TypeId=='Sketcher::SketchObject' if isWire or isSketch: FreeCAD.activeDocument().openTransaction('Assign Base') pl.Base=base if isWire: pipeCmd.drawAsCenterLine(pl.Base) pipeCmd.moveToPyLi(pl.Base,self.combo.currentText()) FreeCAD.activeDocument().commitTransaction() else: FreeCAD.Console.PrintError('Not valid Base: select a Wire or a Sketch.\n') else: pl.Base=None FreeCAD.Console.PrintWarning(pl.Label+'-> deleted Base\n') else: FreeCAD.Console.PrintError('Please choose or create a PypeLine first\n')
Example #12
Source File: SheetMetalCmd.py From FreeCAD_SheetMetal with GNU General Public License v3.0 | 6 votes |
def smMakeReliefFace(edge, dir, gap, reliefW, reliefD, reliefType, op=''): p1 = edge.valueAt(edge.FirstParameter + gap) p2 = edge.valueAt(edge.FirstParameter + gap + reliefW ) if reliefType == "Round" and reliefD > reliefW : p3 = edge.valueAt(edge.FirstParameter + gap + reliefW) + dir.normalize() * (reliefD-reliefW/2) p34 = edge.valueAt(edge.FirstParameter + gap + reliefW/2) + dir.normalize() * reliefD p4 = edge.valueAt(edge.FirstParameter + gap) + dir.normalize() * (reliefD-reliefW/2) e1 = Part.makeLine(p1, p2) e2 = Part.makeLine(p2, p3) e3 = Part.Arc(p3, p34, p4).toShape() e4 = Part.makeLine(p4, p1) else : p3 = edge.valueAt(edge.FirstParameter + gap + reliefW) + dir.normalize() * reliefD p4 = edge.valueAt(edge.FirstParameter + gap) + dir.normalize() * reliefD e1 = Part.makeLine(p1, p2) e2 = Part.makeLine(p2, p3) e3 = Part.makeLine(p3, p4) e4 = Part.makeLine(p4, p1) w = Part.Wire([e1,e2,e3,e4]) face = Part.Face(w) if hasattr(face, 'mapShapes'): face.mapShapes([(edge,face)],[],op) return face
Example #13
Source File: crosspart.py From LCInterlocking with GNU Lesser General Public License v2.1 | 6 votes |
def make_cross_box(length, width, height, node_type, node_thickness): half_length = length / 2.0 p1 = FreeCAD.Vector(half_length, 0, 0) p2 = FreeCAD.Vector(-half_length, 0, 0) p3 = FreeCAD.Vector(-half_length, 0, -height) p4 = FreeCAD.Vector(half_length, 0, -height) l1 = Part.makeLine(p1, p2) l2 = Part.makeLine(p2, p3) l3 = Part.makeLine(p3, p4) l4 = Part.makeLine(p4, p1) wire = Part.Wire([l1,l2,l3,l4]) face = Part.Face(wire) face.translate(FreeCAD.Vector(0, -width / 2.0, 0)) part = face.extrude(FreeCAD.Vector(0, width, 0)) return part
Example #14
Source File: crosspart.py From LCInterlocking with GNU Lesser General Public License v2.1 | 6 votes |
def make_node_xz(width, height, thickness, x_positive = True): p1 = FreeCAD.Vector(0., -thickness/2.0, height / 2.0) p2 = FreeCAD.Vector(0., -thickness/2.0, -height / 2.0) if x_positive is True: pa = FreeCAD.Vector(width, -thickness/2.0, 0.) else: pa = FreeCAD.Vector(-width, -thickness/2.0, 0.) l1 = Part.makeLine(p1, p2) a2 = Part.Arc(p2, pa, p1).toShape() wire = Part.Wire([l1, a2]) face = Part.Face(wire) node = face.extrude(FreeCAD.Vector(0, thickness, 0)) return node
Example #15
Source File: mixed_curve.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
def shape(self): proj1 = self.shape1.toNurbs().extrude(self.dir1) proj2 = self.shape2.toNurbs().extrude(self.dir2) curves = list() for f1 in proj1.Faces: for f2 in proj2.Faces: curves += f1.Surface.intersectSS(f2.Surface) intersect = [c.toShape() for c in curves] edges = [] for sh in intersect: if isinstance(sh, Part.Edge) and sh.Length > 1e-7: edges.append(sh) se = Part.sortEdges(edges) wires = [] for el in se: wires.append(Part.Wire(el)) return Part.Compound(wires)
Example #16
Source File: combined_curve.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
def shape(self): proj1 = self.shape1.toNurbs().extrude(self.dir1) proj2 = self.shape2.toNurbs().extrude(self.dir2) curves = list() for f1 in proj1.Faces: for f2 in proj2.Faces: curves += f1.Surface.intersectSS(f2.Surface) intersect = [c.toShape() for c in curves] edges = [] for sh in intersect: if isinstance(sh, Part.Edge) and sh.Length > 1e-7: edges.append(sh) se = Part.sortEdges(edges) wires = [] for el in se: wires.append(Part.Wire(el)) return Part.Compound(wires)
Example #17
Source File: crosspart.py From LCInterlocking with GNU Lesser General Public License v2.1 | 6 votes |
def make_node_yz(width, height, thickness, x_positive = True): p1 = FreeCAD.Vector(-thickness/2.0, 0, height / 2.0) p2 = FreeCAD.Vector(-thickness/2.0, 0, -height / 2.0) if x_positive is True: pa = FreeCAD.Vector(-thickness/2.0, width, 0.) else: pa = FreeCAD.Vector(-thickness/2.0, -width, 0.) l1 = Part.makeLine(p1, p2) a2 = Part.Arc(p2, pa, p1).toShape() wire = Part.Wire([l1, a2]) face = Part.Face(wire) node = face.extrude(FreeCAD.Vector(thickness, 0, 0)) return node # noeud court = 1/4 hauteur # noeud long = 1/2 hauteur # 2 neouds court = 2 * 1/4 hauteur espace de 16 % de la hateur au centre
Example #18
Source File: makehinges.py From LCInterlocking with GNU Lesser General Public License v2.1 | 6 votes |
def draw_rounded_hinge(hinge_width, hinge_length, height): half_w = hinge_width/2.0 half_l = hinge_length/2.0 half_h = height / 2.0 z_plane = -half_h v1 = FreeCAD.Vector(-half_w, -half_l, z_plane) v2 = FreeCAD.Vector(-half_w, half_l, z_plane) v3 = FreeCAD.Vector(half_w, half_l, z_plane) v4 = FreeCAD.Vector(half_w, -half_l, z_plane) vc1 = FreeCAD.Vector(0, -(half_l + half_w), z_plane) vc2 = FreeCAD.Vector(0, half_l+half_w, z_plane) c1 = Part.Arc(v1, vc1, v4).toShape() c2 = Part.Arc(v2, vc2, v3).toShape() l1 = Part.makeLine(v1, v2) l2 = Part.makeLine(v3, v4) wire = Part.Wire([c1, l1, c2, l2]) hinge = wire.extrude(FreeCAD.Vector(0.0, 0.0, height)) hinge_solid = Part.makeSolid(hinge) return hinge_solid
Example #19
Source File: makeroundedbox.py From LCInterlocking with GNU Lesser General Public License v2.1 | 6 votes |
def create_plane_part(dimension_properties, plane_properties): if plane_properties.position == TopBottomRoundedProperties.POSITION_INSIDE: radius = dimension_properties.inradius side_length = dimension_properties.side_length else: radius = dimension_properties.inradius + plane_properties.radius_outside side_length = dimension_properties.side_length * radius / dimension_properties.inradius edge = create_contours(radius, dimension_properties.nb_face, side_length, dimension_properties.thickness) arcs_segment_list = retrieve_segments_arc(edge) inner_contours, outer_contours = get_contours_with_arc(edge, arcs_segment_list) if plane_properties.position == TopBottomRoundedProperties.POSITION_INSIDE: wire=Part.Wire(inner_contours) else: wire=Part.Wire(outer_contours) face = Part.Face(wire) part = face.extrude(FreeCAD.Vector(0, 0, dimension_properties.thickness)) return part
Example #20
Source File: shapes.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def makePolygon(cls, listOfVertices, forConstruction=False): # convert list of tuples into Vectors. w = Wire(FreeCADPart.makePolygon([i.wrapped for i in listOfVertices])) w.forConstruction = forConstruction return w
Example #21
Source File: kicad.py From fcad_pcb with MIT License | 5 votes |
def findWires(edges): try: return [Part.Wire(e) for e in Part.sortEdges(edges)] except AttributeError: msg = 'Missing Part.sortEdges.'\ 'You need newer FreeCAD (0.17 git 799c43d2)' logger.error(msg) raise AttributeError(msg)
Example #22
Source File: shapes.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def makeRuledSurface(cls, edgeOrWire1, edgeOrWire2, dist=None): """ 'makeRuledSurface(Edge|Wire,Edge|Wire) -- Make a ruled surface Create a ruled surface out of two edges or wires. If wires are used then these must have the same """ return Shape.cast(FreeCADPart.makeRuledSurface(edgeOrWire1.wrapped, edgeOrWire2.wrapped))
Example #23
Source File: shapes.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def makeHelix(cls, pitch, height, radius, angle=0, lefthand=False, heightstyle=False): """ Make a helix along +z axis :param pitch: displacement of 1 turn measured along surface. :param height: full length of helix surface (measured sraight along surface's face) :param radius: starting radius of helix :param angle: if > 0, conical surface is used instead of a cylindrical. (angle < 0 not supported) :param lefthand: if True, helix direction is reversed :param heightstyle: if True, pitch and height are measured parallel to z-axis """ # FreeCAD doc: https://www.freecadweb.org/wiki/Part_API (search for makeHelix) return Wire(FreeCADPart.makeHelix(pitch, height, radius, angle, lefthand, heightstyle))
Example #24
Source File: SheetMetalUnfolder.py From FreeCAD_SheetMetal with GNU General Public License v3.0 | 5 votes |
def __init__(self, f_idx=None, Parent_node= None, Parent_edge = None, k_factor_lookup = None): self.idx = f_idx # Index of the "top-face" self.c_face_idx = None # Face index to the opposite face of the sheet (counter-face) self.node_type = None # 'Flat' or 'Bend' self.p_node = Parent_node # Parent node self.p_edge = Parent_edge # The connecting edge to the parent node self.child_list = [] # List of child-nodes = link to tree structure self.child_idx_lists = [] # List of lists with child_idx and child_edge # need a list of indices of child faces self.sheet_edges = [] # List of edges without child-face self.axis = None # Direction of the axis of the detected cylindrical face self.facePosi = None self.bendCenter = None # Vector of the center of the detected cylindrical face self.distCenter = None # Value used to detect faces at opposite side of the bend self.innerRadius = None # nominal radius of the bend # self.axis for 'Flat'-face: vector pointing from the surface into the metal self.bend_dir = None # Bend direction values: "up" or "down" self.bend_angle = None # Angle in radians self.tan_vec = None # Direction of translation for Bend nodes self.oppositePoint = None # Point of a vertex on the opposite site, used to align points to the sheet plane self.vertexDict = {} # Vertexes of a bend, original and unbend coordinates, flags p, c, t, o self.edgeDict = {} # Unbend edges dictionary, key is a combination of indexes to vertexDict. self._trans_length = None # Length of translation for Bend nodes self.analysis_ok = True # Indicator if something went wrong with the analysis of the face self.error_code = None # Index to unfold_error dictionary self.k_factor_lookup = k_factor_lookup # K-factor lookup dictionary, according to ANSI standard # new node features: self.nfIndexes = [] # List of all face-indexes of a node (flat and bend: folded state) self.seam_edges = [] # List with edges to seams # bend faces are needed for movement simulation at single other bends. # otherwise unfolded faces are recreated from self.b_edges self.node_flattened_faces = [] # Faces of a flattened bend node self.unfoldTopList = None # Source of identical side edges self.unfoldCounterList = None # Source of identical side edges self.actual_angle = None # State of angle in refolded sheet metal part self.p_wire = None # Wire common with parent node, used for bend node self.c_wire = None # Wire common with child node, used for bend node self.b_edges = [] # List of edges in a bend node, that needs to be recalculated, at unfolding
Example #25
Source File: shapes.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def combine(cls, listOfWires): """ Attempt to combine a list of wires into a new wire. the wires are returned in a list. :param cls: :param listOfWires: :return: """ return Shape.cast(FreeCADPart.Wire([w.wrapped for w in listOfWires]))
Example #26
Source File: TestCadObjects.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def testCut(self): """ Tests cutting one face from another. """ # 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.makeLine((0, 0, 0), (0, 5, 0)) edge2 = Part.makeLine((0, 5, 0), (5, 5, 0)) edge3 = Part.makeLine((5, 5, 0), (5, 0, 0)) edge4 = Part.makeLine((5, 0, 0), (0, 0, 0)) wire1 = Part.Wire([edge1,edge2,edge3,edge4]) face2 = Part.Face(wire1) cqFace2 = Face(face2) # Face resulting from cut cqFace3 = cqFace1.cut(cqFace2) self.assertEquals(len(cqFace3.Faces()), 1) self.assertEquals(len(cqFace3.Edges()), 6)
Example #27
Source File: kicad.py From fcad_pcb with MIT License | 5 votes |
def make_gr_circle(params, width=0): center = makeVect(params.center) end = makeVect(params.end) r = center.distanceToPoint(end) if not width or r <= width*0.5: return Part.makeCircle(r+width*0.5, center) return Part.makeCompound([Part.Wire(Part.makeCircle(r+width*0.5,center)), Part.Wire(Part.makeCircle(r-width*0.5,center,Vector(0,0,-1)))])
Example #28
Source File: TestCadObjects.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def testFace(self): """ Test basic face functions, cast and instantiation """ 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) mplanec = Face.cast(face1) mplane = Face(face1) self.assertTupleAlmostEquals((5.0, 5.0, 0.0), mplane.Center().toTuple(), 3)
Example #29
Source File: Asm4_Measure.py From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 | 5 votes |
def drawCircle( self, radius, center, axis ): global taskUI cc = Part.makeCircle( radius, center, axis ) circle = App.ActiveDocument.addObject('Part::FeaturePython', 'aCircle') #circle.ViewObject.Proxy = setCustomIcon(circle,'Draft_Circle.svg') circle.ViewObject.Proxy = setCustomIcon( circle, taskUI.circleIcon ) circle.Shape = Part.Wire( cc ) circle.ViewObject.LineWidth = 5 circle.ViewObject.LineColor = ( 1.0, 1.0, 1.0 ) circle.ViewObject.PointSize = 10 circle.ViewObject.PointColor= ( 0.0, 0.0, 1.0 ) self.addToDims(circle)
Example #30
Source File: newDatumCmd.py From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 | 5 votes |
def Activated(self): ( selectedObj, edge ) = self.getSelection() edgeName = edge.SubElementNames[0] parentPart = selectedObj.getParentGeoFeatureGroup() # if the solid having the edge is indeed in an App::Part if parentPart and (parentPart.TypeId=='App::Part' or parentPart.TypeId=='PartDesign::Body'): # check whether there is already a similar datum, and increment the instance number instanceNum = 1 while App.ActiveDocument.getObject( 'HoleAxis_'+str(instanceNum) ): instanceNum += 1 axis = parentPart.newObject('PartDesign::Line','HoleAxis_'+str(instanceNum)) axis.Support = [( selectedObj, (edgeName,) )] axis.MapMode = 'AxisOfCurvature' axis.MapReversed = False axis.ResizeMode = 'Manual' axis.Length = edge.SubObjects[0].BoundBox.DiagonalLength axis.ViewObject.ShapeColor = (0.0,0.0,1.0) axis.ViewObject.Transparency = 50 ''' pt1 = App.Vector(0,0,diam/2.) pt2 = App.Vector(0,0,-diam/2.) axis = parentPart.newObject('Part::FeaturePython', 'HoleAxis_'+str(instanceNum)) axis.ViewObject.Proxy = Asm4.setCustomIcon(axis,'Asm4_Hole.svg') axis.Shape = Part.Wire(Part.makeLine(pt1,pt2)) axis.Placement = circle.Placement axis.ViewObject.DrawStyle = 'Dashdot' axis.ViewObject.LineColor = (0.0,0.0,1.0) ''' axis.recompute() parentPart.recompute()