def getLinks(self): link_types = {} i = 0 while i < len(self.app_data): store = False if re.search("^LINKS", self.app_data[i], re.IGNORECASE): self.app_data.pop(i) store = True while store: if re.search("^END LINKS", self.app_data[i], re.IGNORECASE): self.app_data.pop(i) store = False #break out of inner loop return link_types elif re.search("^\\bLINK\\b", self.app_data[i], re.IGNORECASE): link = list(filter(None, self.app_data[i].split(" "))) link_name = link[LinkType.LINK_NAME] if link_name in link_types.keys(): error_msg = MessageCodes.ERROR_UNIQUE_PARAM_NAME error_msg.setMsg(error_msg.msg % ("LINK-%s" % link_name, "LINKS \n\n%s" % self.app_data[i])) Messages.showError(error_msg) link_types[link_name] = LinkType(link) self.app_data.pop(i) else: self.app_data.pop(i) i += 1 return link_types
def checkBuild(self): if self.build > Constants.CURRENT_BUILD: Messages.showError(MessageCodes.ERROR_LATER_VERSION) elif self.build < Constants.CURRENT_BUILD: Messages.showWarning(MessageCodes.WARNING_EARLIER_VERSION) else: #build number and file being run are compatible pass
def makeDxf(self, entities, number_of_beams): self.drawEntities(entities) #setup viewports VPort(self.dwg, number_of_beams) output_path = self.app_data.getOutPutFile() try: self.dwg.saveas(output_path) Messages.i("") Messages.i(MessageCodes.INFO_DXF_GENERATED % output_path) except PermissionError: Messages.showError(MessageCodes.ERROR_OPEN_DXF) Messages.continuePrompt(MessageCodes.INFO_CONTINUE_PROMPT)
def getSectionRight(self, props): section = "" try: section = props[Span.SPAN_SECTION_RIGHT] except KeyError: try: section = props[Span.SPAN_SECTION_LEFT] except: try: section = props[Span.SPAN_SECTION] except: Messages.showError(MessageCodes.ERROR_NO_BEAM_SECTIONS) return section
def getSupportTypes(self): support_types = {} i = 0 while i < len(self.app_data): store = False if re.search("^SUPPORT_TYPES", self.app_data[i], re.IGNORECASE): self.app_data.pop(i) store = True while store: if re.search("^END SUPPORT_TYPES", self.app_data[i], re.IGNORECASE): self.app_data.pop(i) store = False #break out of inner loop return support_types elif re.search("^\\bSUPPORT_TYPE\\b", self.app_data[i], re.IGNORECASE): support = list(filter(None, self.app_data[i].split(" "))) column_top = self.getColumn(support, Column.TOP, Beams.COLUMN_TOP) column_bottom = self.getColumn(support, Column.BOTTOM, Beams.COLUMN_BOTTOM) support_name = support[SupportType.NAME] support_type = SupportType(support_name, column_top, column_bottom) if support_name in support_types.keys(): error_msg = MessageCodes.ERROR_UNIQUE_PARAM_NAME error_msg.setMsg( error_msg.msg % ("SUPPORT_TYPE-%s" % support_name, "SUPPORT_TYPES \n\n%s" % self.app_data[i])) Messages.showError(error_msg) support_types[support_name] = support_type self.app_data.pop(i) else: i += 1 i += 1 # for name, props in self.app_data[Beams.SUPPORT_TYPES].items(): # Messages.i(MessageCodes.INFO_DATA_READ%name) # column_top = self.getColumn(props, Beams.COLUMN_TOP) # column_bottom = self.getColumn(props, Beams.COLUMN_BOTTOM) # support_types[name] = SupportType(column_top, column_bottom) return support_types
def getSections(self): sections = {} i = 0 while i < len(self.app_data): store = False if re.search("^SECTIONS", self.app_data[i], re.IGNORECASE): self.app_data.pop(i) store = True while store: if re.search("^END SECTIONS", self.app_data[i], re.IGNORECASE): self.app_data.pop(i) store = False #break out of inner loop return sections elif re.search("^\\bSECTION\\b", self.app_data[i], re.IGNORECASE): section = list(filter(None, self.app_data[i].split(" "))) section_name = section[Section.SECTION_NAME] if section_name in sections.keys(): error_msg = MessageCodes.ERROR_UNIQUE_PARAM_NAME error_msg.setMsg( error_msg.msg % ("SECTION-%s" % section_name, "SECTIONS \n\n%s" % self.app_data[i])) Messages.showError(error_msg) sections[section_name] = Section(section) self.app_data.pop(i) else: self.app_data.pop(i) i += 1 # for name, props in self.app_data[Beams.SECTIONS].items(): # Messages.i(MessageCodes.INFO_DATA_READ%name) # sections[name] = Section(name, props) if len(sections) == 0: print("The input has error") return sections
def showErrorMsg(self, errorMsg=""): msg = MessageCodes.ERROR_IN_INPUT msg.setMsg(msg.msg%("Spans", " ".join(self.props)+"\n%s"%errorMsg)) Messages.showError(msg)
def showErrorMsg(self, errorMsg=""): msg = MessageCodes.ERROR_IN_INPUT print(self.links_input) msg.setMsg(msg.msg % ("Links", " ".join(self.links_input) + "\n%s" % errorMsg)) Messages.showError(msg)
def getBeams(self): beams = {} i = 0 while i < len(self.app_data): store = False if re.search("^BEAMS", self.app_data[i], re.IGNORECASE): self.app_data.pop(i) store = True beam_name = None beam_depth = None spans = {} supports = {} grid_labels = {} span_index = 0 while store: if re.search("^\\bEND BEAMS\\b", self.app_data[i], re.IGNORECASE): self.app_data.pop(i) store = False #break out of inner loop return beams elif re.search("^END BEAM", self.app_data[i], re.IGNORECASE): #store data and reset parameters if beam_name in beams.keys(): error_msg = MessageCodes.ERROR_UNIQUE_PARAM_NAME error_msg.setMsg( error_msg.msg % ("BEAM-%s" % beam_name, "BEAMS \n\n%s" % self.app_data[i])) Messages.showError(error_msg) beams[beam_name] = Beam(beam_depth, spans, supports, grid_labels, beam_name) #reset data at the end of each beam beam_name = None beam_depth = None spans = {} supports = {} grid_labels = {} span_index = 0 self.app_data.pop(i) elif re.search("^\\bBEAM\\b", self.app_data[i], re.IGNORECASE): #store beams first beam = list(filter(None, self.app_data[i].split(" "))) beam_name = beam[1] beam_depth = beam[2] self.app_data.pop(i) elif re.search("^\\bSPAN\\b", self.app_data[i], re.IGNORECASE): span = list(filter(None, self.app_data[i].split(" "))) span_name = span[1] if span_name in spans.keys(): error_msg = MessageCodes.ERROR_UNIQUE_PARAM_NAME error_msg.setMsg(error_msg.msg % ("SPAN-%s" % span_name, "BEAM-%s SPANS \n\n%s" % (beam_name, self.app_data[i]))) Messages.showError(error_msg) spans[span_name] = Span(span_name, span, beam_name, span_index) span_index += 1 self.app_data.pop(i) elif re.search("^\\bSUPPORT\\b", self.app_data[i], re.IGNORECASE): support = list( filter(None, self.app_data[i].split(" "))) support_name = support[1] if support_name in supports.keys(): error_msg = MessageCodes.ERROR_UNIQUE_PARAM_NAME error_msg.setMsg(error_msg.msg % ("SUPPORT-%s" % support_name, "BEAM-%s SUPPORTS \n\n%s" % (beam_name, self.app_data[i]))) Messages.showError(error_msg) supports[support_name] = support[2] try: grid_labels[support_name] = support[3] except IndexError: grid_labels[support_name] = "" self.app_data.pop(i) else: self.app_data.pop(i) i += 1 Messages.d("Total Beams", len(beams)) return beams