From 3a33538fa928154000843c6ebf6bc836ee2cafeb Mon Sep 17 00:00:00 2001 From: deepa-chaudhari Date: Fri, 12 Jun 2015 00:09:27 +0530 Subject: implemented save cad file functionality --- Connections/Shear/Finplate/.txt | 3 + Connections/Shear/Finplate/Finplate0dot1.py | 1 + .../Shear/Finplate/colWebBeamWebConnectivity.py | 12 +- Connections/Shear/Finplate/fin.log | 12 ++ Connections/Shear/Finplate/finPlate.ui | 3 +- Connections/Shear/Finplate/finPlateMain.py | 166 ++++++++++----------- Connections/Shear/Finplate/finplate_calc1.py | 35 ++++- Connections/Shear/Finplate/nutBoltPlacement.py | 6 +- Connections/Shear/Finplate/saveINPUT.txt | 2 +- Connections/Shear/Finplate/ui_finPlate.py | 5 +- 10 files changed, 140 insertions(+), 105 deletions(-) diff --git a/Connections/Shear/Finplate/.txt b/Connections/Shear/Finplate/.txt index e69de29..85888f1 100644 --- a/Connections/Shear/Finplate/.txt +++ b/Connections/Shear/Finplate/.txt @@ -0,0 +1,3 @@ +Thu, 11 Jun 2015 21:09:27 INFO : Overall finplate connection design is safe +Thu, 11 Jun 2015 21:09:27 INFO : Overall finplate connection design is safe +Thu, 11 Jun 2015 21:09:40 INFO : Overall finplate connection design is safe \ No newline at end of file diff --git a/Connections/Shear/Finplate/Finplate0dot1.py b/Connections/Shear/Finplate/Finplate0dot1.py index c8c539a..dbae367 100644 --- a/Connections/Shear/Finplate/Finplate0dot1.py +++ b/Connections/Shear/Finplate/Finplate0dot1.py @@ -708,6 +708,7 @@ class MainController(QtGui.QMainWindow): def create2Dcad(self): + # ISection COLUMN diff --git a/Connections/Shear/Finplate/colWebBeamWebConnectivity.py b/Connections/Shear/Finplate/colWebBeamWebConnectivity.py index 7b45760..0617512 100644 --- a/Connections/Shear/Finplate/colWebBeamWebConnectivity.py +++ b/Connections/Shear/Finplate/colWebBeamWebConnectivity.py @@ -109,11 +109,15 @@ class ColWebBeamWeb(object): def get_models(self): '''Returning 3D models ''' - return [self.columnModel,self.beamModel, - self.weldModelLeft,self.weldModelRight, - self.plateModel]+ self.nutBoltArray.getnutboltModels() - + #+ self.nutBoltArray.getnutboltModels() + return [self.columnModel,self.plateModel, self.weldModelLeft,self.weldModelRight, + self.beamModel] + self.nutBoltArray.getModels() + + def get_nutboltmodels(self): + + return self.nutBoltArray.getModels() + #return self.nutBoltArray.getboltModels() \ No newline at end of file diff --git a/Connections/Shear/Finplate/fin.log b/Connections/Shear/Finplate/fin.log index d2e8b78..82081b6 100644 --- a/Connections/Shear/Finplate/fin.log +++ b/Connections/Shear/Finplate/fin.log @@ -1 +1,13 @@ + +
+ Thu, 11 Jun 2015 23:54:20 + INFO + : Overall finplate connection design is safe +
+ +
+ Thu, 11 Jun 2015 23:54:20 + INFO + : Overall finplate connection design is safe +
diff --git a/Connections/Shear/Finplate/finPlate.ui b/Connections/Shear/Finplate/finPlate.ui index 94561db..07555b9 100644 --- a/Connections/Shear/Finplate/finPlate.ui +++ b/Connections/Shear/Finplate/finPlate.ui @@ -590,7 +590,6 @@ - @@ -4169,7 +4168,7 @@ - Enlarge font size + Font diff --git a/Connections/Shear/Finplate/finPlateMain.py b/Connections/Shear/Finplate/finPlateMain.py index 26e1c9f..a8e0371 100644 --- a/Connections/Shear/Finplate/finPlateMain.py +++ b/Connections/Shear/Finplate/finPlateMain.py @@ -18,7 +18,7 @@ Created on 21-Aug-2014 @author: deepa ''' import sys -from OCC import VERSION +from OCC import VERSION, BRepTools, StlAPI #from PyQt4 import QtGui,QtCore from ui_finPlate import Ui_MainWindow from model import * @@ -27,7 +27,6 @@ from finplate_calc1 import finConn import yaml import pickle import logging -#from exampleSimpleGUI import init_display from OCC.BRepAlgoAPI import BRepAlgoAPI_Fuse from OCC._Quantity import Quantity_NOC_RED,Quantity_NOC_BLUE1,Quantity_NOC_SADDLEBROWN from ISection import ISection @@ -45,6 +44,10 @@ from colFlangeBeamWebConnectivity import ColFlangeBeamWeb from OCC import IGESControl from filletweld import FilletWeld from ModelUtils import * +from OCC.STEPControl import STEPControl_Writer, STEPControl_AsIs +from OCC.Interface import Interface_Static_SetCVal +from OCC.IFSelect import IFSelect_RetDone +from OCC.StlAPI import StlAPI_Writer class MainController(QtGui.QMainWindow): @@ -64,7 +67,7 @@ class MainController(QtGui.QMainWindow): self.ui.comboConnLoc.currentIndexChanged[str].connect(self.setimage_connection) - self.disableViewButtons() + #self.disableViewButtons() self.ui.btnInput.clicked.connect(lambda: self.dockbtn_clicked(self.ui.inputDock)) self.ui.btnOutput.clicked.connect(lambda: self.dockbtn_clicked(self.ui.outputDock)) @@ -73,7 +76,6 @@ class MainController(QtGui.QMainWindow): self.ui.btn_top.clicked.connect(self.call_Topview) self.ui.btn_side.clicked.connect(self.call_Sideview) - #self.ui.btn3D.clicked.connect(self.call_3DModel) self.ui.btn3D.clicked.connect(lambda:self.call_3DModel(True)) self.ui.chkBxBeam.clicked.connect(self.call_3DBeam) self.ui.chkBxCol.clicked.connect(self.call_3DColumn) @@ -99,6 +101,17 @@ class MainController(QtGui.QMainWindow): maxfyVal = 450 self.ui.txtFy.editingFinished.connect(lambda: self.check_range(self.ui.txtFy,self.ui.lbl_fy, minfyVal, maxfyVal)) + ##### MenuBar ##### + self.ui.actionQuit_fin_plate_design.setShortcut('Ctrl+Q') + self.ui.actionQuit_fin_plate_design.setStatusTip('Exit application') + self.ui.actionQuit_fin_plate_design.triggered.connect(QtGui.qApp.quit) + + self.ui.actionCreate_design_report.triggered.connect(self.save_design) + self.ui.actionSave_log_messages.triggered.connect(self.save_log) + self.ui.actionEnlarge_font_size.triggered.connect(self.showFontDialogue) + self.ui.actionZoom_in.triggered.connect(self.callZoomin) + + self.ui.combo_Beam.addItems(get_beamcombolist()) self.ui.comboColSec.addItems(get_columncombolist()) self.ui.combo_Beam.currentIndexChanged[str].connect(self.populatePlateThickCombo) @@ -124,6 +137,8 @@ class MainController(QtGui.QMainWindow): #self.ui.btnSvgSave.clicked.connect(lambda:self.saveTopng(self.display)) self.connectivity = None + self.fuse_model = None + #self.colWebBeamWeb = self.create3DColWebBeamWeb() # my_box = BRepPrimAPI_MakeBox(gp_Pnt(20,0,0),10., 20., 30.).Shape() # my_cylendar = BRepPrimAPI_MakeCylinder(10,30).Shape() @@ -133,6 +148,15 @@ class MainController(QtGui.QMainWindow): #self.fuse_model = self.create2Dcad() #self.fuse_model = my_sphere + def showFontDialogue(self): + font, ok = QtGui.QFontDialog.getFont() + if ok: + self.ui.inputDock.setFont(font) + self.ui.outputDock.setFont(font) + self.ui.textEdit.setFont(font) + + def callZoomin(self): + self.display.DynamicZoom() def disableViewButtons(self): ''' @@ -162,13 +186,9 @@ class MainController(QtGui.QMainWindow): def populatePlateThickCombo(self): dictbeamdata = self.fetchBeamPara() -# beam_sec = self.ui.combo_Beam.currentText() -# dictbeamdata = get_beamdata(beam_sec) beam_tw = float(dictbeamdata[QString("tw")]) - #comboPlateItems = [str(self.ui.comboPlateThick_2.itemText(i)) for i in range(self.ui.comboPlateThick_2.count())] plateThickness = [6,8,10,12,14,16,18,20] newlist = [] - #comboPlateThickItenewlist = [] for ele in plateThickness[:]: item = int(ele) if item >= beam_tw: @@ -653,49 +673,14 @@ class MainController(QtGui.QMainWindow): osdagDisplayShape(self.display, self.connectivity.weldModelLeft, color = 'red', update = True) osdagDisplayShape(self.display, self.connectivity.weldModelRight, color = 'red', update = True) osdagDisplayShape(self.display,self.connectivity.plateModel,color = 'blue', update = True) - self.display.DisplayShape(self.connectivity.nutBoltArray.getnutboltModels(), color = Quantity_NOC_SADDLEBROWN, update=True) + self.display.DisplayShape(self.connectivity.nutBoltArray.getModels(), color = Quantity_NOC_SADDLEBROWN, update=True) elif component == "Model": osdagDisplayShape(self.display, self.connectivity.columnModel, update=True) osdagDisplayShape(self.display, self.connectivity.beamModel, material = Graphic3d_NOT_2D_ALUMINUM, update=True) osdagDisplayShape(self.display, self.connectivity.weldModelLeft, color = 'red', update = True) osdagDisplayShape(self.display, self.connectivity.weldModelRight, color = 'red', update = True) osdagDisplayShape(self.display,self.connectivity.plateModel,color = 'blue', update = True) - self.display.DisplayShape(self.connectivity.nutBoltArray.getnutboltModels(), color = Quantity_NOC_SADDLEBROWN, update=True) - - - def display3Dmodelold(self,cadlist,component): - self.display.EraseAll() - self.display.SetModeShaded() - #self.display,_ = self.init_display(backend_str="pyqt4") - self.display.set_bg_gradient_color(23,1,32,23,1,32) - - if component == "Column": - - osdagDisplayShape(self.display, cadlist[0], update=True) - elif component == "Beam": - self.display.EraseAll() - osdagDisplayShape(self.display, cadlist[1],material = Graphic3d_NOT_2D_ALUMINUM, update=True) - elif component == "Finplate" : - display.EraseAll() - osdagDisplayShape(self.display,cadlist[2],color = 'red', update = True) - osdagDisplayShape(self.display, cadlist[3], color = 'red', update = True) - osdagDisplayShape(self.display, cadlist[4], color = 'blue', update = True) - self.display.DisplayShape(cadlist[5:8],color = Quantity_NOC_SADDLEBROWN, update=True) - self.display.DisplayShape(cadlist[8:11],color = Quantity_NOC_SADDLEBROWN, update = True) - elif component == "Model": - self.display.EraseAll() - #osdagDisplayShape(self.display, cadlist[0], update=True) - osdagDisplayShape(self.display, cadlist[1],material = Graphic3d_NOT_2D_ALUMINUM, update=True) - #osdagDisplayShape(self.display,cadlist[2],color = 'red', update = True) - #osdagDisplayShape(self.display,cadlist[3],color = 'red', update = True) - osdagDisplayShape(self.display, cadlist[4], color = 'blue', update = True) - self.display.DisplayShape(cadlist[5:8],color = Quantity_NOC_SADDLEBROWN, update=True) - self.display.DisplayShape(cadlist[8:11],color = Quantity_NOC_SADDLEBROWN, update = True) - #osdagDisplayShape(self.display, cadlist[11], update = True) - else: - pass - - start_display() + self.display.DisplayShape(self.connectivity.nutBoltArray.getModels(), color = Quantity_NOC_SADDLEBROWN, update=True) def fetchBeamPara(self): beam_sec = self.ui.combo_Beam.currentText() @@ -744,7 +729,6 @@ class MainController(QtGui.QMainWindow): #column = ISection(B = 83, T = 14.1, D = 250, t = 11, R1 = 12, R2 = 3.2, alpha = 98, length = 1000) column = ISection(B = column_B, T = column_T, D = column_D, t = column_tw, R1 = column_R1, R2 = column_R2, alpha = column_alpha, length = 1000) - # Outputs from finPlateCalc1 #### WELD,PLATE,BOLT AND NUT PARAMETERS ##### fillet_length = resultObj['Plate']['height'] @@ -797,32 +781,6 @@ class MainController(QtGui.QMainWindow): colflangeconn = ColFlangeBeamWeb(column,beam,weld,plate,boltRadius,nutRadius) return colflangeconn.create_3dmodel() - def call_3DModelduplicate(self): - self.display.EraseAll() - uiObj = self.getuser_inputs() - resultObj = finConn(uiObj) - for k in resultObj.keys(): - for key in resultObj[k].keys(): - if (resultObj[k][key] != ""): - if self.ui.btn3D.isEnabled(): - self.ui.chkBxBeam.setChecked(QtCore.Qt.Unchecked) - self.ui.chkBxCol.setChecked(QtCore.Qt.Unchecked) - self.ui.chkBxFinplate.setChecked(QtCore.Qt.Unchecked) - self.ui.mytabWidget.setCurrentIndex(0) - - if self.ui.comboConnLoc.currentText()== "Column web-Beam web": - connectivity = self.colWebBeamWeb - else: - self.ui.mytabWidget.setCurrentIndex(0) - connectivity = self.createColFlangeBeamWeb() - - self.display3Dmodel(connectivity.get_models(), "Model") - plateOrigin = connectivity.plate.secOrigin - gpPntplateOrigin= getGpPt(plateOrigin) - my_sphere = BRepPrimAPI_MakeSphere(gpPntplateOrigin,2).Shape() - #self.display.DisplayShape(my_sphere,update=True) - else: - self.display.DisplayMessage(gp_Pnt(1000,0,400),"Sorry, can not create 3D model",height = 25.0) def call_3DModel(self,flag): @@ -836,9 +794,11 @@ class MainController(QtGui.QMainWindow): if self.ui.comboConnLoc.currentText()== "Column web-Beam web": #self.create3DColWebBeamWeb() self.connectivity = self.create3DColWebBeamWeb() + self.fuse_model = None else: self.ui.mytabWidget.setCurrentIndex(0) self.connectivity = self.createColFlangeBeamWeb() + self.fuse_model = None self.display3Dmodel("Model") #plateOrigin = self.connectivity.plate.secOrigin @@ -908,11 +868,12 @@ class MainController(QtGui.QMainWindow): self.call_3DModel(status) - def create2Dcad(self,cadlist): + def create2Dcad(self,connectivity): - #cadlist = self.connectivity.get_models() - + cadlist = self.connectivity.get_models() + print len(cadlist) final_model = cadlist[0] + #model = cadlist[1] for model in cadlist[1:]: final_model = BRepAlgoAPI_Fuse(model,final_model).Shape() return final_model @@ -920,14 +881,43 @@ class MainController(QtGui.QMainWindow): # Export to IGES def save3DtoIGES(self): - - shape = self.create2Dcad() - i = IGESControl.IGESControl_Controller() - i.Init() - iges_writer = IGESControl.IGESControl_Writer() - iges_writer.AddShape(shape) - iges_writer.Write('/home/deepa/Pictures/osdag.iges') - + if self.connectivity == None: + self.connectivity = self.create3DColWebBeamWeb() + if self.fuse_model == None: + self.fuse_model = self.create2Dcad(self.connectivity) + shape = self.fuse_model + + files_types = "IGS (*.igs);;STEP (*.stp);;STL (*.stl);;BREP(*.brep)" + fileName = QtGui.QFileDialog.getSaveFileName(self, 'Export', "/home/Cadfiles/untitled.igs", files_types ) + fName = str(fileName) + file_extension = fName.split(".")[-1] + + if file_extension == 'igs': + IGESControl.IGESControl_Controller().Init() + iges_writer = IGESControl.IGESControl_Writer() + iges_writer.AddShape(shape) + iges_writer.Write(fName) + + elif file_extension == 'brep': + + BRepTools.breptools.Write(shape, fName) + + elif file_extension == 'stp': + # initialize the STEP exporter + step_writer = STEPControl_Writer() + Interface_Static_SetCVal("write.step.schema", "AP203") + + # transfer shapes and write file + step_writer.Transfer(shape, STEPControl_AsIs) + status = step_writer.Write(fName) + + assert(status == IFSelect_RetDone) + + else: + stl_writer = StlAPI_Writer() + stl_writer.SetASCIIMode(True) + stl_writer.Write(shape,fName) + def display2DModelOriginal(self, final_model, viewName): self.display,_ = self.init_display() @@ -1003,9 +993,13 @@ class MainController(QtGui.QMainWindow): self.display.EraseAll() self.ui.mytabWidget.setCurrentIndex(1) - self.connectivity = self.create3DColWebBeamWeb() - final_model = self.create2Dcad(self.connectivity.get_models()) - self.display2DModel(final_model,"Front") + #Sself.connectivity = self.create3DColWebBeamWeb() + #memberlist = self.connectivity.get_models() + if self.connectivity == None: + self.connectivity = self.create3DColWebBeamWeb() + if self.fuse_model == None: + self.fuse_model = self.create2Dcad(self.connectivity) + self.display2DModel( self.fuse_model,"Front") diff --git a/Connections/Shear/Finplate/finplate_calc1.py b/Connections/Shear/Finplate/finplate_calc1.py index 24d152d..5f934c8 100644 --- a/Connections/Shear/Finplate/finplate_calc1.py +++ b/Connections/Shear/Finplate/finplate_calc1.py @@ -152,9 +152,10 @@ def finConn(uiObj): web_plate_l = max_plate_height ; elif min_plate_height > max_plate_height: - logger.error(": Height of plate is more than the clear depth of the beam") + logger.error(": Minimum required plate height is more than the clear depth of the beam") + logger.warning(": Minimum plate height required is %2.2f mm " % (min_plate_height)) logger.warning(": Maximum plate height allowed is %2.2f mm " % (max_plate_height)) - + logger.info(": Increase the plate thickness") #print "Error: Height of plate is more than the clear depth of the beam" #print" Maximum plate height allowed is " + str(max_plate_height) + " mm" web_plate_l = max_plate_height; @@ -276,7 +277,7 @@ def finConn(uiObj): else: logger.error(": Bolt strength is insufficient to carry the shear force") logger.warning (": Increase bolt diameter and/or bolt grade") - + moment_demand=0.0 #################################################################################### # Design of plate: @@ -404,9 +405,11 @@ def finConn(uiObj): outputObj['Plate']['momentcapacity'] = moment_capacity outputObj['Plate']['height'] = web_plate_l outputObj['Plate']['width'] = web_plate_w + + #return outputObj - if web_plate_l == min_plate_height+10 or web_plate_l == (max_plate_height-10)//10*10: + if web_plate_l == (min_plate_height+10) or web_plate_l == ((max_plate_height-10)//10*10): if bolt_line==2: if pitch < min_pitch: for k in outputObj.keys(): @@ -414,6 +417,22 @@ def finConn(uiObj): outputObj[k][key] = "" else: return outputObj + + elif web_plate_l == (min_plate_height+10) or web_plate_l == ((max_plate_height-10)//10*10): + if web_plate_l == min_plate_height or web_plate_l == max_plate_height or web_plate_l < web_plate_l_req or web_plate_w < web_plate_w_req: + for k in outputObj.keys(): + for key in outputObj[k].keys(): + outputObj[k][key] = "" + elif moment_capacity < moment_demand: + for k in outputObj.keys(): + for key in outputObj[k].keys(): + outputObj[k][key] = "" + elif bolt_line==2: + if pitch < min_pitch: + for k in outputObj.keys(): + for key in outputObj[k].keys(): + outputObj[k][key] = "" + else: if web_plate_l == min_plate_height or web_plate_l == max_plate_height or web_plate_l < web_plate_l_req or web_plate_w < web_plate_w_req: for k in outputObj.keys(): @@ -428,14 +447,18 @@ def finConn(uiObj): for k in outputObj.keys(): for key in outputObj[k].keys(): outputObj[k][key] = "" - + # if web_plate_l == min_plate_height or web_plate_l == max_plate_height or web_plate_l < web_plate_l_req or web_plate_w < web_plate_w_req: # outputObj = {} # # elif moment_capacity < moment_demand: # outputObj = {} + if outputObj['Bolt']['status'] == True: - + logger.info(": Overall finplate connection design is safe") + else: + logger.error(": Design is not safe") + return outputObj diff --git a/Connections/Shear/Finplate/nutBoltPlacement.py b/Connections/Shear/Finplate/nutBoltPlacement.py index 88ce850..627f9c9 100644 --- a/Connections/Shear/Finplate/nutBoltPlacement.py +++ b/Connections/Shear/Finplate/nutBoltPlacement.py @@ -30,7 +30,7 @@ class NutBoltArray(): #self.calculatePositions() self.models = [] - + def initialiseNutBolts(self): b = self.bolt n = self.nut @@ -83,11 +83,11 @@ class NutBoltArray(): dbg = self.dbgSphere(self.origin) self.models.append(dbg) - + def dbgSphere(self, pt): return BRepPrimAPI_MakeSphere(getGpPt(pt), 0.1).Shape() - def getnutboltModels(self): + def getModels(self): return self.models \ No newline at end of file diff --git a/Connections/Shear/Finplate/saveINPUT.txt b/Connections/Shear/Finplate/saveINPUT.txt index 54ca750..478e639 100644 --- a/Connections/Shear/Finplate/saveINPUT.txt +++ b/Connections/Shear/Finplate/saveINPUT.txt @@ -56,5 +56,5 @@ S'HSFG' p26 sS'diameter(mm)' p27 -I12 +I20 ss. \ No newline at end of file diff --git a/Connections/Shear/Finplate/ui_finPlate.py b/Connections/Shear/Finplate/ui_finPlate.py index 1c41207..cb41631 100644 --- a/Connections/Shear/Finplate/ui_finPlate.py +++ b/Connections/Shear/Finplate/ui_finPlate.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'finPlate.ui' # -# Created: Sat Jun 6 12:28:08 2015 +# Created: Thu Jun 11 17:13:02 2015 # by: PyQt4 UI code generator 4.10.4 # # WARNING! All changes made in this file will be lost! @@ -1450,7 +1450,6 @@ class Ui_MainWindow(object): self.menuEdit.addAction(self.actionPaste) self.menuView.addAction(self.actionEnlarge_font_size) self.menuView.addSeparator() - self.menuView.addAction(self.actionReduce_font_size) self.menuHelp.addAction(self.actionAbout_Osdag) self.menuGraphics.addAction(self.actionZoom_in) self.menuGraphics.addSeparator() @@ -1673,7 +1672,7 @@ class Ui_MainWindow(object): self.actionView_2D_on_YZ.setText(_translate("MainWindow", "View 2D on YZ", None)) self.actionView_2D_on_ZX.setText(_translate("MainWindow", "View 2D on ZX", None)) self.actionModel.setText(_translate("MainWindow", "Model", None)) - self.actionEnlarge_font_size.setText(_translate("MainWindow", "Enlarge font size", None)) + self.actionEnlarge_font_size.setText(_translate("MainWindow", "Font", None)) self.actionReduce_font_size.setText(_translate("MainWindow", "Reduce font size", None)) self.actionSave_3D_model_as.setText(_translate("MainWindow", "Save 3D model as", None)) self.actionSave_current_2D_image_as.setText(_translate("MainWindow", "Save 2D image as", None)) -- cgit