Beispiel #1
0
 def Activated(self):
     from safe.punch import opening
     import etabs_obj
     etabs = etabs_obj.EtabsModel(backup=False)
     etabs.set_current_unit('kN', 'mm')
     points = etabs.select_obj.get_selected_obj_type(1)
     if len(points) > 2:
         points_xyz = list(etabs.points.get_points_coords(points).values())
     height = 4000
     foun = None
     doc = FreeCAD.ActiveDocument
     if hasattr(doc, 'Foundation'):
         foun = doc.Foundation
         height = foun.height.Value
         z = foun.level.Value
     else:
         if hasattr(doc, 'Beam'):
             z = doc.Beam.start_point.z
     points_vec = [FreeCAD.Vector(p[0], p[1], z) for p in points_xyz]
     # wire = Draft.make_wire(points_vec)
     opening_obj = opening.make_opening(points_vec, height=height)
     if foun is not None:
         opening_objs = foun.openings + [opening_obj]
         foun.openings = opening_objs
     doc.recompute()
 def Activated(self):
     from gui_civiltools.gui_check_legal import (
         allowed_to_continue,
         show_warning_about_number_of_use
     )
     allow, check = allowed_to_continue(
         'export_to_etabs.bin',
         'https://gist.githubusercontent.com/ebrahimraeyat/7f10571fab2a08b7a17ab782778e53e1/raw',
         'cfactor'
         )
     if not allow:
         return
     import etabs_obj
     etabs = etabs_obj.EtabsModel(backup=False)
     if not etabs.success:
         from PySide2.QtWidgets import QMessageBox
         QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
         return False
     from py_widget import aj_correction
     win = aj_correction.Form(etabs)
     import FreeCADGui as Gui
     Gui.Control.showDialog(win)
     # mdi = get_mdiarea()
     # if not mdi:
     #     return None
     # sub = mdi.addSubWindow(win)
     # sub.show()
     show_warning_about_number_of_use(check)
 def Activated(self):
     
     from gui_civiltools.gui_check_legal import (
             allowed_to_continue,
             show_warning_about_number_of_use,
             )
     allow, check = allowed_to_continue(
         'show_drifts.bin',
         'https://gist.githubusercontent.com/ebrahimraeyat/7f10571fab2a08b7a17ab782778e53e1/raw',
         'cfactor'
         )
     if not allow:
         return
     import etabs_obj
     etabs = etabs_obj.EtabsModel()
     if not etabs.success:
         QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
         return False
     etabs_filename = etabs.get_filename()
     json_file = etabs_filename.with_suffix('.json')
     if not json_file.exists():
         QMessageBox.warning(None, 'Settings', 'Please Set Options First!')
         Gui.runCommand("civiltools_settings")
         return
     from py_widget import drift
     win = drift.Form(etabs, json_file)
     Gui.Control.showDialog(win)
     show_warning_about_number_of_use(check)
    def Activated(self):

        from gui_civiltools.gui_check_legal import (
            allowed_to_continue,
            show_warning_about_number_of_use,
        )
        allow, check = allowed_to_continue(
            '100-30.bin',
            'https://gist.githubusercontent.com/ebrahimraeyat/bbfab4efcc50cbcfeba7288339b68c90/raw',
            'cfactor',
            n=2,
        )
        if not allow:
            return
        import etabs_obj
        etabs = etabs_obj.EtabsModel(backup=False)
        if not etabs.success:
            QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
            return False
        ex, ey = etabs.load_patterns.get_EX_EY_load_pattern()
        if ex is None or ey is None:
            QMessageBox.warning(None, 'ETABS',
                                'Please Define EX and EY in ETABS Model.')
            return False
        from py_widget.control import columns_100_30
        win = columns_100_30.Form(etabs, ex, ey)
        Gui.Control.showDialog(win)
        show_warning_about_number_of_use(check)
Beispiel #5
0
 def __init__(self):
     self.form = Gui.PySideUic.loadUi(
         str(punch_path / 'Resources' / 'ui' / 'etabs_panel.ui'))
     self.etabs = etabs_obj.EtabsModel(backup=False)
     # self.set_foundation_level()
     self.set_load_cases()
     self.set_story()
     self.set_filename()
     self.create_connections()
Beispiel #6
0
 def Activated(self):
     import etabs_obj
     etabs = etabs_obj.EtabsModel(backup=False)
     if not etabs.success:
         from PySide2.QtWidgets import QMessageBox
         QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
         return False
     from py_widget.control import shear_story
     win = shear_story.Form(etabs)
     Gui.Control.showDialog(win)
Beispiel #7
0
    def Activated(self):

        import etabs_obj
        etabs = etabs_obj.EtabsModel(backup=False)
        if not etabs.success:
            QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
            return False
        from py_widget.tools import delete_backups
        win = delete_backups.Form(etabs)
        Gui.Control.showDialog(win)
Beispiel #8
0
 def __init__(self,
         beam_names : Union[list, bool] = None,
         etabs_model : Union['etabs_obj.EtabsModel' , bool] = None,
         top_of_foundation : float = 0,
         ):
     if etabs_model is None:
         import etabs_obj
         self.etabs = etabs_obj.EtabsModel(backup=False)
     else:
         self.etabs = etabs_model
     self.etabs.set_current_unit('kN', 'mm')
     self.beam_names = beam_names
     self.top_of_foundation = top_of_foundation
 def Activated(self):
     import etabs_obj
     etabs = etabs_obj.EtabsModel(backup=False)
     if not etabs.success:
         from PySide2.QtWidgets import QMessageBox
         ret = QMessageBox.question(
             None, 'ETABS',
             'ETABS is not open or not recognized by civil Tools. If ETABS is open, please run both ETABS and FreeCAD with Administrator and restart both FreeCAD and ETABS. Do you want to continue?'
         )
         if ret == QMessageBox.StandardButton.Cancel:
             return False
     from py_widget.assign import wall_load_on_frames
     win = wall_load_on_frames.Form(etabs)
     Gui.Control.showDialog(win)
 def set_unit(action):
     utext = action.text().replace("&", "")
     # unit = [0,4,1,3,7,5][unitsList.index(utext)]
     action.parent().parent().parent().setText(utext)
     etabs = etabs_obj.EtabsModel(backup=False)
     if etabs.success:
         mw = FreeCADGui.getMainWindow()
         statuswidget = mw.findChild(QtGui.QToolBar,
                                     "CivilToolsStatusWidget")
         force = statuswidget.force_label.text()
         length = statuswidget.length_label.text()
         print(force, length)
         print('changed')
         etabs.set_current_unit(force, length)
Beispiel #11
0
 def export_to_etabs(self):
     allow, check = self.allowed_to_continue(
         'sections_to_etabs.bin',
         'https://gist.githubusercontent.com/ebrahimraeyat/988ef54bcd7f42246744fd519d220a2c/raw',
         'section',
         n=2,
         )
     if not allow:
         return
     sys.path.insert(0, str(civiltools_path))
     import etabs_obj
     etabs = etabs_obj.EtabsModel()
     etabs.sections.import_sections_to_etabs(self.model1.sections)
     msg = "Successfully written to Etabs."
     QMessageBox.information(None, "done", msg)
     self.show_warning_about_number_of_use(check)       
 def Activated(self):
     import etabs_obj
     etabs = etabs_obj.EtabsModel(backup=False)
     if not etabs.success:
         QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
         return False
     etabs_filename = etabs.get_filename()
     json_file = etabs_filename.with_suffix('.json')
     if not json_file.exists():
         QMessageBox.warning(None, 'Settings', 'Please Set Options First!')
         Gui.runCommand("civiltools_settings")
         return
     tx, ty, _ = etabs.get_drift_periods()
     config.save_analytical_periods(json_file, tx, ty)
     t_file = etabs.get_filepath() / 'T.EDB'
     QMessageBox.information(None, 'Successful',
                             f'Created Period File: {t_file}')
 def Activated(self):
     from gui_civiltools.gui_check_legal import (
             allowed_to_continue,
             show_warning_about_number_of_use,
             )
     allow, check = allowed_to_continue(
         'explode_loads.bin',
         'https://gist.githubusercontent.com/ebrahimraeyat/f05421c70967b698ca9016a1bdb54b01/raw',
         'cfactor',
         )
     if not allow:
         return
     import etabs_obj
     from py_widget import explode_seismic_load_patterns
     etabs = etabs_obj.EtabsModel()
     panel = explode_seismic_load_patterns.Form(etabs)
     Gui.Control.showDialog(panel)
     show_warning_about_number_of_use(check)
 def Activated(self):
     import etabs_obj
     etabs = etabs_obj.EtabsModel(backup=False)
     if not etabs.success:
         from PySide2.QtWidgets import QMessageBox
         QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
         return False
     from py_widget import show_siffness_story_way
     win = show_siffness_story_way.Form(etabs)
     e_name = etabs.get_file_name_without_suffix()
     way_radio_button = {'2800': win.form.radio_button_2800,
                         'modal': win.form.radio_button_modal,
                         'earthquake': win.form.radio_button_earthquake}
     for w, rb in way_radio_button.items():
         name = f'{e_name}_story_stiffness_{w}_table.json'
         json_file = Path(etabs.SapModel.GetModelFilepath()) / name
         if not json_file.exists():
             rb.setChecked(False)
             rb.setEnabled(False)
     Gui.Control.showDialog(win)
 def Activated(self):
     from gui_civiltools.gui_check_legal import (
         allowed_to_continue, show_warning_about_number_of_use)
     allow, check = allowed_to_continue(
         'response_spectrum.bin',
         'https://gist.githubusercontent.com/ebrahimraeyat/2370d564be6b4ba2508f8314a3358970/raw',
         'cfactor',
         n=2,
     )
     if not allow:
         return
     import etabs_obj
     etabs = etabs_obj.EtabsModel(backup=False)
     if not etabs.success:
         from PySide2.QtWidgets import QMessageBox
         QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
         return False
     from py_widget import response_spectrum
     import FreeCADGui as Gui
     win = response_spectrum.Form(etabs)
     Gui.Control.showDialog(win)
     show_warning_about_number_of_use(check)
 def Activated(self):
     
     # from gui_civiltools.gui_check_legal import (
     #         allowed_to_continue,
     #         show_warning_about_number_of_use,
     #         )
     # allow, check = allowed_to_continue(
     #     '100-30.bin',
     #     'https://gist.githubusercontent.com/ebrahimraeyat/bbfab4efcc50cbcfeba7288339b68c90/raw',
     #     'cfactor',
     #     n=2,
     #     )
     # if not allow:
     #     return
     import etabs_obj
     etabs = etabs_obj.EtabsModel(backup=False)
     if not etabs.success:
         QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
         return False
     from py_widget.define import create_load_combinations
     win = create_load_combinations.Form(etabs)
     Gui.Control.showDialog(win)
Beispiel #17
0
    def Activated(self):

        from gui_civiltools.gui_check_legal import (
            allowed_to_continue,
            show_warning_about_number_of_use,
        )
        allow, check = allowed_to_continue(
            'correct_j.bin',
            'https://gist.githubusercontent.com/ebrahimraeyat/98b4863d25f0779dce2347d73a99212b/raw',
            'cfactor',
        )
        if not allow:
            return
        import etabs_obj
        etabs = etabs_obj.EtabsModel()
        if not etabs.success:
            from PySide2.QtWidgets import QMessageBox
            QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
            return False
        from py_widget import beam_j
        win = beam_j.Form(etabs)
        Gui.Control.showDialog(win)
        show_warning_about_number_of_use(check)
    def Activated(self):

        from gui_civiltools.gui_check_legal import (
            allowed_to_continue,
            show_warning_about_number_of_use,
        )
        allow, check = allowed_to_continue(
            'high_pressure_columns.bin',
            'https://gist.githubusercontent.com/ebrahimraeyat/4800d8c54ee47c50032cd70d45cf43ee/raw',
            'cfactor',
            n=2,
        )
        if not allow:
            return
        import etabs_obj
        etabs = etabs_obj.EtabsModel(backup=False)
        if not etabs.success:
            from PySide2.QtWidgets import QMessageBox
            QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
            return False
        from py_widget.control import high_pressure_columns
        win = high_pressure_columns.Form(etabs)
        Gui.Control.showDialog(win)
        show_warning_about_number_of_use(check)
Beispiel #19
0
 def Activated(self):
     
     from gui_civiltools.gui_check_legal import (
             allowed_to_continue,
             show_warning_about_number_of_use,
             )
     allow, check = allowed_to_continue(
         'weakness.bin',
         'https://gist.githubusercontent.com/ebrahimraeyat/3c8c1d0229dc76ec23982af1173aa46a/raw',
         'cfactor',
         n=2,
         )
     if not allow:
         return
     from py_widget import get_weakness
     import etabs_obj
     etabs = etabs_obj.EtabsModel(backup=False)
     if not etabs.success:
         from PySide2.QtWidgets import QMessageBox
         QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
         return False
     win = get_weakness.Form(etabs)
     Gui.Control.showDialog(win)
     show_warning_about_number_of_use(check)
Beispiel #20
0
    def Activated(self):

        from gui_civiltools.gui_check_legal import (
            allowed_to_continue,
            show_warning_about_number_of_use,
        )
        allow, check = allowed_to_continue(
            'assign_frame_section.bin',
            'https://gist.githubusercontent.com/ebrahimraeyat/7a72a787854de95017f389e2936f75d5/raw',
            'cfactor',
            n=5,
        )
        if not allow:
            return
        import etabs_obj
        etabs = etabs_obj.EtabsModel(backup=False)
        if not etabs.success:
            from PySide2.QtWidgets import QMessageBox
            QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
            return False
        from py_widget.assign import assign_frame_sections
        win = assign_frame_sections.Form(etabs)
        Gui.Control.showDialog(win)
        show_warning_about_number_of_use(check)
    def Activated(self):

        from gui_civiltools.gui_check_legal import (
            allowed_to_continue,
            show_warning_about_number_of_use,
        )
        allow, check = allowed_to_continue(
            'stiffness.bin',
            'https://gist.githubusercontent.com/ebrahimraeyat/e5635c17392c73540a46761a7247836e/raw',
            'cfactor',
            n=2,
        )
        if not allow:
            return
        import etabs_obj
        etabs = etabs_obj.EtabsModel(backup=False)
        if not etabs.success:
            from PySide2.QtWidgets import QMessageBox
            QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
            return False
        from py_widget import get_siffness_story_way
        win = get_siffness_story_way.Form(etabs)
        Gui.Control.showDialog(win)
        show_warning_about_number_of_use(check)
Beispiel #22
0
    def Activated(self):

        from gui_civiltools.gui_check_legal import (
            allowed_to_continue,
            show_warning_about_number_of_use,
        )
        allow, check = allowed_to_continue(
            'torsion.bin',
            'https://gist.githubusercontent.com/ebrahimraeyat/d1591790a52a62b3e66bb70f45738105/raw',
            'cfactor',
            n=2,
        )
        if not allow:
            return
        from py_widget import torsion
        import etabs_obj
        etabs = etabs_obj.EtabsModel(backup=False)
        if not etabs.success:
            from PySide2.QtWidgets import QMessageBox
            QMessageBox.warning(None, 'ETABS', 'Please open etabs file!')
            return False
        win = torsion.Form(etabs)
        Gui.Control.showDialog(win)
        show_warning_about_number_of_use(check)
def test_assign_wall_loads_to_etabs():
    mod_path = civiltools_path.parent
    sys.path.insert(0, str(mod_path))
    import etabs_obj
    etabs = etabs_obj.EtabsModel(backup=False)
    wall_loads.assign_wall_loads_to_etabs(etabs)
 def __init__(self, parent=None):
     self.form = Gui.PySideUic.loadUi(
         str(punch_path / 'Resources' / 'ui' /
             'explode_seismic_load_patterns.ui'))
     self.etabs = etabs_obj.EtabsModel(backup=False)
     self.form.start_button.clicked.connect(self.accept)
Beispiel #25
0
 def accept(self):
     software = self.form.software.currentText()
     is_slabs = self.form.slabs_checkbox.isChecked()
     is_area_loads = self.form.loads_checkbox.isChecked()
     is_openings = self.form.openings_checkbox.isChecked()
     is_strips = self.form.strips_checkbox.isChecked()
     is_stiffs = self.form.stiff_elements_checkbox.isChecked()
     is_punches = self.form.punches.isChecked()
     soil_name = self.form.soil_name.text()
     soil_modulus = self.form.soil_modulus.value()
     is_2d = 'Yes' if self.form.analysis_2d.isChecked() else 'No'
     max_mesh_size = self.form.max_mesh_size.value()
     doc = FreeCAD.ActiveDocument
     slab_names = []
     software_name = software.split()[0]
     if software in ('SAFE 20', 'ETABS 19'):
         import etabs_obj
         etabs = etabs_obj.EtabsModel(backup=False, software=software_name)
         etabs.unlock_model()
         if is_slabs:
             slab_names = etabs.area.export_freecad_slabs(
                 doc,
                 soil_name=soil_name,
                 soil_modulus=soil_modulus,
             )
         if is_area_loads:
             try:
                 loads = doc.findObjects(Type='Fem::ConstraintForce')
                 for load in loads:
                     etabs.area.set_uniform_gravity_load(
                         slab_names,
                         load.loadcase,
                         load.Force,
                         )
             except TypeError:
                 print('Can not find any loads in model')
         if self.form.wall_loads.isChecked():
             etabs.area.export_freecad_wall_loads(doc)
         if is_openings:
             etabs.area.export_freecad_openings(doc)
         if is_strips:
             if doc.Foundation.foundation_type == 'Strip':
                 etabs.area.export_freecad_strips(doc)
         if is_stiffs:
             etabs.area.export_freecad_stiff_elements(doc)
         if is_punches:
             punches = []
             for o in doc.Objects:
                 if hasattr(o, "Proxy") and \
                     hasattr(o.Proxy, "Type") and \
                     o.Proxy.Type == "Punch":
                     punches.append(o)
             etabs.database.create_punching_shear_general_table(punches)
             etabs.database.create_punching_shear_perimeter_table(punches)
         etabs.SapModel.View.RefreshView()
     elif software == 'SAFE 16':
         from safe.punch.safe_read_write_f2k import FreecadReadwriteModel as FRW
         f2k_file = doc.Safe
         input_f2k_path = f2k_file.input
         output_f2k_path = f2k_file.output
         rw = FRW(input_f2k_path, output_f2k_path, doc)
         if is_slabs:
             slab_names = rw.export_freecad_slabs(
                 soil_name=soil_name,
                 soil_modulus=soil_modulus,
             )
             if is_area_loads:
                 try:
                     loads = doc.findObjects(Type='Fem::ConstraintForce')
                     for load in loads:
                         rw.add_uniform_gravity_load(
                             slab_names,
                             load.loadcase,
                             load.Force,
                             )
                 except TypeError:
                     print('Can not find any loads in model')
         rw.safe.set_analysis_type(is_2d=is_2d)
         rw.safe.set_mesh_options(mesh_size=max_mesh_size)
         if self.form.wall_loads.isChecked():
             rw.export_freecad_wall_loads()
         if is_openings:
             rw.export_freecad_openings(doc)
         if is_strips:
             rw.export_freecad_strips()
         if is_stiffs:
             rw.export_freecad_stiff_elements()
         if is_punches:
             rw.export_punch_props()
         rw.add_preferences()
         rw.safe.write()
     Gui.Control.closeDialog()
def setStatusIcons(show=True):

    "shows or hides the BIM icons in the status bar"

    import FreeCADGui
    from PySide import QtCore, QtGui
    import etabs_obj

    force_units = ['kgf', 'N', 'kN', 'tonf']
    length_units = ['m', 'cm', 'mm']

    def set_unit(action):
        utext = action.text().replace("&", "")
        # unit = [0,4,1,3,7,5][unitsList.index(utext)]
        action.parent().parent().parent().setText(utext)
        etabs = etabs_obj.EtabsModel(backup=False)
        if etabs.success:
            mw = FreeCADGui.getMainWindow()
            statuswidget = mw.findChild(QtGui.QToolBar,
                                        "CivilToolsStatusWidget")
            force = statuswidget.force_label.text()
            length = statuswidget.length_label.text()
            print(force, length)
            print('changed')
            etabs.set_current_unit(force, length)

    def addonMgr():

        mw = FreeCADGui.getMainWindow()
        if mw:
            st = mw.statusBar()
            statuswidget = st.findChild(QtGui.QToolBar,
                                        "CivilToolsStatusWidget")
            if statuswidget:
                updatebutton = statuswidget.findChild(QtGui.QPushButton,
                                                      "UpdateButton")
                if updatebutton:
                    statuswidget.actions()[-1].setVisible(False)
        FreeCADGui.runCommand("Std_AddonMgr")

    class CheckWorker(QtCore.QThread):

        updateAvailable = QtCore.Signal(bool)

        def __init__(self):

            QtCore.QThread.__init__(self)

        def run(self):

            try:
                import git
            except ImportError:
                return
            FreeCAD.Console.PrintLog(
                "Checking for available updates of the civilTools workbench\n")
            civiltools_dir = os.path.join(FreeCAD.getUserAppDataDir(), "Mod",
                                          "civilTools")
            etabs_api_dir = os.path.join(FreeCAD.getUserAppDataDir(), "Mod",
                                         "etabs_api")
            for directory in (civiltools_dir, etabs_api_dir):
                if os.path.exists(directory) and os.path.exists(directory +
                                                                os.sep +
                                                                '.git'):
                    gitrepo = git.Git(directory)
                    try:
                        gitrepo.fetch()
                        if "git pull" in gitrepo.status():
                            self.updateAvailable.emit(True)
                            return
                    except:
                        # can fail for any number of reasons, ex. not being online
                        pass
            self.updateAvailable.emit(False)

    def checkUpdates():
        FreeCAD.civiltools_update_checker = CheckWorker()
        FreeCAD.civiltools_update_checker.updateAvailable.connect(
            showUpdateButton)
        FreeCAD.civiltools_update_checker.start()

    def showUpdateButton(avail):
        if avail:
            FreeCAD.Console.PrintLog("A civilTools update is available\n")
            mw = FreeCADGui.getMainWindow()
            if mw:
                st = mw.statusBar()
                statuswidget = st.findChild(QtGui.QToolBar,
                                            "CivilToolsStatusWidget")
                if statuswidget:
                    updatebutton = statuswidget.findChild(
                        QtGui.QPushButton, "UpdateButton")
                    if updatebutton:
                        # updatebutton.show() # doesn't work for some reason
                        statuswidget.actions()[-1].setVisible(True)
        else:
            FreeCAD.Console.PrintLog("No civilTools update available\n")
        if hasattr(FreeCAD, "civiltools_update_checker"):
            del FreeCAD.civiltools_update_checker

    # main code

    mw = FreeCADGui.getMainWindow()
    if mw:
        st = mw.statusBar()
        statuswidget = st.findChild(QtGui.QToolBar, "CivilToolsStatusWidget")
        if show:
            if statuswidget:
                statuswidget.show()
            else:
                statuswidget = QtGui.QToolBar()
                statuswidget.setObjectName("CivilToolsStatusWidget")
                # force menue
                force_label = QtGui.QPushButton("force")
                force_label.setObjectName("force_label")
                force_label.setFlat(True)
                menu = QtGui.QMenu(force_label)
                g_force_units = QtGui.QActionGroup(menu)
                for u in force_units:
                    a = QtGui.QAction(g_force_units)
                    a.setText(u)
                    menu.addAction(a)
                force_label.setMenu(menu)
                g_force_units.triggered.connect(set_unit)
                etabs = etabs_obj.EtabsModel(backup=False)
                force, length = 'kgf', 'm'
                if etabs.success:
                    force, length = etabs.get_current_unit()
                force_label.setText(force)
                force_label.setToolTip(
                    translate("civiltools", "The preferred force unit"))
                statuswidget.addWidget(force_label)
                statuswidget.force_label = force_label
                st.addPermanentWidget(statuswidget)
                # length menue
                length_label = QtGui.QPushButton("force")
                length_label.setObjectName("length_label")
                length_label.setFlat(True)
                menu = QtGui.QMenu(length_label)
                g_length_units = QtGui.QActionGroup(menu)
                for u in length_units:
                    a = QtGui.QAction(g_length_units)
                    a.setText(u)
                    menu.addAction(a)
                length_label.setMenu(menu)
                g_length_units.triggered.connect(set_unit)
                etabs = etabs_obj.EtabsModel(backup=False)
                length_label.setText(length)
                length_label.setToolTip(
                    translate("civiltools", "The preferred length unit"))
                statuswidget.addWidget(length_label)
                statuswidget.length_label = length_label

                # update notifier button (starts hidden)
                updatebutton = QtGui.QPushButton()
                bwidth = updatebutton.fontMetrics().boundingRect(
                    "AAAA").width()
                updatebutton.setObjectName("UpdateButton")
                updatebutton.setMaximumWidth(bwidth)
                updatebutton.setIcon(
                    QtGui.QIcon(
                        os.path.join(os.path.dirname(__file__), "images",
                                     "update.png")))
                updatebutton.setText("")
                updatebutton.setToolTip(
                    translate(
                        "civilTools",
                        "An update to the civilTools workbench is available. Click here to open the addons manager."
                    ))
                updatebutton.setFlat(True)
                QtCore.QObject.connect(updatebutton,
                                       QtCore.SIGNAL("pressed()"), addonMgr)
                updatebutton.hide()
                statuswidget.addWidget(updatebutton)
                QtCore.QTimer.singleShot(
                    2500, checkUpdates
                )  # delay a bit the check for civilTools WB update...
        else:
            if statuswidget:
                statuswidget.hide()
            else:
                # when switching workbenches, the toolbar sometimes "jumps"
                # out of the status bar to any other dock area...
                statuswidget = mw.findChild(QtGui.QToolBar,
                                            "CivilToolsStatusWidget")
                if statuswidget:
                    statuswidget.hide()