def get_elebase_sh(corner_min, size, baseheight, tm): from FreeCAD import Vector as vec from MeshPart import meshFromShape from Part import makeLine # scaled place on orgin place_for_mesh = FreeCAD.Vector(-corner_min.x - size[0], -corner_min.y - size[1], 0.00) # SRTM data resolution is 30 m = 30'000 mm in the usa # rest of the world is 90 m = 90'000 mm # it makes no sense to use values smaller than 90'000 mm pt_distance = 100000 say(corner_min) # y is huge!, but this is ok! say(size) # base area surface mesh with heights # Version new pn1 = vec(0, 0, 0) pn2 = vec(pn1.x + size[0] * 2, pn1.y, 0) pn3 = vec(pn1.x + size[0] * 2, pn1.y + size[1] * 2, 0) pn4 = vec(pn1.x, pn1.y + size[1] * 2, 0) ln1 = makeLine(pn1, pn2) ln2 = makeLine(pn2, pn3) ln3 = makeLine(pn3, pn4) ln4 = makeLine(pn4, pn1) wi = Part.Wire([ln1, ln2, ln3, ln4]) fa = Part.makeFace([wi], "Part::FaceMakerSimple") msh = meshFromShape(fa, LocalLength=pt_distance) # move to corner_min to retrieve the heights msh.translate( corner_min.x, corner_min.y, 0, ) # move mesh points z-koord for pt_msh in msh.Points: # say(pt_msh.Index) # say(pt_msh.Vector) pt_tm = tm.toGeographic(pt_msh.Vector.x, pt_msh.Vector.y) height = get_height_single(pt_tm[0], pt_tm[1]) # mm # say(height) pt_msh.move(FreeCAD.Vector(0, 0, height)) # move mesh back centered on origin msh.translate( -corner_min.x - size[0], -corner_min.y - size[1], -baseheight, ) # create Shape from Mesh sh = Part.Shape() sh.makeShapeFromMesh(msh.Topology, 0.1) return sh
def cbeam_parallel_flange(params, document): # key = params['type'] # not used h = params["h"] b = params["b"] tf = params["tf"] tw = params["tw"] r = params["r"] le = params["l"] name = params["name"] # lower flange, starting at the end of web, going counter-clockwise Vlf1 = Vector(0, (-h / 2), 0) Vlf2 = Vector(b, -h / 2, 0) Vlf3 = Vector(b, -h / 2 + tf, 0) Vlf4 = Vector((tw + r), (-h / 2 + tf), 0) Llf1 = makeLine(Vlf1, Vlf2) Llf2 = makeLine(Vlf2, Vlf3) Llf3 = makeLine(Vlf3, Vlf4) # upper flange, starting at the right web fillet, going clockwise Vuf1 = Vector(tw + r, (h / 2 - tf), 0) Vuf2 = Vector(b, (h / 2 - tf), 0) Vuf3 = Vector(b, h / 2, 0) Vuf4 = Vector(0, h / 2, 0) Luf1 = makeLine(Vuf1, Vuf2) Luf2 = makeLine(Vuf2, Vuf3) Luf3 = makeLine(Vuf3, Vuf4) # web, starting right bottom, going counter-clockwise Vw1 = Vector(tw, (-h / 2 + tf + r), 0) Vw2 = Vector(tw, (h / 2 - tf - r), 0) Lw1 = makeLine(Vw1, Vw2) Lw2 = makeLine(Vuf4, Vlf1) # center of the fillets, starting right bottom, going up Vfc1 = Vector((tw + r), (-h / 2 + tf + r), 0) Vfc2 = Vector((tw + r), (h / 2 - tf - r), 0) normal = Vector(0, 0, 1) Cfc1 = makeCircle(r, Vfc1, normal, 180, 270) Cfc2 = makeCircle(r, Vfc2, normal, 90, 180) # putting the segments together make a wire, a face and extrude it W = Part.Wire([Llf1, Llf2, Llf3, Cfc1, Lw1, Cfc2, Luf1, Luf2, Luf3, Lw2]) F = Part.Face(W) if params["arch"]: part = Arch.makeStructure(name=name) prof = document.addObject("Part::Feature", "Profile") prof.Shape = F part.Base = prof part.Height = le else: part = document.addObject("Part::Feature", "BOLTS_part") part.Label = name beam = F.extrude(Vector(0, 0, le)) part.Shape = beam
def cbeam_parallel_flange(params,document): key = params['type'] h = params['h'] b = params['b'] tf = params['tf'] tw = params['tw'] r = params ['r'] l = params['l'] name = params['name'] # lower flange, starting at the end of web, going counter-clockwise Vlf1 = Vector(0,(-h/2),0) Vlf2 = Vector(b,-h/2,0) Vlf3 = Vector(b,-h/2+tf,0) Vlf4 = Vector((tw+r),(-h/2+tf),0) Llf1 = makeLine(Vlf1,Vlf2) Llf2 = makeLine(Vlf2,Vlf3) Llf3 = makeLine(Vlf3,Vlf4) # upper flange, starting at the right web fillet, going clockwise Vuf1 = Vector(tw+r,(h/2-tf),0) Vuf2 = Vector(b,(h/2-tf),0) Vuf3 = Vector(b,h/2,0) Vuf4 = Vector(0,h/2,0) Luf1 = makeLine(Vuf1,Vuf2) Luf2 = makeLine(Vuf2,Vuf3) Luf3 = makeLine(Vuf3,Vuf4) # web, starting right bottom, going counter-clockwise Vw1 = Vector(tw,(-h/2+tf+r),0) Vw2 = Vector(tw,(h/2-tf-r),0) Lw1 = makeLine(Vw1,Vw2) Lw2 = makeLine(Vuf4 ,Vlf1) # center of the fillets, starting right bottom, going up Vfc1 = Vector((tw+r),(-h/2+tf+r),0) Vfc2 = Vector((tw+r),(h/2-tf-r),0) normal = Vector(0,0,1) Cfc1 = makeCircle(r,Vfc1,normal,180,270) Cfc2 = makeCircle(r,Vfc2,normal, 90,180) # putting the segments together make a wire, a face and extrude it W = Part.Wire([Llf1,Llf2,Llf3,Cfc1,Lw1,Cfc2,Luf1,Luf2,Luf3,Lw2]) F = Part.Face(W) if params['arch']: part = Arch.makeStructure(name=name) prof = document.addObject("Part::Feature","Profile") prof.Shape = F part.Base = prof part.Height = l else: part = document.addObject("Part::Feature","BOLTS_part") part.Label = name beam = F.extrude(Vector(0,0,l)) part.Shape = beam
def dualvwheel(params, document): # no params name = params["name"] # still name some quantities r_1 = 0.5 * 13.89 r_2 = 0.5 * 15.974 r_3 = 9.77 r_4 = 0.5 * 18.75 r_5 = 0.5 * 24.39 # profile for revolution is symmetric, therefore only points from right half vertices = [ (0, r_1, 0), (0.5, r_1, 0), (0.5, r_2, 0), (0.5 * 10.23 - 0.3, r_2, 0), (0.5 * 10.23, r_2 + 0.3, 0), (0.5 * 10.23, r_3, 0), (0.5 * (10.23 - 4.84), r_5, 0), (0.5 * (10.23) - 4.84, r_3, 0), (0.5 * (10.23) - 4.84, r_4, 0), (0, r_4, 0) ] lines = [] vlast = None vcur = Vector(vertices[0]) # right half for i in range(1, len(vertices)): vlast = vcur vcur = Vector(vertices[i]) lines.append(makeLine(vcur, vlast)) # left half for i in range(len(vertices) - 2, -1, -1): vlast = vcur vcur = Vector(vertices[i]) vcur[0] *= -1 lines.append(makeLine(vcur, vlast)) part = document.addObject("Part::Feature", "BOLTS_part") part.Label = name part.Shape = Part.Face( Part.Wire(lines) ).revolve(Vector(0, 0, 0), Vector(1, 0, 0), 360).removeSplitter()
def vec2edge(point, direct): ''' vec2edge(point,direct) Returns an edge placed at point with the orientation and length of direct. ''' from Part import makeLine return makeLine(point, point + direct)
def vec2edge(point,direct): ''' vec2edge(point,direct) Returns an edge placed at point with the orientation and length of direct. ''' from Part import makeLine return makeLine(point,point+direct)
def dualvwheel(params,document): #no params name = params["name"] #still name some quantities r_1 = 0.5*13.89 r_2 = 0.5*15.974 r_3 = 9.77 r_4 = 0.5*18.75 r_5 = 0.5*24.39 #profile for revolution is symmetric, therefore only points from right half vertices = [ (0,r_1,0), (0.5,r_1,0), (0.5,r_2,0), (0.5*10.23-0.3,r_2,0), (0.5*10.23,r_2+0.3,0), (0.5*10.23,r_3,0), (0.5*(10.23-4.84),r_5,0), (0.5*(10.23)-4.84,r_3,0), (0.5*(10.23)-4.84,r_4,0), (0,r_4,0) ] lines = [] vlast = None vcur = Vector(vertices[0]) #right half for i in range(1,len(vertices)): vlast = vcur vcur = Vector(vertices[i]) lines.append(makeLine(vcur,vlast)) #left half for i in range(len(vertices)-2,-1,-1): vlast = vcur vcur = Vector(vertices[i]) vcur[0] *= -1 lines.append(makeLine(vcur,vlast)) part = document.addObject("Part::Feature","BOLTS_part") part.Label = name part.Shape = Part.Face(Part.Wire(lines)).revolve(Vector(0,0,0),Vector(1,0,0),360).removeSplitter()
def lbeam_parallel_flange_unequal(params, document): # key = params["type"] a = params["a"] b = params["b"] t = params["t"] ri = params["r1"] ro = params["r2"] le = params["l"] name = params["name"] # points, starting at the left upper corner, going counter-clockwise V1 = Vector(0, 0, 0) V2 = Vector(b, 0, 0) V3 = Vector(b, t - ro, 0) V4 = Vector(b - ro, t, 0) V5 = Vector(t + ri, t, 0) V6 = Vector(t, t + ri, 0) V7 = Vector(t, a - ro, 0) V8 = Vector(t - ro, a, 0) V9 = Vector(0, a, 0) # circle center of the fillets, starting right bottom, going counter-clockwise Vc1 = Vector(b - ro, t - ro, 0) Vc2 = Vector(t + ri, t + ri, 0) Vc3 = Vector(t - ro, a - ro, 0) normal = Vector(0, 0, 1) # edges E1 = makeLine(V1, V2) E2 = makeLine(V2, V3) E3 = makeCircle(ro, Vc1, normal, 0, 90) E4 = makeLine(V4, V5) E5 = makeCircle(ri, Vc2, normal, 180, 270) E6 = makeLine(V6, V7) E7 = makeCircle(ro, Vc3, normal, 0, 90) E8 = makeLine(V8, V9) E9 = makeLine(V9, V1) # putting the segments together make a wire, a face and extrude it W = Part.Wire([E1, E2, E3, E4, E5, E6, E7, E8, E9]) F = Part.Face(W) if params["arch"]: from ArchStructure import makeStructure part = makeStructure(name=name) prof = document.addObject("Part::Feature", "Profile") prof.Shape = F part.Base = prof part.Height = le else: part = document.addObject("Part::Feature", "BOLTS_part") part.Label = name beam = F.extrude(Vector(0, 0, le)) part.Shape = beam
def assemble(symmetry, vertices, offset_global=(0, 0)): """ Assemble a wire from a list of symmetry information and a list of list of vertices symmetry information is a tuple of offset x, offset y, bool reverse, bool switch_comp, bool mirror_x, bool mirror_y """ offset = Vector(offset_global[0], offset_global[1], 0) lines = [] vlast = None vcur = None for sym, verts in zip(symmetry, vertices): o_x, o_y, reverse, switch, mir_x, mir_y = sym mir_x = -1 if mir_x else 1 mir_y = -1 if mir_y else 1 if reverse: verts = verts[::-1] if vcur is None: vcur = Vector(verts[0]) if switch: vcur[0], vcur[1] = vcur[1], vcur[0] vcur[0] = mir_x * vcur[0] + o_x + offset[0] vcur[1] = mir_y * vcur[1] + o_y + offset[1] for v in verts[1:]: vlast = vcur vcur = Vector(v) if switch: vcur[0], vcur[1] = vcur[1], vcur[0] vcur[0] = mir_x * vcur[0] + o_x + offset[0] vcur[1] = mir_y * vcur[1] + o_y + offset[1] lines.append(makeLine(vlast, vcur)) return lines
def assemble(symmetry,vertices,offset_global=(0,0)): """ Assemble a wire from a list of symmetry information and a list of list of vertices symmetry information is a tuple of offset x, offset y, bool reverse, bool switch_comp, bool mirror_x, bool mirror_y """ offset = Vector(offset_global[0],offset_global[1],0) lines = [] vlast = None vcur = None for sym,verts in zip(symmetry,vertices): o_x, o_y, reverse, switch, mir_x, mir_y = sym mir_x = -1 if mir_x else 1 mir_y = -1 if mir_y else 1 if reverse: verts = verts[::-1] if vcur is None: vcur = Vector(verts[0]) if switch: vcur[0],vcur[1] = vcur[1],vcur[0] vcur[0] = mir_x*vcur[0]+o_x+offset[0] vcur[1] = mir_y*vcur[1]+o_y+offset[1] for v in verts[1:]: vlast = vcur vcur = Vector(v) if switch: vcur[0],vcur[1] = vcur[1],vcur[0] vcur[0] = mir_x*vcur[0]+o_x+offset[0] vcur[1] = mir_y*vcur[1]+o_y+offset[1] lines.append(makeLine(vlast,vcur)) return lines
def rectangle_hollow(params, document): h = params["h"] b = params["b"] t = params["t"] le = params["l"] name = params["name"] # Definition in EN standard ri = 1.0 * t ro = 1.5 * t # outer rectangle, going clockwise Vor1 = Vector((b / 2), (h / 2 - ro), 0) Vor2 = Vector((b / 2), (-h / 2 + ro), 0) Vor3 = Vector((b / 2 - ro), (-h / 2), 0) Vor4 = Vector((-b / 2 + ro), -h / 2, 0) Vor5 = Vector(-b / 2, (-h / 2 + ro), 0) Vor6 = Vector(-b / 2, (h / 2 - ro), 0) Vor7 = Vector((-b / 2 + ro), (h / 2), 0) Vor8 = Vector((b / 2 - ro), (h / 2), 0) Lor1 = makeLine(Vor1, Vor2) Lor2 = makeLine(Vor3, Vor4) Lor3 = makeLine(Vor5, Vor6) Lor4 = makeLine(Vor7, Vor8) # outer radius, going clockwise Voc1 = Vector((b / 2 - ro), (-h / 2 + ro), 0) Voc2 = Vector((-b / 2 + ro), (-h / 2 + ro), 0) Voc3 = Vector((-b / 2 + ro), (h / 2 - ro), 0) Voc4 = Vector((b / 2 - ro), (h / 2 - ro), 0) normal = Vector(0, 0, 1) Coc1 = makeCircle(ro, Voc1, normal, 270, 0) Coc2 = makeCircle(ro, Voc2, normal, 180, 270) Coc3 = makeCircle(ro, Voc3, normal, 90, 180) Coc4 = makeCircle(ro, Voc4, normal, 0, 90) # inner rectangle, going clockwise Vir1 = Vector((b / 2 - t), (h / 2 - t - ri), 0) Vir2 = Vector((b / 2 - t), (-h / 2 + t + ri), 0) Vir3 = Vector((b / 2 - t - ri), (-h / 2 + t), 0) Vir4 = Vector((-b / 2 + t + ri), (-h / 2 + t), 0) Vir5 = Vector((-b / 2 + t), (-h / 2 + t + ri), 0) Vir6 = Vector((-b / 2 + t), (h / 2 - t - ri), 0) Vir7 = Vector((-b / 2 + t + ri), (h / 2 - t), 0) Vir8 = Vector((b / 2 - t - ri), (h / 2 - t), 0) Lir1 = makeLine(Vir1, Vir2) Lir2 = makeLine(Vir3, Vir4) Lir3 = makeLine(Vir5, Vir6) Lir4 = makeLine(Vir7, Vir8) # inner radius, going clockwise Vic1 = Vector((b / 2 - t - ri), (-h / 2 + t + ri), 0) Vic2 = Vector((-b / 2 + t + ri), (-h / 2 + t + ri), 0) Vic3 = Vector((-b / 2 + t + ri), (h / 2 - t - ri), 0) Vic4 = Vector((b / 2 - t - ri), (h / 2 - t - ri), 0) normal = Vector(0, 0, 1) Cic1 = makeCircle(ri, Vic1, normal, 270, 0) Cic2 = makeCircle(ri, Vic2, normal, 180, 270) Cic3 = makeCircle(ri, Vic3, normal, 90, 180) Cic4 = makeCircle(ri, Vic4, normal, 0, 90) # putting the segments together, make wires, make faces, extrude them and cut them Wo = Part.Wire([ Lor1, Coc1, Lor2, Coc2, Lor3, Coc3, Lor4, Coc4, ]) Wi = Part.Wire([ Lir1, Cic1, Lir2, Cic2, Lir3, Cic3, Lir4, Cic4, ]) face = Part.makeFace([Wo, Wi], "Part::FaceMakerBullseye") if params["arch"]: from ArchStructure import makeStructure part = makeStructure(name=name) prof = document.addObject("Part::Feature", "Profile") prof.Shape = face part.Base = prof part.Height = le else: part = document.addObject("Part::Feature", "BOLTS_part") part.Label = name beam = face.extrude(Vector(0, 0, le)) part.Shape = beam
def setup(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information()))) # geometric object # load line load_line = doc.addObject("Part::Line", "LoadLine") load_line.X1 = 0 load_line.Y1 = 0 load_line.Z1 = 1000 load_line.X2 = 0 load_line.Y2 = 0 load_line.Z2 = 0 if FreeCAD.GuiUp: load_line.ViewObject.hide() # commands where generated by Python out of the original Z88 Mesh obj data v1 = vec(0.0, 2000.0, 0.0) v2 = vec(0.0, 0.0, 0.0) v3 = vec(1000.0, 1000.0, 2000.0) v4 = vec(2000.0, 2000.0, 0.0) v5 = vec(2000.0, 0.0, 0.0) v6 = vec(3000.0, 1000.0, 2000.0) v7 = vec(4000.0, 2000.0, 0.0) v8 = vec(4000.0, 0.0, 0.0) v9 = vec(5000.0, 1000.0, 2000.0) v10 = vec(6000.0, 2000.0, 0.0) v11 = vec(6000.0, 0.0, 0.0) v12 = vec(7000.0, 1000.0, 2000.0) v13 = vec(8000.0, 2000.0, 0.0) v14 = vec(8000.0, 0.0, 0.0) v15 = vec(9000.0, 1000.0, 2000.0) v16 = vec(10000.0, 2000.0, 0.0) v17 = vec(10000.0, 0.0, 0.0) v18 = vec(11000.0, 1000.0, 2000.0) v19 = vec(12000.0, 2000.0, 0.0) v20 = vec(12000.0, 0.0, 0.0) line1 = makeLine(v1, v2) line2 = makeLine(v4, v5) line3 = makeLine(v7, v8) line4 = makeLine(v10, v11) line5 = makeLine(v13, v14) line6 = makeLine(v16, v17) line7 = makeLine(v19, v20) line8 = makeLine(v1, v4) line9 = makeLine(v2, v5) line10 = makeLine(v4, v7) line11 = makeLine(v5, v8) line12 = makeLine(v7, v10) line13 = makeLine(v8, v11) line14 = makeLine(v10, v13) line15 = makeLine(v11, v14) line16 = makeLine(v13, v16) line17 = makeLine(v14, v17) line18 = makeLine(v16, v19) line19 = makeLine(v17, v20) line20 = makeLine(v1, v3) line21 = makeLine(v4, v6) line22 = makeLine(v7, v9) line23 = makeLine(v10, v12) line24 = makeLine(v13, v15) line25 = makeLine(v16, v18) line26 = makeLine(v2, v3) line27 = makeLine(v5, v6) line28 = makeLine(v8, v9) line29 = makeLine(v11, v12) line30 = makeLine(v14, v15) line31 = makeLine(v17, v18) line32 = makeLine(v3, v4) line33 = makeLine(v6, v7) line34 = makeLine(v9, v10) line35 = makeLine(v12, v13) line36 = makeLine(v15, v16) line37 = makeLine(v18, v19) line38 = makeLine(v3, v5) line39 = makeLine(v6, v8) line40 = makeLine(v9, v11) line41 = makeLine(v12, v14) line42 = makeLine(v15, v17) line43 = makeLine(v18, v20) line44 = makeLine(v3, v6) line45 = makeLine(v6, v9) line46 = makeLine(v9, v12) line47 = makeLine(v12, v15) line48 = makeLine(v15, v18) line49 = makeLine(v2, v4) line50 = makeLine(v5, v7) line51 = makeLine(v8, v10) line52 = makeLine(v11, v13) line53 = makeLine(v14, v16) line54 = makeLine(v17, v19) obj_line1 = doc.addObject("Part::Feature", "Line1") obj_line1.Shape = line1 obj_line2 = doc.addObject("Part::Feature", "Line2") obj_line2.Shape = line2 obj_line3 = doc.addObject("Part::Feature", "Line3") obj_line3.Shape = line3 obj_line4 = doc.addObject("Part::Feature", "Line4") obj_line4.Shape = line4 obj_line5 = doc.addObject("Part::Feature", "Line5") obj_line5.Shape = line5 obj_line6 = doc.addObject("Part::Feature", "Line6") obj_line6.Shape = line6 obj_line7 = doc.addObject("Part::Feature", "Line7") obj_line7.Shape = line7 obj_line8 = doc.addObject("Part::Feature", "Line8") obj_line8.Shape = line8 obj_line9 = doc.addObject("Part::Feature", "Line9") obj_line9.Shape = line9 obj_line10 = doc.addObject("Part::Feature", "Line10") obj_line10.Shape = line10 obj_line11 = doc.addObject("Part::Feature", "Line11") obj_line11.Shape = line11 obj_line12 = doc.addObject("Part::Feature", "Line12") obj_line12.Shape = line12 obj_line13 = doc.addObject("Part::Feature", "Line13") obj_line13.Shape = line13 obj_line14 = doc.addObject("Part::Feature", "Line14") obj_line14.Shape = line14 obj_line15 = doc.addObject("Part::Feature", "Line15") obj_line15.Shape = line15 obj_line16 = doc.addObject("Part::Feature", "Line16") obj_line16.Shape = line16 obj_line17 = doc.addObject("Part::Feature", "Line17") obj_line17.Shape = line17 obj_line18 = doc.addObject("Part::Feature", "Line18") obj_line18.Shape = line18 obj_line19 = doc.addObject("Part::Feature", "Line19") obj_line19.Shape = line19 obj_line20 = doc.addObject("Part::Feature", "Line20") obj_line20.Shape = line20 obj_line21 = doc.addObject("Part::Feature", "Line21") obj_line21.Shape = line21 obj_line22 = doc.addObject("Part::Feature", "Line22") obj_line22.Shape = line22 obj_line23 = doc.addObject("Part::Feature", "Line23") obj_line23.Shape = line23 obj_line24 = doc.addObject("Part::Feature", "Line24") obj_line24.Shape = line24 obj_line25 = doc.addObject("Part::Feature", "Line25") obj_line25.Shape = line25 obj_line26 = doc.addObject("Part::Feature", "Line26") obj_line26.Shape = line26 obj_line27 = doc.addObject("Part::Feature", "Line27") obj_line27.Shape = line27 obj_line28 = doc.addObject("Part::Feature", "Line28") obj_line28.Shape = line28 obj_line29 = doc.addObject("Part::Feature", "Line29") obj_line29.Shape = line29 obj_line30 = doc.addObject("Part::Feature", "Line30") obj_line30.Shape = line30 obj_line31 = doc.addObject("Part::Feature", "Line31") obj_line31.Shape = line31 obj_line32 = doc.addObject("Part::Feature", "Line32") obj_line32.Shape = line32 obj_line33 = doc.addObject("Part::Feature", "Line33") obj_line33.Shape = line33 obj_line34 = doc.addObject("Part::Feature", "Line34") obj_line34.Shape = line34 obj_line35 = doc.addObject("Part::Feature", "Line35") obj_line35.Shape = line35 obj_line36 = doc.addObject("Part::Feature", "Line36") obj_line36.Shape = line36 obj_line37 = doc.addObject("Part::Feature", "Line37") obj_line37.Shape = line37 obj_line38 = doc.addObject("Part::Feature", "Line38") obj_line38.Shape = line38 obj_line39 = doc.addObject("Part::Feature", "Line39") obj_line39.Shape = line39 obj_line40 = doc.addObject("Part::Feature", "Line40") obj_line40.Shape = line40 obj_line41 = doc.addObject("Part::Feature", "Line41") obj_line41.Shape = line41 obj_line42 = doc.addObject("Part::Feature", "Line42") obj_line42.Shape = line42 obj_line43 = doc.addObject("Part::Feature", "Line43") obj_line43.Shape = line43 obj_line44 = doc.addObject("Part::Feature", "Line44") obj_line44.Shape = line44 obj_line45 = doc.addObject("Part::Feature", "Line45") obj_line45.Shape = line45 obj_line46 = doc.addObject("Part::Feature", "Line46") obj_line46.Shape = line46 obj_line47 = doc.addObject("Part::Feature", "Line47") obj_line47.Shape = line47 obj_line48 = doc.addObject("Part::Feature", "Line48") obj_line48.Shape = line48 obj_line49 = doc.addObject("Part::Feature", "Line49") obj_line49.Shape = line49 obj_line50 = doc.addObject("Part::Feature", "Line50") obj_line50.Shape = line50 obj_line51 = doc.addObject("Part::Feature", "Line51") obj_line51.Shape = line51 obj_line52 = doc.addObject("Part::Feature", "Line52") obj_line52.Shape = line52 obj_line53 = doc.addObject("Part::Feature", "Line53") obj_line53.Shape = line53 obj_line54 = doc.addObject("Part::Feature", "Line54") obj_line54.Shape = line54 doc.recompute() geom_obj = SplitFeatures.makeBooleanFragments(name="CraneTruss") geom_obj.Objects = [ obj_line1, obj_line2, obj_line3, obj_line4, obj_line5, obj_line6, obj_line7, obj_line8, obj_line9, obj_line10, obj_line11, obj_line12, obj_line13, obj_line14, obj_line15, obj_line16, obj_line17, obj_line18, obj_line19, obj_line20, obj_line21, obj_line22, obj_line23, obj_line24, obj_line25, obj_line26, obj_line27, obj_line28, obj_line29, obj_line30, obj_line31, obj_line32, obj_line33, obj_line34, obj_line35, obj_line36, obj_line37, obj_line38, obj_line39, obj_line40, obj_line41, obj_line42, obj_line43, obj_line44, obj_line45, obj_line46, obj_line47, obj_line48, obj_line49, obj_line50, obj_line51, obj_line52, obj_line53, obj_line54, ] if FreeCAD.GuiUp: obj_line1.ViewObject.hide() obj_line2.ViewObject.hide() obj_line3.ViewObject.hide() obj_line4.ViewObject.hide() obj_line5.ViewObject.hide() obj_line6.ViewObject.hide() obj_line7.ViewObject.hide() obj_line8.ViewObject.hide() obj_line9.ViewObject.hide() obj_line10.ViewObject.hide() obj_line11.ViewObject.hide() obj_line12.ViewObject.hide() obj_line13.ViewObject.hide() obj_line14.ViewObject.hide() obj_line15.ViewObject.hide() obj_line16.ViewObject.hide() obj_line17.ViewObject.hide() obj_line18.ViewObject.hide() obj_line19.ViewObject.hide() obj_line20.ViewObject.hide() obj_line21.ViewObject.hide() obj_line22.ViewObject.hide() obj_line23.ViewObject.hide() obj_line24.ViewObject.hide() obj_line25.ViewObject.hide() obj_line26.ViewObject.hide() obj_line27.ViewObject.hide() obj_line28.ViewObject.hide() obj_line29.ViewObject.hide() obj_line30.ViewObject.hide() obj_line31.ViewObject.hide() obj_line32.ViewObject.hide() obj_line33.ViewObject.hide() obj_line34.ViewObject.hide() obj_line35.ViewObject.hide() obj_line36.ViewObject.hide() obj_line37.ViewObject.hide() obj_line38.ViewObject.hide() obj_line39.ViewObject.hide() obj_line40.ViewObject.hide() obj_line41.ViewObject.hide() obj_line42.ViewObject.hide() obj_line43.ViewObject.hide() obj_line44.ViewObject.hide() obj_line45.ViewObject.hide() obj_line46.ViewObject.hide() obj_line47.ViewObject.hide() obj_line48.ViewObject.hide() obj_line49.ViewObject.hide() obj_line50.ViewObject.hide() obj_line51.ViewObject.hide() obj_line52.ViewObject.hide() obj_line53.ViewObject.hide() obj_line54.ViewObject.hide() doc.recompute() if FreeCAD.GuiUp: geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" elif solvertype == "z88": solver_obj = ObjectsFem.makeSolverZ88(doc, "SolverZ88") else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype) ) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.SplitInputWriter = False solver_obj.AnalysisType = "static" solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = False solver_obj.MatrixSolverType = "default" solver_obj.IterationsControlParameterTimeUse = False analysis.addObject(solver_obj) # beam section beamsection_obj = ObjectsFem.makeElementGeometry1D( doc, sectiontype="Circular", height=25.0, name="CrossSectionCircular" ) analysis.addObject(beamsection_obj) # material material_obj = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial") mat = material_obj.Material mat["Name"] = "Steel" mat["YoungsModulus"] = "200000 MPa" mat["PoissonRatio"] = "0.30" material_obj.Material = mat analysis.addObject(material_obj) # constraint fixed con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed") con_fixed.References = [(geom_obj, ("Vertex1", "Vertex2", "Vertex13", "Vertex14"))] analysis.addObject(con_fixed) # constraint force con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce") con_force.References = [(geom_obj, ("Vertex5", "Vertex6"))] con_force.Force = 60000.0 # 30 kN on each Node con_force.Direction = (load_line, ["Edge1"]) con_force.Reversed = False analysis.addObject(con_force) # mesh from .meshes.mesh_truss_crane_seg3 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False femmesh_obj.ElementDimension = "1D" # four elements for each bar femmesh_obj.CharacteristicLengthMax = "1500.0 mm" femmesh_obj.CharacteristicLengthMin = "1500.0 mm" if FreeCAD.GuiUp: femmesh_obj.ViewObject.DisplayMode = "Faces, Wireframe & Nodes" femmesh_obj.ViewObject.PointColor = (1.0, 0.0, 0.5, 0.0) doc.recompute() return doc
def ibeam_parallel_flange(params,document): key = params['type'] h = params['h'] b = params['b'] tf = params['tf'] tw = params['tw'] r = params ['r'] l = params['l'] name = params['name'] part = document.addObject("Part::Feature","BOLTS_part") part.Label = name # lower flange, starting at the left web fillet, going against clockwise Vlf1 = Vector((-tw/2-r),(-h/2+tf),0) Vlf2 = Vector(-b/2,(-h/2+tf),0) Vlf3 = Vector(-b/2,-h/2,0) Vlf4 = Vector(b/2,-h/2,0) Vlf5 = Vector(b/2,(-h/2+tf),0) Vlf6 = Vector((tw/2+r),(-h/2+tf),0) Llf1 = makeLine(Vlf1,Vlf2) Llf2 = makeLine(Vlf2,Vlf3) Llf3 = makeLine(Vlf3,Vlf4) Llf4 = makeLine(Vlf4,Vlf5) Llf5 = makeLine(Vlf5,Vlf6) # upper flange, starting at the rigth web fillet, going clockwise Vuf1 = Vector(tw/2+r,(h/2-tf),0) Vuf2 = Vector(b/2,(h/2-tf),0) Vuf3 = Vector(b/2,h/2,0) Vuf4 = Vector(-b/2,h/2,0) Vuf5 = Vector(-b/2,(h/2-tf),0) Vuf6 = Vector((-tw/2-r),(h/2-tf),0) Luf1 = makeLine(Vuf1,Vuf2) Luf2 = makeLine(Vuf2,Vuf3) Luf3 = makeLine(Vuf3,Vuf4) Luf4 = makeLine(Vuf4,Vuf5) Luf5 = makeLine(Vuf5,Vuf6) # web, starting rigth bottom, going against clockwise Vw1 = Vector(tw/2,(-h/2+tf+r),0) Vw2 = Vector(tw/2,(h/2-tf-r),0) Vw3 = Vector(-tw/2,(h/2-tf-r),0) Vw4 = Vector(-tw/2,(-h/2+tf+r),0) Lw1 = makeLine(Vw1,Vw2) Lw2 = makeLine(Vw3,Vw4) # center of the fillets, starting right bottom, going against clockwise Vfc1 = Vector((tw/2+r),(-h/2+tf+r),0) Vfc2 = Vector((tw/2+r),(h/2-tf-r),0) Vfc3 = Vector((-tw/2-r),(h/2-tf-r),0) Vfc4 = Vector((-tw/2-r),(-h/2+tf+r),0) normal = Vector(0,0,1) Cfc1 = makeCircle(r,Vfc1,normal,180,270) Cfc2 = makeCircle(r,Vfc2,normal, 90,180) Cfc3 = makeCircle(r,Vfc3,normal, 0, 90) Cfc4 = makeCircle(r,Vfc4,normal,270, 0) # putting the segments together make a wire, a face and extrude it W = Part.Wire([Llf1,Llf2,Llf3,Llf4,Llf5,Cfc1,Lw1,Cfc2,Luf1,Luf2,Luf3,Luf4,Luf5,Cfc3,Lw2,Cfc4]) F = Part.Face(W) beam = F.extrude(Vector(0,0,l)) part.Shape = beam
def zbeam(params, document): # key = params['type'] h = params['h'] c1 = params['c1'] tw = params['tw'] tf = params['tf'] l = params['l'] name = params['name'] rf = tf / 2.0 rw = tw # points, starting at the left upper corner, going counter-clockwise V1 = Vector(-0.5 * tw, 0, 0) V2 = Vector(-0.5 * tw + c1, 0, 0) V3 = Vector(-0.5 * tw + c1, tf - rf, 0) V4 = Vector(-0.5 * tw + c1 - rf, tf, 0) V5 = Vector(0.5 * tw + rw, tf, 0) V6 = Vector(0.5 * tw, tf + rw, 0) V7 = Vector(0.5 * tw, h, 0) V8 = Vector(0.5 * tw - c1, h, 0) V9 = Vector(0.5 * tw - c1, h - tf + rf, 0) V10 = Vector(0.5 * tw - c1 + rf, h - tf, 0) V11 = Vector(-0.5 * tw - rw, h - tf, 0) V12 = Vector(-0.5 * tw, h - tf - rw, 0) # circle center of the fillets, starting right bottom, going counter-clockwise Vc1 = Vector(-0.5 * tw + c1 - rf, tf - rf, 0) Vc2 = Vector(0.5 * tw + rw, tf + rw, 0) Vc3 = Vector(0.5 * tw - c1 + rf, h - tf + rf, 0) Vc4 = Vector(-0.5 * tw - rw, h - tf - rw, 0) normal = Vector(0, 0, 1) # edges E1 = makeLine(V1, V2) E2 = makeLine(V2, V3) E3 = makeCircle(rf, Vc1, normal, 0, 90) E4 = makeLine(V4, V5) E5 = makeCircle(rw, Vc2, normal, 180, 270) E6 = makeLine(V6, V7) E7 = makeLine(V7, V8) E8 = makeLine(V8, V9) E9 = makeCircle(rf, Vc3, normal, 180, 270) E10 = makeLine(V10, V11) E11 = makeCircle(rw, Vc4, normal, 0, 90) E12 = makeLine(V12, V1) # putting the segments together make a wire, a face and extrude it W = Part.Wire([E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12]) F = Part.Face(W) if params['arch']: import Arch part = Arch.makeStructure(name=name) prof = document.addObject("Part::Feature", "Profile") prof.Shape = F part.Base = prof part.Height = l else: part = document.addObject("Part::Feature", "BOLTS_part") part.Label = name beam = F.extrude(Vector(0, 0, l)) part.Shape = beam
def vslot(outer_symmetry,fillets,corner_offset,circle_offsets,space_offsets): #build the outline lines = [] vlast = None vcur = Vector(vertices_corner[0]) for part in outer_symmetry: for i in range(part[0],part[1],part[2]): vlast = vcur vcur = Vector(vertices_corner[i]) vcur[0],vcur[1] = part[4]*vcur[part[5]]+part[3],part[6]*vcur[part[7]] lines.append(makeLine(vlast,vcur)) #add fillets for fillet in fillets: lines[fillet] = edge_fillet(lines[fillet],1.5) #build the holes holes = [] #corner holes for sx,offset in zip([1,-1],[0,corner_offset]): for sy in [1,-1]: hole = [] for i in range(1,len(vertices_hole)): v1 = Vector(vertices_hole[i-1]).scale(sx,sy,1) + Vector((offset,0,0)) v2 = Vector(vertices_hole[i]).scale(sx,sy,1) + Vector((offset,0,0)) hole.append(Part.makeLine(v1,v2)) holes.append(Part.Wire(hole)) if sx*sy > 0: holes[-1].reverse() #circular holes for offset in circle_offsets: holes.append(Part.Wire(Part.makeCircle(2.1,Vector(offset,0,0)))) holes[-1].reverse() space_symmetry = [ (+1,len(vertices_inner), +1, 0,-1,0,+1,1), (len(vertices_inner)-2,-1,-1,-w,+1,0,+1,1), (+1,len(vertices_inner), +1,-w,+1,0,-1,1), (len(vertices_inner)-2,-1,-1, 0,-1,0,-1,1), ] #big space for offset in space_offsets: hole = [] vcur = Vector(vertices_inner[0]).scale(-1,1,1) + Vector((offset,0,0)) for part in space_symmetry: for i in range(part[0],part[1],part[2]): vlast = vcur vcur = Vector(vertices_inner[i]) vcur[0],vcur[1] = part[4]*vcur[part[5]]+part[3],part[6]*vcur[part[7]] vcur += Vector((offset,0,0)) hole.append(makeLine(vlast,vcur)) holes.append(Part.Wire(hole)) holes[-1].reverse() #put everything together return Part.Face([Part.Wire(lines)] + holes)
def zbeam(params, document): # key = params['type'] h = params["h"] c1 = params["c1"] tw = params["tw"] tf = params["tf"] le = params["l"] name = params["name"] rf = tf / 2.0 rw = tw # points, starting at the left upper corner, going counter-clockwise V1 = Vector(-0.5 * tw, 0, 0) V2 = Vector(-0.5 * tw + c1, 0, 0) V3 = Vector(-0.5 * tw + c1, tf - rf, 0) V4 = Vector(-0.5 * tw + c1 - rf, tf, 0) V5 = Vector(0.5 * tw + rw, tf, 0) V6 = Vector(0.5 * tw, tf + rw, 0) V7 = Vector(0.5 * tw, h, 0) V8 = Vector(0.5 * tw - c1, h, 0) V9 = Vector(0.5 * tw - c1, h - tf + rf, 0) V10 = Vector(0.5 * tw - c1 + rf, h - tf, 0) V11 = Vector(-0.5 * tw - rw, h - tf, 0) V12 = Vector(-0.5 * tw, h - tf - rw, 0) # circle center of the fillets, starting right bottom, going counter-clockwise Vc1 = Vector(-0.5 * tw + c1 - rf, tf - rf, 0) Vc2 = Vector(0.5 * tw + rw, tf + rw, 0) Vc3 = Vector(0.5 * tw - c1 + rf, h - tf + rf, 0) Vc4 = Vector(-0.5 * tw - rw, h - tf - rw, 0) normal = Vector(0, 0, 1) # edges E1 = makeLine(V1, V2) E2 = makeLine(V2, V3) E3 = makeCircle(rf, Vc1, normal, 0, 90) E4 = makeLine(V4, V5) E5 = makeCircle(rw, Vc2, normal, 180, 270) E6 = makeLine(V6, V7) E7 = makeLine(V7, V8) E8 = makeLine(V8, V9) E9 = makeCircle(rf, Vc3, normal, 180, 270) E10 = makeLine(V10, V11) E11 = makeCircle(rw, Vc4, normal, 0, 90) E12 = makeLine(V12, V1) # putting the segments together make a wire, a face and extrude it W = Part.Wire([E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12]) F = Part.Face(W) if params["arch"]: from ArchStructure import makeStructure part = makeStructure(name=name) prof = document.addObject("Part::Feature", "Profile") prof.Shape = F part.Base = prof part.Height = le else: part = document.addObject("Part::Feature", "BOLTS_part") part.Label = name beam = F.extrude(Vector(0, 0, le)) part.Shape = beam
def ibeam_angled_flange(params,document): h = params['h'] b = params['b'] tf = params['tf'] tw = params['tw'] hw = params ['hw'] f = params ['f'] g = params ['g'] r1 = params ['r1'] r2 = params ['r2'] l = params['l'] name = params['name'] part = document.addObject("Part::Feature","BOLTS_part") part.Label = name #The profile is symmetric, we store the positions relative to the #origin for upper right quarter vertices = [ Vector((0.5*tw,0,0)), Vector((0.5*tw,f,0)), Vector((0.5*b,0.5*h-g,0)), Vector((+0.5*b,0.5*h,0)), Vector((0,0.5*h,0)), ] lines = [] plast = None pcur = vertices[0] #upper right quadrant for i in range(1,len(vertices)): plast = pcur pcur = Vector(vertices[i]) lines.append(makeLine(pcur,plast)) #upper left quadrant for i in range(len(vertices)-2,-1,-1): plast = pcur pcur = Vector(vertices[i]) pcur[0] *= -1 lines.append(makeLine(pcur,plast)) #lower left quadrant for i in range(1,len(vertices)): plast = pcur pcur = Vector(vertices[i]) pcur[0] *= -1 pcur[1] *= -1 lines.append(makeLine(pcur,plast)) #lower right quadrant for i in range(len(vertices)-2,-1,-1): plast = pcur pcur = Vector(vertices[i]) pcur[1] *= -1 lines.append(makeLine(pcur,plast)) beam = Part.Face(Part.Wire(lines)).extrude(Vector(0,0,l)) inner_fillets = [] outer_fillets = [] for edge in beam.Edges: for v in edge.Vertexes: if fabs(fabs(v.Point[0]) - 0.5*tw) > 1e-8 or fabs(fabs(v.Point[1]) - f) > 1e-8: break else: inner_fillets.append(edge) for v in edge.Vertexes: if fabs(fabs(v.Point[0]) - 0.5*b) > 1e-8 or fabs(fabs(v.Point[1]) - (0.5*h-g)) > 1e-8: break else: outer_fillets.append(edge) part.Shape = beam.makeFillet(r1,inner_fillets).makeFillet(r2,outer_fillets).removeSplitter()
def setup(doc=None, solvertype="ccxtools"): # init FreeCAD document if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj( doc, get_explanation(manager.get_header(get_information()))) # geometric objects # ring stiffener = doc.addObject("Part::Box", "Stiffener") stiffener.Length = 10 stiffener.Width = 200 stiffener.Height = 10 stiffener.Placement.Base = (-5, -100, 0) circumference = Shapes.addTube(doc, "Circumference") circumference.Height = 10.0 circumference.InnerRadius = 97.5 circumference.OuterRadius = 102.5 doc.recompute() fusion = doc.addObject("Part::MultiFuse", "Fusion") fusion.Shapes = [stiffener, circumference] doc.recompute() centerhole = doc.addObject("Part::Cylinder", "CenterHole") centerhole.Radius = 3 centerhole.Height = 20 doc.recompute() ring_bottom = doc.addObject("Part::Cut", "RingBottom") ring_bottom.Base = fusion ring_bottom.Tool = centerhole doc.recompute() # standard ring ring_top = clone(ring_bottom, delta=vec(0, 0, 20)) ring_top.Label = "RingTop" # compound of both rings geom_obj = doc.addObject("Part::Compound", "TheRingOfFire") geom_obj.Links = [ring_bottom, ring_top] doc.recompute() if FreeCAD.GuiUp: geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # line for centrif axis sh_axis_line = makeLine(vec(0, 0, 0), vec(0, 0, 31)) axis_line = doc.addObject("Part::Feature", "CentrifAxis") axis_line.Shape = sh_axis_line doc.recompute() if FreeCAD.GuiUp: axis_line.ViewObject.LineWidth = 5.0 axis_line.ViewObject.LineColor = (1.0, 0.0, 0.0) # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools( doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype)) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.AnalysisType = "static" solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = False solver_obj.MatrixSolverType = "default" solver_obj.IterationsControlParameterTimeUse = False solver_obj.SplitInputWriter = False analysis.addObject(solver_obj) # materials material_obj_scotty = ObjectsFem.makeMaterialSolid(doc, "Steel_Scotty") mat = material_obj_scotty.Material mat["Name"] = "Steel_Scotty" mat["YoungsModulus"] = "210000 MPa" mat["PoissonRatio"] = "0.30" mat["Density"] = "4000 kg/m^3" material_obj_scotty.Material = mat material_obj_scotty.References = [(ring_bottom, "Solid1")] analysis.addObject(material_obj_scotty) material_obj_std = ObjectsFem.makeMaterialSolid(doc, "Steel_Std") mat = material_obj_std.Material mat["Name"] = "Steel_Std" mat["YoungsModulus"] = "210000 MPa" mat["PoissonRatio"] = "0.30" mat["Density"] = "8000 kg/m^3" material_obj_std.Material = mat material_obj_std.References = [(ring_top, "Solid1")] analysis.addObject(material_obj_std) # constraint fixed con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed") con_fixed.References = [(geom_obj, ("Face4", "Face12"))] analysis.addObject(con_fixed) # constraint centrif con_centrif = ObjectsFem.makeConstraintCentrif(doc, "ConstraintCentrif") con_centrif.RotationFrequency = "100 Hz" con_centrif.RotationAxis = [(axis_line, "Edge1")] analysis.addObject(con_centrif) # mesh from .meshes.mesh_constraint_centrif_tetra10 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject( ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False femmesh_obj.CharacteristicLengthMax = "5.0 mm" doc.recompute() return doc
def setup(doc=None, solvertype="ccxtools"): if doc is None: doc = init_doc() # explanation object # just keep the following line and change text string in get_explanation method manager.add_explanation_obj( doc, get_explanation(manager.get_header(get_information()))) # line for load direction sh_load_line = makeLine(FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(0, 10, 0)) load_line = doc.addObject("Part::Feature", "Load_direction_line") load_line.Shape = sh_load_line doc.recompute() if FreeCAD.GuiUp: load_line.ViewObject.LineWidth = 5.0 load_line.ViewObject.LineColor = (1.0, 0.0, 0.0) # geometry object # name is important because the other method in this module use obj name cylinder1 = doc.addObject("Part::Cylinder", "Cylinder1") cylinder1.Height = "50 mm" cylinder1.Radius = "5 mm" cylinder2 = doc.addObject("Part::Cylinder", "Cylinder2") cylinder2.Height = "50 mm" cylinder2.Radius = "4 mm" geom_obj = doc.addObject("Part::Cut", "Cut") geom_obj.Base = cylinder1 geom_obj.Tool = cylinder2 doc.recompute() if FreeCAD.GuiUp: geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() # analysis analysis = ObjectsFem.makeAnalysis(doc, "Analysis") # solver if solvertype == "calculix": solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX") elif solvertype == "ccxtools": solver_obj = ObjectsFem.makeSolverCalculixCcxTools( doc, "CalculiXccxTools") solver_obj.WorkingDir = u"" else: FreeCAD.Console.PrintWarning( "Not known or not supported solver type: {}. " "No solver object was created.\n".format(solvertype)) if solvertype == "calculix" or solvertype == "ccxtools": solver_obj.AnalysisType = "static" solver_obj.GeometricalNonlinearity = "linear" solver_obj.ThermoMechSteadyState = False solver_obj.MatrixSolverType = "default" solver_obj.IterationsControlParameterTimeUse = False solver_obj.SplitInputWriter = False analysis.addObject(solver_obj) # material material_obj = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial") mat = material_obj.Material mat["Name"] = "Calculix-Steel" mat["YoungsModulus"] = "210000 MPa" mat["PoissonRatio"] = "0.30" material_obj.Material = mat analysis.addObject(material_obj) # constraint fixed con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed") con_fixed.References = [(geom_obj, "Face3")] analysis.addObject(con_fixed) # constraint force con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce") con_force.References = [(geom_obj, "Face1")] con_force.Force = 2500.0 # 2500 N = 2.5 kN con_force.Direction = (load_line, ["Edge1"]) con_force.Reversed = True analysis.addObject(con_force) # constraint transform con_transform = ObjectsFem.makeConstraintTransform( doc, name="ConstraintTransform") con_transform.References = [(geom_obj, "Face1")] con_transform.TransformType = "Cylindrical" con_transform.X_rot = 0.0 con_transform.Y_rot = 0.0 con_transform.Z_rot = 0.0 analysis.addObject(con_transform) # mesh from .meshes.mesh_transform_torque_tetra10 import create_nodes, create_elements fem_mesh = Fem.FemMesh() control = create_nodes(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating nodes.\n") control = create_elements(fem_mesh) if not control: FreeCAD.Console.PrintError("Error on creating elements.\n") femmesh_obj = analysis.addObject( ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = geom_obj femmesh_obj.SecondOrderLinear = False doc.recompute() return doc
def ibeam_angled_flange(params, document): h = params['h'] b = params['b'] tf = params['tf'] tw = params['tw'] hw = params['hw'] f = params['f'] g = params['g'] r1 = params['r1'] r2 = params['r2'] l = params['l'] name = params['name'] #The profile is symmetric, we store the positions relative to the #origin for upper right quarter vertices = [ Vector((0.5 * tw, 0, 0)), Vector((0.5 * tw, f, 0)), Vector((0.5 * b, 0.5 * h - g, 0)), Vector((+0.5 * b, 0.5 * h, 0)), Vector((0, 0.5 * h, 0)), ] lines = [] plast = None pcur = vertices[0] #upper right quadrant for i in range(1, len(vertices)): plast = pcur pcur = Vector(vertices[i]) lines.append(makeLine(plast, pcur)) #upper left quadrant for i in range(len(vertices) - 2, -1, -1): plast = pcur pcur = Vector(vertices[i]) pcur[0] *= -1 lines.append(makeLine(plast, pcur)) #lower left quadrant for i in range(1, len(vertices)): plast = pcur pcur = Vector(vertices[i]) pcur[0] *= -1 pcur[1] *= -1 lines.append(makeLine(plast, pcur)) #lower right quadrant for i in range(len(vertices) - 2, -1, -1): plast = pcur pcur = Vector(vertices[i]) pcur[1] *= -1 lines.append(makeLine(plast, pcur)) fillets = [(slice(0, 2), r1), (slice(1, 3), r2), (slice(5, 7), r2), (slice(6, 8), r1), (slice(8, 10), r1), (slice(9, 11), r2), (slice(13, 15), r1), (slice(14, 16), r2)] #add fillets in reverse order to not disturb the counting, as edges are added fillets.reverse() for fillet, r in fillets: lines[fillet] = edge_fillet(lines[fillet], r) F = Part.Face(Part.Wire(lines)) if params['arch']: part = Arch.makeStructure(name=name) prof = document.addObject("Part::Feature", "Profile") prof.Shape = F part.Base = prof part.Height = l else: part = document.addObject("Part::Feature", "BOLTS_part") part.Label = name beam = F.extrude(Vector(0, 0, l)) part.Shape = beam.removeSplitter()
def ibeam_angled_flange(params,document): h = params['h'] b = params['b'] tf = params['tf'] tw = params['tw'] hw = params ['hw'] f = params ['f'] g = params ['g'] r1 = params ['r1'] r2 = params ['r2'] l = params['l'] name = params['name'] #The profile is symmetric, we store the positions relative to the #origin for upper right quarter vertices = [ Vector((0.5*tw,0,0)), Vector((0.5*tw,f,0)), Vector((0.5*b,0.5*h-g,0)), Vector((+0.5*b,0.5*h,0)), Vector((0,0.5*h,0)), ] lines = [] plast = None pcur = vertices[0] #upper right quadrant for i in range(1,len(vertices)): plast = pcur pcur = Vector(vertices[i]) lines.append(makeLine(plast,pcur)) #upper left quadrant for i in range(len(vertices)-2,-1,-1): plast = pcur pcur = Vector(vertices[i]) pcur[0] *= -1 lines.append(makeLine(plast,pcur)) #lower left quadrant for i in range(1,len(vertices)): plast = pcur pcur = Vector(vertices[i]) pcur[0] *= -1 pcur[1] *= -1 lines.append(makeLine(plast,pcur)) #lower right quadrant for i in range(len(vertices)-2,-1,-1): plast = pcur pcur = Vector(vertices[i]) pcur[1] *= -1 lines.append(makeLine(plast,pcur)) fillets = [ (slice(0,2), r1), (slice(1,3), r2), (slice(5,7), r2), (slice(6,8), r1), (slice(8,10),r1), (slice(9,11),r2), (slice(13,15),r1), (slice(14,16),r2) ] #add fillets in reverse order to not disturb the counting, as edges are added fillets.reverse() ''' # the API of FreeCAD has changed in the regard of lines see https://forum.freecadweb.org/viewtopic.php?f=22&t=23252 # def edge_fillet needs adaption for fillet,r in fillets: lines[fillet] = edge_fillet(lines[fillet],r) ''' print('The profile is made without Fillets atm.') F = Part.Face(Part.Wire(lines)) if params['arch']: part = Arch.makeStructure(name=name) prof = document.addObject("Part::Feature","Profile") prof.Shape = F part.Base = prof part.Height = l else: part = document.addObject("Part::Feature","BOLTS_part") part.Label = name beam = F.extrude(Vector(0,0,l)) part.Shape = beam.removeSplitter()
def rectangle_hollow(params,document): h = params['h'] b = params['b'] t = params['t'] l = params['l'] name = params['name'] ## Definition in EN standard ri=1.0*t ro=1.5*t # outer rectangle, going clockwise Vor1 = Vector((b/2),(h/2-ro),0) Vor2 = Vector((b/2),(-h/2+ro),0) Vor3 = Vector((b/2-ro),(-h/2),0) Vor4 = Vector((-b/2+ro),-h/2,0) Vor5 = Vector(-b/2,(-h/2+ro),0) Vor6 = Vector(-b/2,(h/2-ro),0) Vor7 = Vector((-b/2+ro),(h/2),0) Vor8 = Vector((b/2-ro),(h/2),0) Lor1 = makeLine(Vor1,Vor2) Lor2 = makeLine(Vor3,Vor4) Lor3 = makeLine(Vor5,Vor6) Lor4 = makeLine(Vor7,Vor8) # outer radius, going clockwise Voc1 = Vector((b/2-ro),(-h/2+ro),0) Voc2 = Vector((-b/2+ro),(-h/2+ro),0) Voc3 = Vector((-b/2+ro),(h/2-ro),0) Voc4= Vector((b/2-ro),(h/2-ro),0) normal = Vector(0,0,1) Coc1 = makeCircle(ro,Voc1,normal,270, 0) Coc2 = makeCircle(ro,Voc2,normal,180,270) Coc3 = makeCircle(ro,Voc3,normal, 90,180) Coc4 = makeCircle(ro,Voc4,normal, 0, 90) # inner rectangle, going clockwise Vir1 = Vector((b/2-t),(h/2-t-ri),0) Vir2 = Vector((b/2-t),(-h/2+t+ri),0) Vir3 = Vector((b/2-t-ri),(-h/2+t),0) Vir4 = Vector((-b/2+t+ri),(-h/2+t),0) Vir5 = Vector((-b/2+t),(-h/2+t+ri),0) Vir6 = Vector((-b/2+t),(h/2-t-ri),0) Vir7 = Vector((-b/2+t+ri),(h/2-t),0) Vir8 = Vector((b/2-t-ri),(h/2-t),0) Lir1 = makeLine(Vir1,Vir2) Lir2 = makeLine(Vir3,Vir4) Lir3 = makeLine(Vir5,Vir6) Lir4 = makeLine(Vir7,Vir8) # inner radius, going clockwise Vic1 = Vector((b/2-t-ri),(-h/2+t+ri),0) Vic2 = Vector((-b/2+t+ri),(-h/2+t+ri),0) Vic3 = Vector((-b/2+t+ri),(h/2-t-ri),0) Vic4= Vector((b/2-t-ri),(h/2-t-ri),0) normal = Vector(0,0,1) Cic1 = makeCircle(ri,Vic1,normal,270, 0) Cic2 = makeCircle(ri,Vic2,normal,180,270) Cic3 = makeCircle(ri,Vic3,normal, 90,180) Cic4 = makeCircle(ri,Vic4,normal, 0, 90) # putting the segments together, make wires, make faces, extrude them and cut them Wo = Part.Wire([Lor1,Coc1,Lor2,Coc2,Lor3,Coc3,Lor4,Coc4,]) Wi = Part.Wire([Lir1,Cic1,Lir2,Cic2,Lir3,Cic3,Lir4,Cic4,]) face = Part.makeFace([Wo, Wi], "Part::FaceMakerBullseye") if params['arch']: part = Arch.makeStructure(name=name) prof = document.addObject("Part::Feature","Profile") prof.Shape = face part.Base = prof part.Height = l else: part = document.addObject("Part::Feature","BOLTS_part") part.Label = name beam = face.extrude(Vector(0,0,l)) part.Shape = beam
def rectangle_hollow(params, document): h = params['h'] b = params['b'] t = params['t'] l = params['l'] name = params['name'] ## Definition in EN standard ri = 1.0 * t ro = 1.5 * t # outer rectangle, going clockwise Vor1 = Vector((b / 2), (h / 2 - ro), 0) Vor2 = Vector((b / 2), (-h / 2 + ro), 0) Vor3 = Vector((b / 2 - ro), (-h / 2), 0) Vor4 = Vector((-b / 2 + ro), -h / 2, 0) Vor5 = Vector(-b / 2, (-h / 2 + ro), 0) Vor6 = Vector(-b / 2, (h / 2 - ro), 0) Vor7 = Vector((-b / 2 + ro), (h / 2), 0) Vor8 = Vector((b / 2 - ro), (h / 2), 0) Lor1 = makeLine(Vor1, Vor2) Lor2 = makeLine(Vor3, Vor4) Lor3 = makeLine(Vor5, Vor6) Lor4 = makeLine(Vor7, Vor8) # outer radius, going clockwise Voc1 = Vector((b / 2 - ro), (-h / 2 + ro), 0) Voc2 = Vector((-b / 2 + ro), (-h / 2 + ro), 0) Voc3 = Vector((-b / 2 + ro), (h / 2 - ro), 0) Voc4 = Vector((b / 2 - ro), (h / 2 - ro), 0) normal = Vector(0, 0, 1) Coc1 = makeCircle(ro, Voc1, normal, 270, 0) Coc2 = makeCircle(ro, Voc2, normal, 180, 270) Coc3 = makeCircle(ro, Voc3, normal, 90, 180) Coc4 = makeCircle(ro, Voc4, normal, 0, 90) # inner rectangle, going clockwise Vir1 = Vector((b / 2 - t), (h / 2 - t - ri), 0) Vir2 = Vector((b / 2 - t), (-h / 2 + t + ri), 0) Vir3 = Vector((b / 2 - t - ri), (-h / 2 + t), 0) Vir4 = Vector((-b / 2 + t + ri), (-h / 2 + t), 0) Vir5 = Vector((-b / 2 + t), (-h / 2 + t + ri), 0) Vir6 = Vector((-b / 2 + t), (h / 2 - t - ri), 0) Vir7 = Vector((-b / 2 + t + ri), (h / 2 - t), 0) Vir8 = Vector((b / 2 - t - ri), (h / 2 - t), 0) Lir1 = makeLine(Vir1, Vir2) Lir2 = makeLine(Vir3, Vir4) Lir3 = makeLine(Vir5, Vir6) Lir4 = makeLine(Vir7, Vir8) # inner radius, going clockwise Vic1 = Vector((b / 2 - t - ri), (-h / 2 + t + ri), 0) Vic2 = Vector((-b / 2 + t + ri), (-h / 2 + t + ri), 0) Vic3 = Vector((-b / 2 + t + ri), (h / 2 - t - ri), 0) Vic4 = Vector((b / 2 - t - ri), (h / 2 - t - ri), 0) normal = Vector(0, 0, 1) Cic1 = makeCircle(ri, Vic1, normal, 270, 0) Cic2 = makeCircle(ri, Vic2, normal, 180, 270) Cic3 = makeCircle(ri, Vic3, normal, 90, 180) Cic4 = makeCircle(ri, Vic4, normal, 0, 90) # putting the segments together, make wires, make faces, extrude them and cut them Wo = Part.Wire([ Lor1, Coc1, Lor2, Coc2, Lor3, Coc3, Lor4, Coc4, ]) Wi = Part.Wire([ Lir1, Cic1, Lir2, Cic2, Lir3, Cic3, Lir4, Cic4, ]) face = Part.Face([Wo, Wi]) if params['arch']: part = Arch.makeStructure(name=name) prof = document.addObject("Part::Feature", "Profile") prof.Shape = face part.Base = prof part.Height = l else: part = document.addObject("Part::Feature", "BOLTS_part") part.Label = name outer = Part.Face(Wo) inner = Part.Face(Wi) part.Shape = outer.cut(inner).extrude(Vector(0, 0, l))
def ibeam_parallel_flange(params, document): key = params['type'] h = params['h'] b = params['b'] tf = params['tf'] tw = params['tw'] r = params['r'] l = params['l'] name = params['name'] # lower flange, starting at the left web fillet, going against clockwise Vlf1 = Vector((-tw / 2 - r), (-h / 2 + tf), 0) Vlf2 = Vector(-b / 2, (-h / 2 + tf), 0) Vlf3 = Vector(-b / 2, -h / 2, 0) Vlf4 = Vector(b / 2, -h / 2, 0) Vlf5 = Vector(b / 2, (-h / 2 + tf), 0) Vlf6 = Vector((tw / 2 + r), (-h / 2 + tf), 0) Llf1 = makeLine(Vlf1, Vlf2) Llf2 = makeLine(Vlf2, Vlf3) Llf3 = makeLine(Vlf3, Vlf4) Llf4 = makeLine(Vlf4, Vlf5) Llf5 = makeLine(Vlf5, Vlf6) # upper flange, starting at the rigth web fillet, going clockwise Vuf1 = Vector(tw / 2 + r, (h / 2 - tf), 0) Vuf2 = Vector(b / 2, (h / 2 - tf), 0) Vuf3 = Vector(b / 2, h / 2, 0) Vuf4 = Vector(-b / 2, h / 2, 0) Vuf5 = Vector(-b / 2, (h / 2 - tf), 0) Vuf6 = Vector((-tw / 2 - r), (h / 2 - tf), 0) Luf1 = makeLine(Vuf1, Vuf2) Luf2 = makeLine(Vuf2, Vuf3) Luf3 = makeLine(Vuf3, Vuf4) Luf4 = makeLine(Vuf4, Vuf5) Luf5 = makeLine(Vuf5, Vuf6) # web, starting rigth bottom, going against clockwise Vw1 = Vector(tw / 2, (-h / 2 + tf + r), 0) Vw2 = Vector(tw / 2, (h / 2 - tf - r), 0) Vw3 = Vector(-tw / 2, (h / 2 - tf - r), 0) Vw4 = Vector(-tw / 2, (-h / 2 + tf + r), 0) Lw1 = makeLine(Vw1, Vw2) Lw2 = makeLine(Vw3, Vw4) # center of the fillets, starting right bottom, going against clockwise Vfc1 = Vector((tw / 2 + r), (-h / 2 + tf + r), 0) Vfc2 = Vector((tw / 2 + r), (h / 2 - tf - r), 0) Vfc3 = Vector((-tw / 2 - r), (h / 2 - tf - r), 0) Vfc4 = Vector((-tw / 2 - r), (-h / 2 + tf + r), 0) normal = Vector(0, 0, 1) Cfc1 = makeCircle(r, Vfc1, normal, 180, 270) Cfc2 = makeCircle(r, Vfc2, normal, 90, 180) Cfc3 = makeCircle(r, Vfc3, normal, 0, 90) Cfc4 = makeCircle(r, Vfc4, normal, 270, 0) # putting the segments together make a wire, a face and extrude it W = Part.Wire([ Llf1, Llf2, Llf3, Llf4, Llf5, Cfc1, Lw1, Cfc2, Luf1, Luf2, Luf3, Luf4, Luf5, Cfc3, Lw2, Cfc4 ]) F = Part.Face(W) if params['arch']: part = Arch.makeStructure(name=name) prof = document.addObject("Part::Feature", "Profile") prof.Shape = F part.Base = prof part.Height = l else: part = document.addObject("Part::Feature", "BOLTS_part") part.Label = name beam = F.extrude(Vector(0, 0, l)) part.Shape = beam