def clone_tooth(base_shape): clone = gp_Trsf() grouped_shape = base_shape # Find a divisor, between 1 and 8, for the number_of teeth multiplier = 1 max_multiplier = 1 for i in range(0, 8): if num_teeth % multiplier == 0: max_multiplier = i + 1 multiplier = max_multiplier for i in range(1, multiplier): clone.SetRotation(gp_OZ(), -i * tooth_angle) rotated_shape = BRepBuilderAPI_Transform(base_shape, clone, True).Shape() grouped_shape = BRepAlgoAPI_Fuse(grouped_shape, rotated_shape).Shape() # Rotate the basic tooth and fuse together aggregated_shape = grouped_shape for i in range(1, int(num_teeth / multiplier)): clone.SetRotation(gp_OZ(), - i * multiplier * tooth_angle) rotated_shape = BRepBuilderAPI_Transform(grouped_shape, clone, True).Shape() aggregated_shape = BRepAlgoAPI_Fuse(aggregated_shape, rotated_shape).Shape() cylinder = BRepPrimAPI_MakeCylinder(gp_XOY(), top_radius - roller_diameter, thickness) aggregated_shape = BRepAlgoAPI_Fuse(aggregated_shape, cylinder.Shape()).Shape() return aggregated_shape
def __init__(self, shaft, blade, n_blades): self.shaft_solid = shaft.generate_solid() blade.apply_transformations(reflect=True) blade_solid = blade.generate_solid(max_deg=2, display=False, errors=None) blades = [] blades.append(blade_solid) for i in range(n_blades - 1): blade.rotate(rad_angle=1.0 * 2.0 * np.pi / float(n_blades)) blade_solid = blade.generate_solid(max_deg=2, display=False, errors=None) blades.append(blade_solid) blades_combined = blades[0] for i in range(len(blades) - 1): boolean_union = BRepAlgoAPI_Fuse(blades_combined, blades[i + 1]) boolean_union.Build() if not boolean_union.IsDone(): raise RuntimeError('Unsuccessful assembling of blade') blades_combined = boolean_union.Shape() boolean_union = BRepAlgoAPI_Fuse(self.shaft_solid, blades_combined) boolean_union.Build() result_compound = boolean_union.Shape() section_edges = boolean_union.SectionEdges() sewer = BRepBuilderAPI_Sewing(1e-2) sewer.Add(result_compound) sewer.Perform() self.sewed_full_body = sewer.SewedShape()
def create_model(self): for weld in self.weldsabw: self.weldmodels.append(weld.create_model()) for weld in self.weldsblw: self.weldmodels.append(weld.create_model()) for weld in self.weldsabw1: self.weldmodels.append(weld.create_model()) for weld in self.weldsblw1: self.weldmodels.append(weld.create_model()) for plate in self.plates: self.platemodels.append(plate.create_model()) welds = self.weldmodels weldarray = welds[0] for comp in welds: weldarray = BRepAlgoAPI_Fuse(comp, weldarray).Shape() plates = self.platemodels parray = plates[0] for comp in plates: parray = BRepAlgoAPI_Fuse(comp, parray).Shape() array = BRepAlgoAPI_Fuse(weldarray, parray).Shape() return array
def fillet(event=None): Box = BRepPrimAPI_MakeBox(gp_Pnt(-400, 0, 0), 200, 230, 180).Shape() fillet_ = BRepFilletAPI_MakeFillet(Box) # Add fillet on each edge for e in TopologyExplorer(Box).edges(): fillet_.Add(20, e) blendedBox = fillet_.Shape() P1 = gp_Pnt(250, 150, 75) S1 = BRepPrimAPI_MakeBox(300, 200, 200).Shape() S2 = BRepPrimAPI_MakeBox(P1, 120, 180, 70).Shape() Fuse = BRepAlgoAPI_Fuse(S1, S2) FusedShape = Fuse.Shape() fill = BRepFilletAPI_MakeFillet(FusedShape) for e in TopologyExplorer(FusedShape).edges(): fill.Add(e) for i in range(1, fill.NbContours() + 1): length = fill.Length(i) Rad = 0.15 * length fill.SetRadius(Rad, i, 1) blendedFusedSolids = fill.Shape() display.EraseAll() display.DisplayShape(blendedBox) display.DisplayShape(blendedFusedSolids) display.FitAll()
def createWedgeGeometry(self): wedgeL_1 = FilletWeld(b=self.T, h=self.T, L=self.L) wedgeL_2 = copy.deepcopy(wedgeL_1) wedgeW_1 = FilletWeld(b=self.T, h=self.T, L=self.W) wedgeW_2 = copy.deepcopy(wedgeW_1) wedgeL_1uDir = numpy.array([-1.0, 0.0, 0.0]) wedgeL_1wDir = numpy.array([0.0, -1.0, 0.0]) wedgeL_1.place(self.p3, wedgeL_1uDir, wedgeL_1wDir) wedgeL_1Model = wedgeL_1.create_model() wedgeL_2uDir = numpy.array([1.0, 0.0, 0.0]) wedgeL_2wDir = numpy.array([0.0, 1.0, 0.0]) wedgeL_2.place(self.p1, wedgeL_2uDir, wedgeL_2wDir) wedgeL_2Model = wedgeL_2.create_model() wedgeW_1uDir = numpy.array([0.0, 1.0, 0.0]) wedgeW_1wDir = numpy.array([-1.0, 0.0, 0.0]) wedgeW_1.place(self.p4, wedgeW_1uDir, wedgeW_1wDir) wedgeW_1Model = wedgeW_1.create_model() # wedgeW_2uDir = numpy.array([0.0, -1.0, 0.0]) wedgeW_2wDir = numpy.array([1.0, 0.0, 0.0]) wedgeW_2.place(self.p2, wedgeW_2uDir, wedgeW_2wDir) wedgeW_2Model = wedgeW_2.create_model() wedge = BRepAlgoAPI_Fuse(wedgeL_1Model, wedgeL_2Model).Shape() wedge = BRepAlgoAPI_Fuse(wedge, wedgeW_1Model).Shape() wedge = BRepAlgoAPI_Fuse(wedge, wedgeW_2Model).Shape() return wedge
def get_plates_models(self): plate = BRepAlgoAPI_Fuse(self.plate1_Model, self.plate2_Model).Shape() if (self.Obj.sec_profile == 'Back to Back Angles' or self.Obj.sec_profile == 'Back to Back Channels' or self.Obj.sec_profile == 'Star Angles') and self.inter_length > 1000: plate = BRepAlgoAPI_Fuse(plate, self.inter_conc_plates).Shape() return plate
def boolean_union(array): first = array[0] if len(array) > 1: for i in range(1, len(array)): other = array[i] fuse = BRepAlgoAPI_Fuse(first, other) first = fuse.Shape() return [first]
def get_models(self): columns = self.get_column_models() plate_conectors = self.get_plate_models() welds = self.get_welded_modules() CAD = BRepAlgoAPI_Fuse(columns, plate_conectors).Shape() CAD = BRepAlgoAPI_Fuse(CAD, welds).Shape() return CAD
def get_end_plates_models(self): if self.Obj.sec_profile == 'Star Angles': plate = BRepAlgoAPI_Fuse(self.plate1_Model,self.nutboltArrayLModels).Shape() else: plate = BRepAlgoAPI_Fuse(self.plate1_Model, self.nutboltArrayLModels).Shape() # if (self.Obj.sec_profile == 'Back to Back Angles' or self.Obj.sec_profile == 'Back to Back Channels' or self.Obj.sec_profile == 'Star Angles') and self.inter_length > 1000: # plate = BRepAlgoAPI_Fuse(plate, self.inter_conc_plates).Shape() return plate
def get_models(self): mem = self.get_members_models() plts = self.get_plates_models() nut_bolts = self.get_nut_bolt_array_models() array = BRepAlgoAPI_Fuse(mem, plts).Shape() array = BRepAlgoAPI_Fuse(array, nut_bolts).Shape() return array
def create_model(self): prism1 = self.plate1.create_model() prism2 = self.plate2.create_model() prism3 = self.plate3.create_model() prism4 = self.plate4.create_model() prism = BRepAlgoAPI_Fuse(prism1, prism2).Shape() prism = BRepAlgoAPI_Fuse(prism, prism3).Shape() prism = BRepAlgoAPI_Fuse(prism, prism4).Shape() return prism
def get_models(self): mem = self.get_welded_models() plts = self.get_plates_models() wlds = self.get_welded_models() array = BRepAlgoAPI_Fuse(mem, plts).Shape() array = BRepAlgoAPI_Fuse(array, wlds).Shape() return array
def get_models(self): welds = self.weldmodels weldarray = welds[0] for comp in welds: weldarray = BRepAlgoAPI_Fuse(comp, weldarray).Shape() plates = self.platemodels parray = plates[0] for comp in plates: parray = BRepAlgoAPI_Fuse(comp, parray).Shape() array = BRepAlgoAPI_Fuse(weldarray, parray).Shape() return array
def get_models(self): nut_bolts = self.models nbarray = nut_bolts[0] for comp in nut_bolts: nbarray = BRepAlgoAPI_Fuse(comp, nbarray).Shape() plates = self.platemodels parray = plates[0] for comp in plates: parray = BRepAlgoAPI_Fuse(comp, parray).Shape() array = BRepAlgoAPI_Fuse(nbarray, parray).Shape() return array
def create_model(self): prism1 = self.angle1.create_model() prism2 = self.angle2.create_model() prism3 = self.angle3.create_model() prism4 = self.angle4.create_model() prism5 = self.plate1.create_model() #prism6 = self.plate2.create_model() prism = BRepAlgoAPI_Fuse(prism1, prism2).Shape() prism = BRepAlgoAPI_Fuse(prism, prism3).Shape() prism = BRepAlgoAPI_Fuse(prism, prism4).Shape() # prism = BRepAlgoAPI_Fuse(prism, prism5).Shape() #prism = BRepAlgoAPI_Fuse(prism, prism6).Shape() return prism, [prism5]
def create_model(self): prism1 = self.Isection1.create_model() prism2 = self.Isection2.create_model() prism = BRepAlgoAPI_Fuse(prism1, prism2).Shape() return prism
def get_nut_bolt_models(self): nut_bolts = self.models nbarray = nut_bolts[0] for comp in nut_bolts: nbarray = BRepAlgoAPI_Fuse(comp, nbarray).Shape() return nbarray
def get_welded_models(self): if self.Obj.sec_profile == 'Angles' or self.Obj.sec_profile == 'Channels': welded_sec = [ self.weldHL11_Model, self.weldHL12_Model, self.weldHR11_Model, self.weldHR12_Model, self.weldVL11_Model, self.weldVR11_Model ] elif (self.Obj.sec_profile == 'Back to Back Angles' or self.Obj.sec_profile == 'Back to Back Channels' or self.Obj.sec_profile == 'Star Angles') and self.inter_length > 1000: welded_sec = [ self.weldHL11_Model, self.weldHL12_Model, self.weldHR11_Model, self.weldHR12_Model, self.weldVL11_Model, self.weldVR11_Model, self.weldHL21_Model, self.weldHL22_Model, self.weldHR21_Model, self.weldHR22_Model, self.weldVL21_Model, self.weldVR21_Model, self.inter_conc_welds ] else: welded_sec = [ self.weldHL11_Model, self.weldHL12_Model, self.weldHR11_Model, self.weldHR12_Model, self.weldVL11_Model, self.weldVR11_Model, self.weldHL21_Model, self.weldHL22_Model, self.weldHR21_Model, self.weldHR22_Model, self.weldVL21_Model, self.weldVR21_Model ] welds = welded_sec[0] for comp in welded_sec[1:]: welds = BRepAlgoAPI_Fuse(comp, welds).Shape() return welds
def pull(): """Pull profile on active WP onto active part.""" wp = win.activeWp if win.lineEditStack: length = float(win.lineEditStack.pop()) * win.unitscale wireOK = wp.makeWire() if not wireOK: print("Unable to make wire.") return wire = wp.wire workPart = win.activePart uid = win.activePartUID pullProfile = BRepBuilderAPI_MakeFace(wire) aPrismVec = wp.wVec * length tool = BRepPrimAPI_MakePrism(pullProfile.Shape(), aPrismVec).Shape() newPart = BRepAlgoAPI_Fuse(workPart, tool).Shape() win.erase_shape(uid) doc.replaceShape(uid, newPart) win.draw_shape(uid) win.setActivePart(uid) win.statusBar().showMessage("Pull operation complete") win.clearCallback() else: win.registerCallback(pullC) win.lineEdit.setFocus() statusText = "Enter pull distance (pos in +w direction)" win.statusBar().showMessage(statusText)
def get_welded_models(self): welds = self.weldmodels weldarray = welds[0] for comp in welds: weldarray = BRepAlgoAPI_Fuse(comp, weldarray).Shape() return weldarray
def fillet(event=None): display.EraseAll() box = BRepPrimAPI_MakeBox(gp_Pnt(-400, 0, 0), 200, 230, 180).Shape() fillet = BRepFilletAPI_MakeFillet(box) # Add fillet on each edge for e in TopologyExplorer(box).edges(): fillet.Add(20, e) blended_box = fillet.Shape() p_1 = gp_Pnt(250, 150, 75) s_1 = BRepPrimAPI_MakeBox(300, 200, 200).Shape() s_2 = BRepPrimAPI_MakeBox(p_1, 120, 180, 70).Shape() fused_shape = BRepAlgoAPI_Fuse(s_1, s_2).Shape() fill = BRepFilletAPI_MakeFillet(fused_shape) for e in TopologyExplorer(fused_shape).edges(): fill.Add(e) for i in range(1, fill.NbContours() + 1): length = fill.Length(i) radius = 0.15 * length fill.SetRadius(radius, i, 1) blended_fused_solids = fill.Shape() display.DisplayShape(blended_box) display.DisplayShape(blended_fused_solids, update=True)
def Write(self, path): if len(self.shapes)>0: u = self.shapes[0] for s in self.shapes[1:]: u = BRepAlgoAPI_Fuse(u, s).Shape() write_stl_file(u, path, mode=self.mode, linear_deflection=self.linear_deflection, angular_deflection=self.angular_deflection)
def get_welded_modules(self): """ :return: CAD model for all the welds """ if self.C.preference != 'Outside': welded_sec = [self.flangePlateWeldL11Model, self.flangePlateWeldL12Model, self.flangePlateWeldL21Model, self.flangePlateWeldL22Model, self.flangePlateWeldW11Model, self.flangePlateWeldW12Model, self.flangePlateWeldW21Model, self.flangePlateWeldW22Model, \ self.webPlateWeldL11Model, self.webPlateWeldL12Model, self.webPlateWeldL21Model, self.webPlateWeldL22Model, self.webPlateWeldW11Model, self.webPlateWeldW12Model, self.webPlateWeldW21Model, self.webPlateWeldW22Model, \ self.innerflangePlateWeldL11Model, self.innerflangePlateWeldL12Model, self.innerflangePlateWeldL21Model, self.innerflangePlateWeldL22Model, self.innerflangePlateWeldL31Model, self.innerflangePlateWeldL32Model, self.innerflangePlateWeldL41Model, self.innerflangePlateWeldL42Model, \ self.innerflangePlateWeldW11Model, self.innerflangePlateWeldW12Model, self.innerflangePlateWeldW21Model, self.innerflangePlateWeldW22Model, self.innerflangePlateWeldW31Model, self.innerflangePlateWeldW32Model, self.innerflangePlateWeldW41Model, self.innerflangePlateWeldW42Model] else: welded_sec = [self.flangePlateWeldL11Model, self.flangePlateWeldL12Model, self.flangePlateWeldL21Model, self.flangePlateWeldL22Model, self.flangePlateWeldW11Model, self.flangePlateWeldW12Model, self.flangePlateWeldW21Model, self.flangePlateWeldW22Model, \ self.webPlateWeldL11Model, self.webPlateWeldL12Model, self.webPlateWeldL21Model, self.webPlateWeldL22Model, self.webPlateWeldW11Model, self.webPlateWeldW12Model, self.webPlateWeldW21Model, self.webPlateWeldW22Model] welds = welded_sec[0] for comp in welded_sec[1:]: welds = BRepAlgoAPI_Fuse(comp, welds).Shape() welds = BRepAlgoAPI_Cut(welds, self.weldCutPlateModel).Shape() return welds
def get_nut_bolt_array_models(self): nut_bolts = self.nut_bolt_array.get_models() array = nut_bolts[0] for comp in nut_bolts: array = BRepAlgoAPI_Fuse(comp, array).Shape() return array
def centre_mass_vizuall(self): flag = 0 shape = 0 for name in self.modules: if flag == 0: cp = BRepBuilderAPI_Copy(self.modules[name]) cp.Perform(self.modules[name]) shape = cp.Shape() flag = 1 shape = BRepAlgoAPI_Fuse(shape, self.modules[name]).Shape() props = GProp_GProps() brepgprop_VolumeProperties(shape, props) # Get inertia properties mass = props.Mass() cog = props.CentreOfMass() matrix_of_inertia = props.MatrixOfInertia() # Display inertia properties # print("Cube mass = %s" % mass) cog_x, cog_y, cog_z = cog.Coord() # print("Center of mass: x = %f;y = %f;z = %f;" % (cog_x, cog_y, cog_z)) mat = props.MatrixOfInertia() ####################################################################################### list_1 = [mat.Value(1, 1), mat.Value(1, 2), mat.Value(1, 3)] list_2 = [mat.Value(2, 1), mat.Value(2, 2), mat.Value(2, 3)] list_3 = [mat.Value(3, 1), mat.Value(3, 2), mat.Value(3, 3)] print('\t'.join(str(i) for i in list_1)) print('\t'.join(str(i) for i in list_2)) print('\t'.join(str(i) for i in list_3)) var1 = (cog_x**2 + cog_y**2 + cog_z**2)**0.5 print(var1)
def get_column_models(self): """ :return: CAD mode for the columns """ columns = BRepAlgoAPI_Fuse(self.column1Model, self.column2Model).Shape() return columns
def create_model(self): boltCylinderex = BRepPrimAPI_MakeCylinder( gp_Ax2(getGpPt(self.p1), getGpDir(self.shaftDir)), self.r, self.cylex_length).Shape() boltCylinder1 = BRepPrimAPI_MakeCylinder( gp_Ax2(getGpPt(self.p1), getGpDir(-self.shaftDir)), self.r, self.cyl1_length).Shape() bolt_endplate = BRepPrimAPI_MakeBox(getGpPt(self.p3), self.endplate_width, self.endplate_width, self.endplate_thickness).Shape() Anchor_BOlt = BRepAlgoAPI_Fuse(boltCylinder1, bolt_endplate).Shape() Anchor_BOlt = BRepAlgoAPI_Fuse(boltCylinderex, Anchor_BOlt).Shape() return Anchor_BOlt
def get_plate_models(self): """ :return: CAD model for all the plates """ # plates_sec = [self.endPlate1Model, self.endPlate2Model] # plates = plates_sec[0] # # for comp in plates_sec[1:]: # plates = BRepAlgoAPI_Fuse(comp, plates).Shape() plates = BRepAlgoAPI_Fuse(self.endPlate1Model, self.endPlate2Model).Shape() if self.stiff == True: plates = BRepAlgoAPI_Fuse(plates, self.stiffener1Model).Shape() plates = BRepAlgoAPI_Fuse(plates, self.stiffener2Model).Shape() return plates
def fuse(event=None): display.EraseAll() box1 = BRepPrimAPI_MakeBox(2, 1, 1).Shape() box2 = BRepPrimAPI_MakeBox(2, 1, 1).Shape() box1 = translate_topods_from_vector(box1, gp_Vec(.5, .5, 0)) fuse_shp = BRepAlgoAPI_Fuse(box1, box2).Shape() display.DisplayShape(fuse_shp) display.FitAll()
def get_members_models(self): if self.Obj == 'Channels': member = self.member1_Model elif self.Obj == 'Back to Back Channels': member = BRepAlgoAPI_Fuse(self.member1_Model, self.member2_Model).Shape() return member