Example #1
0
    def Initialize(self):
        def QT_TRANSLATE_NOOP(scope, text):
            return text

        #import GDMLCommands, GDMLResources
        commands=['CycleCommand','ExpandCommand', \
              'PolyHedraCommand', 'BoxCommand','ConeCommand','ElTubeCommand', \
              'EllipsoidCommand','SphereCommand', \
              'TrapCommand','TubeCommand','AddCompound', \
              'TessellateCommand', 'Mesh2TessCommand']
        toolbarcommands=['CycleCommand','ExpandCommand',
              'PolyHedraCommand', 'BoxCommand','ConeCommand', \
                  'ElTubeCommand', 'EllipsoidCommand','SphereCommand', \
                  'TrapCommand','TubeCommand','AddCompound', \
                  'TessellateCommand', 'Mesh2TessCommand']

        parttoolbarcommands = ['Part_Cut', 'Part_Fuse', 'Part_Common']
        meshtoolbarcommands = ['Mesh_FromPartShape']

        self.appendToolbar(QT_TRANSLATE_NOOP('Workbench', 'GDMLTools'),
                           toolbarcommands)
        self.appendMenu('GDML', commands)
        self.appendToolbar(QT_TRANSLATE_NOOP('Workbech', 'GDML Part tools'),
                           parttoolbarcommands)
        FreeCADGui.addIconPath(joinDir("Resources/icons"))
        FreeCADGui.addLanguagePath(joinDir("Resources/translations"))
        FreeCADGui.addPreferencePage(joinDir("Resources/ui/GDML-base.ui"),
                                     "GDML")
Example #2
0
    def Initialize(self):
        import tools
        global Dir
        
        Gui.addCommand('CreateGlider', tools.CreateGlider())
        Gui.addCommand('ShapeCommand', tools.ShapeCommand())
        Gui.addCommand('AirfoilCommand', tools.AirfoilCommand())
        Gui.addCommand('ArcCommand', tools.ArcCommand())
        Gui.addCommand("AoaCommand", tools.AoaCommand())
        Gui.addCommand("BallooningCommand", tools.BallooningCommand())
        Gui.addCommand("LineCommand", tools.LineCommand())

        Gui.addCommand("ImportGlider", tools.ImportGlider())
        Gui.addCommand("Gl2dExport", tools.Gl2dExport())
        Gui.addCommand("AirfoilMergeCommand", tools.AirfoilMergeCommand())
        Gui.addCommand("BallooningMergeCommand", tools.BallooningMergCommand())
        Gui.addCommand("CellCommand", tools.CellCommand())
        Gui.addCommand("ZrotCommand", tools.ZrotCommand())
        Gui.addCommand("DesignCommand", tools.DesignCommand())

        Gui.addCommand("PatternCommand", tools.PatternCommand())
        Gui.addCommand("PanelCommand", tools.PanelCommand())
        Gui.addCommand("PolarsCommand", tools.PolarsCommand())

        Gui.addCommand("RefreshCommand", tools.RefreshCommand())

        self.appendToolbar("Tools", self.toolBox)
        self.appendToolbar("Production", self.productionBox)
        self.appendToolbar("Develop", self.devBox)
        self.appendMenu("Tools", self.toolBox)
        self.appendMenu("Production", self.productionBox)

        Gui.addPreferencePage(Dir + "/ui/preferences.ui", "Display")
def addPreferencePage():

    """Adds the CAD Exchanger preferences page to FreeCAD"""

    if FreeCAD.GuiUp:
        import FreeCADGui
        FreeCADGui.addPreferencePage(os.path.join(os.path.dirname(__file__),"CADExchangerIO.ui"),"Import-Export")
Example #4
0
    def Initialize(self):
        """This function is executed when FreeCAD starts"""
        import RebarTools

        from BillOfMaterial.BOMPreferences import BOMPreferences
        from pathlib import Path

        self.rebar_commands = RebarTools.ReinforcementCommands
        self.appendToolbar("RebarCommands", self.rebar_commands)

        BOMPreferences()
        FreeCADGui.addPreferencePage(
            str(
                Path(RebarTools.__file__).parent.absolute()
                / "BillOfMaterial"
                / "BOMPreferences.ui"
            ),
            "Reinforcement",
        )
        FreeCADGui.addIconPath(
            str(
                Path(RebarTools.__file__).parent.absolute()
                / "icons"
                / "preferences"
            )
        )
Example #5
0
    def Initialize(self):
        from . import tools
        global Dir

        Gui.addCommand('CreateGlider', tools.CreateGlider())
        Gui.addCommand('ShapeCommand', tools.ShapeCommand())
        Gui.addCommand('AirfoilCommand', tools.AirfoilCommand())
        Gui.addCommand('ArcCommand', tools.ArcCommand())
        Gui.addCommand('AoaCommand', tools.AoaCommand())
        Gui.addCommand('BallooningCommand', tools.BallooningCommand())
        Gui.addCommand('LineCommand', tools.LineCommand())
        Gui.addCommand('LineObserveCommand', tools.LineObserveCommand())

        Gui.addCommand('ImportGlider', tools.ImportGlider())
        Gui.addCommand('Gl2dExport', tools.Gl2dExport())
        Gui.addCommand('AirfoilMergeCommand', tools.AirfoilMergeCommand())
        Gui.addCommand('BallooningMergeCommand', tools.BallooningMergCommand())
        Gui.addCommand('CellCommand', tools.CellCommand())
        Gui.addCommand('ZrotCommand', tools.ZrotCommand())
        Gui.addCommand('CutCommand', tools.CutCommand())
        Gui.addCommand('ColorCommand', tools.ColorCommand())

        Gui.addCommand('PatternCommand', tools.PatternCommand())
        Gui.addCommand('PanelCommand', tools.PanelCommand())
        Gui.addCommand('PolarsCommand', tools.PolarsCommand())

        Gui.addCommand('GliderRibFeatureCommand',
                       tools.GliderRibFeatureCommand())
        Gui.addCommand('GliderBallooningFeatureCommand',
                       tools.GliderBallooningFeatureCommand())
        Gui.addCommand('GliderSharkFeatureCommand',
                       tools.GliderSharkFeatureCommand())
        Gui.addCommand('GliderSingleSkinRibFeatureCommand',
                       tools.GliderSingleSkinRibFeatureCommand())
        Gui.addCommand('GliderHoleFeatureCommand',
                       tools.GliderHoleFeatureCommand())
        Gui.addCommand('GliderFlapFeatureCommand',
                       tools.GliderFlapFeatureCommand())
        Gui.addCommand('GliderScaleFeatureCommand',
                       tools.GliderScaleFeatureCommand())
        Gui.addCommand('GliderBallooningMultiplierFeatureCommand',
                       tools.GliderBallooningMultiplierFeatureCommand())

        Gui.addCommand('ViewCommand', tools.ViewCommand())

        Gui.addCommand('RefreshCommand', tools.RefreshCommand())

        self.appendToolbar('GliderTools', self.toolBox)
        self.appendToolbar('Production', self.productionBox)
        self.appendToolbar('Feature', self.featureBox)
        self.appendToolbar('GliderView', self.viewBox)
        self.appendToolbar('Develop', self.devBox)

        self.appendMenu('GliderTools', self.toolBox)
        self.appendMenu('Production', self.productionBox)
        self.appendMenu('Feature', self.featureBox)
        self.appendToolbar('GliderView', self.viewBox)
        self.appendToolbar('Develop', self.devBox)

        Gui.addPreferencePage(Dir + '/ui/preferences.ui', 'Display')
Example #6
0
    def Initialize(self):
        # load the module
        # import GD&T tools
        try:
            from . import datum_feature
            from . import datum_system
            from . import geometric_tolerance
            from . import annotation_plane
            from . import inventory
        except ImportError:
            FreeCAD.Console.PrintWarning(
                "Error: Initializing one or more of the GD&T modules failed, GD&T will not work as expected.\n"
            )

        self.cmdList = [
            'dd_datumFeature', 'dd_datumSystem', 'dd_geometricTolerance',
            'dd_annotationPlane'
        ]
        self.inventory = ['dd_inventory']
        self.appendToolbar("GD&T Tools", self.cmdList + self.inventory)
        self.appendMenu("GD&T Tools", self.cmdList + self.inventory)

        gui.addIconPath(str(ICON_DIR))
        gui.addPreferencePage(
            str(DIR / 'Resources' / 'ui' / 'preferences-gdt.ui'), 'GDT')

        Log("Loading Geometric Dimensioning & Tolerancing... done\n")
Example #7
0
    def Initialize(self):
        import kicadStepUpCMD, sys
        global pref_page
        pref_page = True # False #True #
        import FreeCADGui

        submenu = ['demo.kicad_pcb','d-pak.kicad_mod', 'demo-sketch.FCStd', 'demo.step',\
                   'footprint-template.FCStd', 'footprint-Edge-template.FCStd', 'footprint-template-roundrect-polylines.FCStd',\
                   'footprint-RF-antenna.FCStd', 'footprint-RF-antenna-w-solder-Mask.FCStd', 'RF-antenna-dxf.dxf', \
                   'complex-Polyline-footprint.FCStd', 'footprint-complex-arc-pads.FCStd', \
                   'footprint-SPU0410LR5H.FCStd',\
                   'kicadStepUp-cheat-sheet.pdf', 'kicad-3D-to-MCAD.pdf', 'Generating-a-KiCAD-footprint-and-Model-from-3D-Step-Data.pdf' ]
        dirs = self.ListDemos()

        #self.appendToolbar("ksu Tools", ["ksuTools"])
        self.appendToolbar("ksu Tools", ["ksuToolsEditPrefs","ksuTools","ksuToolsOpenBoard","ksuToolsLoadFootprint",\
                           "ksuToolsExportModel","ksuToolsPushPCB","ksuToolsFootprintGen","Separator","ksuToolsAddTracks","ksuToolsAddSilks","Separator",\
                           "ksuToolsCollisions","ksuToolsImport3DStep","ksuToolsExport3DStep","ksuToolsMakeUnion",\
                           "ksuToolsMakeCompound", "ksuToolsSimpleCopy", "ksuToolsDeepCopy", "ksuToolsCheckSolid"])
                           #, "ksuToolsPushMoved","ksuToolsSync3DModels"])
        self.appendToolbar("ksu Sketching", ["ksuTools3D2D", "ksuTools2D2Sketch", "ksuTools2DtoFace",\
                           "ksuToolsLoopSelection","ksuToolsEdges2Sketch","ksuToolsOffset2D","ksuToolsExtrude","ksuToolsMergeSketches",\
                           "ksuToolsSimplifySketck", "ksuToolsBsplineNormalize", "ksuToolsConstrainator", "ksuToolsSkValidate", "ksuToolsDiscretize"])
                           #, "ksuToolsPushMoved","ksuToolsSync3DModels"])
        ksuTB = ["ksuToolsOpenBoard","ksuToolsPushPCB","ksuToolsPushMoved","ksuToolsSync3DModels","ksuToolsPullPCB","ksuToolsPullMoved","ksuAsm2Part",\
                 "Separator","ksuToolsGeneratePositions","ksuToolsComparePositions",\
                 "Separator","ksuToolsToggleTreeView","Separator","ksuRemoveTimeStamp","ksuRemoveSuffix","Separator","ksuToolsLoadFootprint","ksuToolsFootprintGen"]
        #ksuTB.extend(["Separator","ksuToolsAligner","ksuToolsMover","ksuToolsCaliper"])
        self.appendToolbar("ksu PushPull", ksuTB)
        combined_path = '\t'.join(sys.path)
        if 'Manipulator' in combined_path:
            ksuDTB=["ksuToolsAligner","ksuToolsMover","ksuToolsCaliper","Separator","ksuToolsDefeaturingTools"]
            self.appendToolbar("ksu Design Tools", ksuDTB)
        Hlp_TB = ["ksuToolsToggleTreeView", "Restore_Transparency", "ksuToolsTransparencyToggle", "ksuToolsHighlightToggle",\
                            "ksuToolsVisibilityToggle", "ksuToolsStepImportModeSTD", "ksuToolsStepImportModeComp",\
                            "ksuToolsCopyPlacement", "ksuToolsResetPlacement", "ksuToolsResetPartPlacement", "ksuToolsAddToTree",\
                            "ksuToolsRemoveFromTree", "ksuToolsRemoveSubTree", "checkSolidExpSTEP"]
        #if 'LinkView' in dir(FreeCADGui):
        #    Hlp_TB.remove("ksuToolsHighlightToggle")
        self.appendToolbar("ksu Show", ["ksuToolsTurnTable", "ksuToolsExplode"])
        self.appendToolbar("ksu Helpers", Hlp_TB)
        #self.appendMenu("ksu Tools", ["ksuTools","ksuToolsEdit"])
        self.appendMenu("ksu Tools", ["ksuTools","ksuToolsEditPrefs"])
        self.appendMenu("ksu PushPull", ["ksuToolsOpenBoard","ksuToolsPushPCB","ksuToolsPushMoved","ksuToolsSync3DModels","ksuToolsPullPCB","ksuToolsPullMoved",\
                        "Separator","ksuToolsGeneratePositions","ksuToolsComparePositions",\
                        "Separator","ksuRemoveTimeStamp","ksuRemoveSuffix",\
                        "Separator","ksuToolsLoadFootprint","ksuToolsFootprintGen"])
        self.appendMenu(["ksu Tools", "Demo"], submenu)
        
        #FreeCADGui.addPreferencePage( a2plib.pathOfModule() + '/GuiA2p/ui/a2p_prefs.ui','A2plus' )
        if pref_page:
            FreeCADGui.addPreferencePage(
                ksuWB_ui_path + '/ksu_prefs.ui',
                'kicadStepUpGui'
                )
            FreeCADGui.addPreferencePage(kSU_MainPrefPage,"kicadStepUpGui")

        FreeCADGui.addIconPath(ksuWB_icons_path)
        Log ("Loading ksuModule... done\n")
Example #8
0
    def Initialize(self):
        import FreeCADGui
        import MachinekitPreferences
        FreeCADGui.addPreferencePage(MachinekitPreferences.Page, 'Machinekit')
        FreeCADGui.addIcon('preferences-machinekit', self.Icon)

        import MachinekitCommands
        MachinekitCommands.SetupToolbar(self)
        MachinekitCommands.SetupMenu(self)
        pass
def Setup():
    global _setup
    if not _setup:
        import FreeCADGui
        import machinekit

        icon = machinekit.FileResource('machinekiticon.svg')
        FreeCADGui.addIcon('preferences-machinekit', icon)
        FreeCADGui.addPreferencePage(PageGeneral, 'Machinekit')
        FreeCADGui.addPreferencePage(PageHUD, 'Machinekit')
        _setup = True
Example #10
0
def checkImports():
    def missingDependency(file):
        module = os.path.join(os.path.dirname(EmptyFile.__file__), "libs",
                              file)
        python = os.path.join(
            os.path.dirname(sys.executable),
            os.path.basename(sys.executable).replace('FreeCAD', 'python'))
        subprocess.call(u"\"%s\" -m pip install \"%s\"" % (python, module))

    import os, subprocess, traceback, FreeCAD, FreeCADGui, EmptyFile
    try:
        if (not hasattr(FreeCADGui, 'InventorLoaderPrefs')):
            addinpath = os.path.abspath(os.path.dirname(EmptyFile.__file__))
            FreeCADGui.addIconPath(os.path.join(addinpath, 'Resources'))
            FreeCADGui.addPreferencePage(
                os.path.join(addinpath, 'Resources/ui/PrefsInventorLoader.ui'),
                'Import-Export')
            FreeCADGui.InventorImporterPrefs = True
    except:
        FreeCAD.Console.PrintError(">E: %s\n" % traceback.format_exc())

    try:
        import olefile
    except:
        missingDependency("olefile-0.46.zip")

    try:
        import xlrd
    except:
        missingDependency("xlrd-1.2.0.tar.gz")

    try:
        import xlwt
    except:
        missingDependency("xlwt-1.3.0.tar.gz")

    try:
        import xlutils
    except:
        missingDependency("xlutils-2.0.0.tar.gz")

    import importerUtils
    try:
        import SheetMetalCmd
        importerUtils.setUseSheetMetal(True)
    except:
        importerUtils.setUseSheetMetal(False)

    from InventorWorkbench import InventorWorkbench
    Gui.addWorkbench(InventorWorkbench)
Example #11
0
    def Initialize(self):
        def QT_TRANSLATE_NOOP(scope, text):
            return text
        
        #import GDMLCommands, GDMLResources
        commands=['CycleCommand','ColourMapCommand','ExpandCommand', \
              'ExpandMaxCommand','SetMaterialCommand', \
              'BoxCommand','ConeCommand','ElTubeCommand', \
              'EllipsoidCommand','SphereCommand', \
              'TorusCommand','TrapCommand','TubeCommand', \
              'Sketcher_NewSketch','Part_Extrude', \
              'BooleanCutCommand','BooleanIntersectionCommand', \
              'BooleanUnionCommand', \
              'TessellateCommand','TessellateGmshCommand', \
              'DecimateCommand', \
              'Mesh_FromPartShape','Mesh_Evaluation', \
              'Mesh2TessCommand','Tess2MeshCommand', 'TetrahedronCommand', \
              'AddCompound']

        toolbarcommands=['CycleCommand','ColourMapCommand','ExpandCommand',
              'ExpandMaxCommand', 'SetMaterialCommand', \
              'Separator','Std_Part','BoxCommand','ConeCommand', \
              'ElTubeCommand', 'EllipsoidCommand','SphereCommand', \
              'TorusCommand','TrapCommand','TubeCommand', \
              'Sketcher_NewSketch','Part_Extrude', \
              'Separator', 'BooleanCutCommand','BooleanIntersectionCommand', \
              'BooleanUnionCommand','Separator', \
              'TessellateCommand','TessellateGmshCommand', \
              'DecimateCommand', \
              'Mesh_FromPartShape','Mesh_Evaluation', \
              'Mesh2TessCommand','Tess2MeshCommand','TetrahedronCommand', \
              'AddCompound']

        #parttoolbarcommands = ['Part_Cut','Part_Fuse','Part_Common']
        #meshtoolbarcommands = ['Mesh_FromPartShape','Mesh_Evaluation']

        self.appendToolbar(QT_TRANSLATE_NOOP('Workbench','GDMLTools'),toolbarcommands)
        self.appendMenu('GDML',commands)
        #self.appendToolbar(QT_TRANSLATE_NOOP('Workbech','GDML Part tools'),parttoolbarcommands)
        #self.appendToolbar(QT_TRANSLATE_NOOP('Workbech','GDML Mesh Tools'),meshtoolbarcommands)
        FreeCADGui.addIconPath(joinDir("Resources/icons"))
        FreeCADGui.addLanguagePath(joinDir("Resources/translations"))
        FreeCADGui.addPreferencePage(joinDir("Resources/ui/GDML-base.ui"),"GDML")
Example #12
0
    def Initialize(self):
        import os
        import FreeCAD as App
        import FreeCADGui as Gui
        import MBDyn_locator
        MBDwbPath = os.path.dirname(MBDyn_locator.__file__)
        MBDwb_icons_path = os.path.join(MBDwbPath, 'icons')
        MBDwb_setting_ui_path = os.path.join(MBDwbPath, 'resources','wb_settings_widgets')
        import MBDyn_guitools.m_values
        import MBDyn_guitools.MBDynFreeCAD
        import MBDyn_guitools.body_AS4_cmd
        import MBDyn_guitools.ref_cmd
        import MBDyn_guitools.struct_node_cmd
        import MBDyn_guitools.revpin_joint_AS4_2_cmd
        import MBDyn_guitools.hinge_joint_AS4_cmd
        import MBDyn_guitools.postproc_AS4_cmd
        import MBDyn_guitools.total_joint_cmd
        import MBDyn_guitools.total_pinjoint_cmd
        import MBDyn_guitools.inline_joint_cmd
        import MBDyn_guitools.ramp_drive_cmd
        import MBDyn_guitools.axial_rot_joint_AS4_cmd

        from MBDyn_settings.wdgt_solver_settings import wdgt_solver_settings
        self.list = ["mbdyn_configure", "mbdyn_launchGui", "body_sel_cmd",
                    "ref_cmd", "struct_node_cmd", "revpin_joint_cmd",
                    "hinge_joint_cmd", "total_joint_cmd", "total_pinjoint_cmd",
                    "axial_rot_joint_cmd", "inline_joint_cmd", "ramp_drive_cmd", "postproc_cmd"]
        self.appendToolbar("Mbdyn_comands", self.list)
        self.appendMenu("Mbdyn_menu", self.list)
        Log("Loading MyModule... done\n")
        # Add preferences page on the main window toolbar: Edit/ preferences.../mbdyn
        general_setting_ui = os.path.join(MBDwb_setting_ui_path, 'ui_general_settings.ui')
        Gui.addPreferencePage(general_setting_ui, "MBDyn")
        Gui.addPreferencePage(wdgt_solver_settings, "MBDyn")
        img_path = os.path.join(MBDwb_icons_path, 'preferences-MBDyn.svg')
        # The commande Gui.addIcon gives me the following warning (on freecad 0.19):
        # <string>:86: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
        Gui.addIcon("preferences-mbdyn", img_path)
Example #13
0
    def Initialize(self):
        """This function is executed when FreeCAD starts"""
        '''
        disabling numpad shortcuts
        to use for positioning and quick launch
        '''

        preset = [
            ("Std_ViewAxo", "CTRL+0"),
            ("Std_ViewFront", "CTRL+1"),
            ("Std_ViewTop", "CTRL+2"),
            ("Std_ViewRight", "CTRL+3"),
            ("Std_ViewRear", "CTRL+4"),
            ("Std_ViewBottom", "CTRL+5"),
            ("Std_ViewLeft", "CTRL+6"),
            ("Std_BoxSelection", "b"),
        ]

        for (cmd, shortcut) in preset:
            FreeCAD.ParamGet(
                "User parameter:BaseApp/Preferences/Shortcut").SetString(
                    cmd, shortcut)

        def QT_TRANSLATE_NOOP(scope, text):
            return text

        try:
            import os, Draft_rc, DraftTools, DraftGui, Arch, Arch_rc, WFrame
            from DraftTools import translate
            FreeCADGui.addLanguagePath(":/translations")
            FreeCADGui.addIconPath(":/icons")
        except Exception as inst:
            print(inst)
            FreeCAD.Console.PrintError(
                "Error: Initializing one or more of the Draft modules failed, Draft will not work as expected.\n"
            )

        self.wframe = [
            "Draft_Layer", "WF_Beam", "WF_Panel", "Arch_CutPlane",
            "Arch_CutLine", "WF_Copy", "WF_Stretch", "WF_List",
            "WF_EditAttributes", "WF_SelectByAttributes", "WF_AlignViewWPlane"
        ]
        self.wframeExport = ["WF_AddContainer", "WF_AddView", "WF_Export"]

        self.appendToolbar("Wood Frame", self.wframe)
        self.appendToolbar("Wood Frame Export", self.wframeExport)
        self.appendMenu("Wood Frame", self.wframe)  # creates a new menu

        # self.appendMenu(["An existing Menu","My submenu"],self.list) # appends a submenu to an existing menu

        #add draft toolbar
        self.drafttools = [
            "Draft_Line", "Draft_Wire", "Draft_Circle", "Draft_Arc",
            "Draft_Arc_3Points", "Draft_Ellipse", "Draft_Polygon",
            "Draft_Rectangle", "Draft_Text", "Draft_Dimension",
            "Draft_BSpline", "Draft_Point", "Draft_ShapeString",
            "Draft_Facebinder", "Draft_BezierTools", "Draft_Label"
        ]
        self.draftmodtools = [
            "Draft_Move", "Draft_Rotate", "Draft_Offset", "Draft_Trimex",
            "Draft_Join", "Draft_Split", "Draft_Upgrade", "Draft_Downgrade",
            "Draft_Scale", "Draft_Edit", "Draft_WireToBSpline",
            "Draft_AddPoint", "Draft_DelPoint", "Draft_Shape2DView",
            "Draft_Draft2Sketch", "Draft_Array", "Draft_PathArray",
            "Draft_PointArray", "Draft_Clone", "Draft_Drawing", "Draft_Mirror",
            "Draft_Stretch"
        ]
        self.draftextratools = [
            "Draft_WireToBSpline", "Draft_AddPoint", "Draft_DelPoint",
            "Draft_ShapeString", "Draft_PathArray", "Draft_Mirror",
            "Draft_Stretch"
        ]
        self.draftcontexttools = [
            "Draft_ApplyStyle", "Draft_ToggleDisplayMode", "Draft_AddToGroup",
            "Draft_AutoGroup", "Draft_SelectGroup", "Draft_SelectPlane",
            "Draft_ShowSnapBar", "Draft_ToggleGrid", "Draft_UndoLine",
            "Draft_FinishLine", "Draft_CloseLine"
        ]
        self.utils = [
            "Draft_Heal", "Draft_FlipDimension",
            "Draft_ToggleConstructionMode", "Draft_ToggleContinueMode",
            "Draft_Edit", "Draft_Slope", "Draft_SetWorkingPlaneProxy",
            "Draft_AddConstruction"
        ]
        self.snapList = [
            'Draft_Snap_Lock', 'Draft_Snap_Midpoint',
            'Draft_Snap_Perpendicular', 'Draft_Snap_Grid',
            'Draft_Snap_Intersection', 'Draft_Snap_Parallel',
            'Draft_Snap_Endpoint', 'Draft_Snap_Angle', 'Draft_Snap_Center',
            'Draft_Snap_Extension', 'Draft_Snap_Near', 'Draft_Snap_Ortho',
            'Draft_Snap_Special', 'Draft_Snap_Dimensions',
            'Draft_Snap_WorkingPlane'
        ]
        self.appendToolbar(
            QT_TRANSLATE_NOOP("Workbench", "Draft creation tools"),
            self.drafttools)
        self.appendToolbar(
            QT_TRANSLATE_NOOP("Workbench", "Draft modification tools"),
            self.draftmodtools)
        # self.appendToolbar(QT_TRANSLATE_NOOP("Workbench","Draft mod tools"),self.draftextratools)
        self.appendMenu(QT_TRANSLATE_NOOP("draft", "&Draft"),
                        self.drafttools + self.draftmodtools)
        self.appendMenu([
            QT_TRANSLATE_NOOP("draft", "&Draft"),
            QT_TRANSLATE_NOOP("Workbench", "Utilities")
        ], self.utils + self.draftcontexttools)
        self.appendMenu([
            QT_TRANSLATE_NOOP("draft", "&Draft"),
            QT_TRANSLATE_NOOP("Workbench", "Snapping")
        ], self.snapList)

        if hasattr(FreeCADGui, "draftToolBar"):
            if not hasattr(FreeCADGui.draftToolBar, "loadedArchPreferences"):
                FreeCADGui.addPreferencePage(":/ui/preferences-arch.ui",
                                             "Arch")
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-archdefaults.ui", "Arch")
                FreeCADGui.draftToolBar.loadedArchPreferences = True
            if not hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
                FreeCADGui.addPreferencePage(":/ui/preferences-draft.ui",
                                             "Draft")
                FreeCADGui.addPreferencePage(":/ui/preferences-draftsnap.ui",
                                             "Draft")
                FreeCADGui.addPreferencePage(":/ui/preferences-draftvisual.ui",
                                             "Draft")
                FreeCADGui.addPreferencePage(":/ui/preferences-drafttexts.ui",
                                             "Draft")
                FreeCADGui.draftToolBar.loadedPreferences = True
        Log('Loading Draft module...done\n')
Example #14
0
    def Initialize(self):
        "This function is executed when FreeCAD starts"
        import BOPTools  # as bop
        import Design456_Extrude  # import all	 needed files
        import Design456_Extract
        import Design456_ExtrudeFace
        import Design456_SplitObject
        import Design456_loftOnDirection
        import Design456_Part as designPart
        import Design456_Part_Tools as pTools
        import Design456_Part_Utils as pUtils
        import Design456_2Ddrawing as TwoDDraw
        import Design456_SelectionGate as SelGate
        import Design456_Alignment as align
        # from Part import CommandShapes	 #Tube	not working
        Gui.runCommand('Std_PerspectiveCamera', 1)

        self.appendToolbar("Design456_Part", designPart.Design456_Part.list)
        self.appendToolbar("Design456_Tools", pTools.Design456_Part_Tools.list)
        self.appendToolbar("Design456_2DTools",
                           pUtils.Design456_Part_Utils.list)
        self.appendToolbar("Design456_2Ddrawing",
                           TwoDDraw.Design456_2Ddrawing.list)
        self.appendToolbar("Selection Mode",
                           SelGate.Design456_SelectionGate.list)
        self.appendToolbar("Design456_Alignments",
                           align.Design456_Alignment.list)

        self.appendMenu("Design456_Part", designPart.Design456_Part.list)
        self.appendMenu("Design456_Tools", pTools.Design456_Part_Tools.list)
        self.appendMenu("Design456_2Ddrawing",
                        TwoDDraw.Design456_2Ddrawing.list)
        self.appendMenu("Design456_2DTools", pUtils.Design456_Part_Utils.list)
        self.appendMenu("Design456_Alignments", align.Design456_Alignment.list)

        # Design456_Part
        #self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Drafting"), self.drawing_commands)

        # Design456_Part
        # DRAFT
        def QT_TRANSLATE_NOOP(context, text):
            return text

        # Run self-tests
        dependencies_OK = False
        try:
            from pivy import coin
            if Gui.getSoDBVersion() != coin.SoDB.getVersion():
                raise AssertionError("FreeCAD and Pivy use different versions "
                                     "of Coin. "
                                     "This will lead to unexpected behavior.")
        except AssertionError:
            App.Console.PrintWarning("Error: FreeCAD and Pivy "
                                     "use different versions of Coin. "
                                     "This will lead to unexpected "
                                     "behavior.\n")
        except Exception:
            App.Console.PrintWarning("Error: Pivy not found, "
                                     "Draft Workbench will be disabled.\n")
        except Exception:
            App.Console.PrintWarning("Error: Unknown error "
                                     "while trying to load Pivy.\n")
        else:
            dependencies_OK = True

        if not dependencies_OK:
            return
        # END DRAFT

        # Import Draft tools, icons
        try:
            import Draft_rc
            import DraftTools
            import DraftGui
            import DraftFillet
            Gui.addLanguagePath(":/translations")
            Gui.addIconPath(":/icons")
        except Exception as exc:
            App.Console.PrintError(exc)
            App.Console.PrintError("Error: Initializing one or more "
                                   "of the Draft modules failed, "
                                   "Draft will not work as expected.\n")
        try:
            # Set up command lists
            import draftutils.init_tools as it
            self.drawing_commands = it.get_draft_drawing_commands()
            self.annotation_commands = it.get_draft_annotation_commands()
            self.modification_commands = it.get_draft_modification_commands()
            self.context_commands = it.get_draft_context_commands()
            self.line_commands = it.get_draft_line_commands()
            self.utility_commands = it.get_draft_utility_commands()
            self.utility_small = it.get_draft_small_commands()

            # Set up toolbars
            self.appendToolbar(
                QT_TRANSLATE_NOOP("Draft", "Draft creation tools"),
                self.drawing_commands)
            self.appendToolbar(
                QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"),
                self.annotation_commands)
            self.appendToolbar(
                QT_TRANSLATE_NOOP("Draft", "Draft modification tools"),
                self.modification_commands)
            self.appendToolbar(
                QT_TRANSLATE_NOOP("Draft", "Draft utility tools"),
                self.utility_small)

            # Set up menus
            self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Drafting"),
                            self.drawing_commands)
            self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Annotation"),
                            self.annotation_commands)
            self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Modification"),
                            self.modification_commands)
            self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Utilities"),
                            self.utility_commands + self.context_commands)

            # Set up preferences pages
            if hasattr(FreeCADGui, "draftToolBar"):
                if not hasattr(Gui.draftToolBar, "loadedPreferences"):
                    Gui.addPreferencePage(":/ui/preferences-draft.ui",
                                          QT_TRANSLATE_NOOP("Draft", "Draft"))
                    Gui.addPreferencePage(":/ui/preferences-draftinterface.ui",
                                          QT_TRANSLATE_NOOP("Draft", "Draft"))
                    Gui.addPreferencePage(":/ui/preferences-draftsnap.ui",
                                          QT_TRANSLATE_NOOP("Draft", "Draft"))
                    Gui.addPreferencePage(":/ui/preferences-draftvisual.ui",
                                          QT_TRANSLATE_NOOP("Draft", "Draft"))
                    Gui.addPreferencePage(":/ui/preferences-drafttexts.ui",
                                          QT_TRANSLATE_NOOP("Draft", "Draft"))
                    Gui.draftToolBar.loadedPreferences = True
                # END DRAFT
        except Exception as exc:
            App.Console.PrintError(exc)
            App.Console.PrintError("Error: Initializing one or more "
                                   "of the Draft modules failed, "
                                   "Draft will not work as expected.\n")
Example #15
0
                            translate("draft", "CubicBezCurve")):
                        self.appendContextMenu("", self.line_commands)
            else:
                if Gui.Selection.getSelection():
                    self.appendContextMenu("Utilities", self.context_commands)
            # END DRAFT
        except Exception as exc:
            App.Console.PrintError(exc)
            App.Console.PrintError("Error: Draft ContexMenu "
                                   "failed, "
                                   "Draft will not work as expected.\n")

    def GetClassName(self):
        return "Gui::PythonWorkbench"


Gui.addWorkbench(Design456_Workbench())
# FROM DRAFT
# Preference pages for importing and exporting various file formats
# are independent of the loading of the workbench and can be loaded at startup
Gui.addPreferencePage(":/ui/preferences-dxf.ui",
                      QT_TRANSLATE_NOOP("Draft", "Import-Export"))
Gui.addPreferencePage(":/ui/preferences-dwg.ui",
                      QT_TRANSLATE_NOOP("Draft", "Import-Export"))
Gui.addPreferencePage(":/ui/preferences-svg.ui",
                      QT_TRANSLATE_NOOP("Draft", "Import-Export"))
Gui.addPreferencePage(":/ui/preferences-oca.ui",
                      QT_TRANSLATE_NOOP("Draft", "Import-Export"))

App.__unit_test__ += ["TestDraftGui"]
Example #16
0
    def Initialize(self):
        """When the workbench is first loaded."""
        def QT_TRANSLATE_NOOP(context, text):
            return text

        # Run self-tests
        dependencies_OK = False
        try:
            from pivy import coin
            if FreeCADGui.getSoDBVersion() != coin.SoDB.getVersion():
                raise AssertionError("FreeCAD and Pivy use different versions "
                                     "of Coin. "
                                     "This will lead to unexpected behaviour.")
        except AssertionError:
            FreeCAD.Console.PrintWarning("Error: FreeCAD and Pivy "
                                         "use different versions of Coin. "
                                         "This will lead to unexpected "
                                         "behaviour.\n")
        except ImportError:
            FreeCAD.Console.PrintWarning("Error: Pivy not found, "
                                         "Draft Workbench will be disabled.\n")
        except Exception:
            FreeCAD.Console.PrintWarning("Error: Unknown error "
                                         "while trying to load Pivy.\n")
        else:
            dependencies_OK = True

        if not dependencies_OK:
            return

        # Import Draft tools, icons
        try:
            import Draft_rc
            import DraftTools
            import DraftGui
            import DraftFillet
            from draftguitools import gui_circulararray
            from draftguitools import gui_polararray
            from draftguitools import gui_orthoarray
            from draftguitools import gui_arrays
            FreeCADGui.addLanguagePath(":/translations")
            FreeCADGui.addIconPath(":/icons")
        except Exception as exc:
            FreeCAD.Console.PrintError(exc)
            FreeCAD.Console.PrintError("Error: Initializing one or more "
                                       "of the Draft modules failed, "
                                       "Draft will not work as expected.\n")

        # Set up command lists
        import draftutils.init_tools as it
        self.drawing_commands = it.get_draft_drawing_commands()
        self.annotation_commands = it.get_draft_annotation_commands()
        self.modification_commands = it.get_draft_modification_commands()
        self.context_commands = it.get_draft_context_commands()
        self.line_commands = it.get_draft_line_commands()
        self.utility_commands = it.get_draft_utility_commands()

        # Set up toolbars
        self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft creation tools"),
                           self.drawing_commands)
        self.appendToolbar(
            QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"),
            self.annotation_commands)
        self.appendToolbar(
            QT_TRANSLATE_NOOP("Draft", "Draft modification tools"),
            self.modification_commands)

        # Set up menus
        self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Drafting"),
                        self.drawing_commands)
        self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Annotation"),
                        self.annotation_commands)
        self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Modification"),
                        self.modification_commands)
        self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Utilities"),
                        self.utility_commands + self.context_commands)

        # Set up preferences pages
        if hasattr(FreeCADGui, "draftToolBar"):
            if not hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draft.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draftsnap.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draftvisual.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-drafttexts.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.draftToolBar.loadedPreferences = True

        FreeCAD.Console.PrintLog('Loading Draft workbench, done.\n')
Example #17
0
 def __init__(self):
     FreeCADGui.addPreferencePage(
         os.path.join(os.path.dirname(__file__), "AddonManagerOptions.ui"),
         "Addon Manager",
     )
Example #18
0
    def Initialize(self):
        import sys
        PyVersion = sys.version_info[0]
        if PyVersion == 2:
            import a2p_Resources2
        else:
            import a2p_Resources3
        import a2plib
        import a2p_importpart
        import a2p_recursiveUpdatePlanner
        import a2p_convertPart
        import a2p_solversystem
        import a2p_MuxAssembly
        import a2p_partinformation
        import a2p_constraintDialog
        import a2p_constraintcommands
        import a2p_bom # bom == bill of materials == partslist

        if a2plib.getRecursiveUpdateEnabled():
            partCommands = [
                'a2p_ImportPart',
                'a2p_ImportShapeReferenceCommand',
                'a2p_updateImportedParts',
                'a2p_recursiveUpdateImportedPartsCommand',
                'a2p_movePart',
                'a2p_MovePartUnderConstraints',
                'a2p_duplicatePart',
                'a2p_ConvertPart',
                'a2p_editImportedPart',
                'a2p_SaveAndExit_Command',
                ]
        else:
            partCommands = [
                'a2p_ImportPart',
                'a2p_ImportShapeReferenceCommand',
                'a2p_updateImportedParts',
                'a2p_movePart',
                'a2p_MovePartUnderConstraints',
                'a2p_duplicatePart',
                'a2p_ConvertPart',
                'a2p_editImportedPart',
                'a2p_SaveAndExit_Command',
                ]
        
        if a2plib.SHOW_CONSTRAINTS_ON_TOOLBAR:
            constraintCommands = [
                'a2p_ConstraintDialogCommand',
                'a2p_EditConstraintCommand',
                'a2p_DeleteConnectionsCommand',
                'a2p_PointIdentityConstraintCommand',
                'a2p_PointOnLineConstraintCommand',
                'a2p_PointOnPlaneConstraintCommand',
                'a2p_SphericalSurfaceConstraintCommand',
                'a2p_CircularEdgeConnection',
                'a2p_AxialConstraintCommand',
                'a2p_AxisParallelConstraintCommand',
                'a2p_AxisPlaneParallelCommand',
                'a2p_AxisPlaneNormalCommand',
                'a2p_AxisPlaneAngleCommand',
                'a2p_PlanesParallelConstraintCommand',
                'a2p_PlaneCoincidentConstraintCommand',
                'a2p_AngledPlanesConstraintCommand',
                'a2p_CenterOfMassConstraintCommand',
                ]
        else:
            constraintCommands = [
                'a2p_ConstraintDialogCommand',
                'a2p_EditConstraintCommand',
                'a2p_DeleteConnectionsCommand',
                ]
        
        solverCommands = [
            'a2p_SolverCommand',
            'a2p_ToggleAutoSolveCommand',
            'a2p_FlipConstraintDirectionCommand',
            'a2p_Show_Hierarchy_Command'
            ]
        viewCommands = [
            'a2p_isolateCommand',
            'a2p_ViewConnectionsCommand',
            'a2p_Restore_Transparency',
            'a2p_ToggleTransparencyCommand',            
            'a2p_Show_PartLabels_Command',
            'a2p_Show_DOF_info_Command',
            ]
        miscCommands = [
            'a2p_SimpleAssemblyShapeCommand',
            'a2p_repairTreeViewCommand',
            'a2p_CreatePartInformationSheet_Command',
            'a2p_CreatePartlist',
            ]

        self.appendToolbar(
               'A2p_Part',
               partCommands
               )
        self.appendToolbar(
               'A2p_Constraint',
               constraintCommands
               )
        self.appendToolbar(
               'A2p_Solver',
               solverCommands
               )
        self.appendToolbar(
               'A2p_View',
               viewCommands
               )
        self.appendToolbar(
               'A2p_Misc',
               miscCommands
               )

        self.appendMenu(
            'A2plus',
            partCommands
            )
        self.appendMenu(
            ['A2plus', 'Constraint'],
            constraintCommands
            )
        self.appendMenu(
            ['A2plus', 'Solver'],
            solverCommands
            )
        self.appendMenu(
            ['A2plus', 'View'],
            viewCommands
            )
        self.appendMenu(
            ['A2plus', 'Misc'],
            miscCommands
            )            
            
        menuEntries = [
            'a2p_absPath_to_relPath_Command',
            'a2p_MigrateProxiesCommand'
            ]
        self.appendMenu(
            ['A2plus', 'Misc'],
            menuEntries
            )
        FreeCADGui.addIconPath(':/icons')
        
        FreeCADGui.addPreferencePage(
            a2plib.pathOfModule() +
            '/GuiA2p/Resources/ui/a2p_prefs.ui','A2plus'
            )
Example #19
0
    def start_updater(self):
        if not self.loaded:
            return

        self.updater.cancel()
        self.updater.clear()
        if self.progress_dialog is not None:
            self.progress_dialog.hide()
            self.progress_dialog.deleteLater()
            self.progress_dialog = None

        # Check the FreeCAD revision no. in filename with the
        # remote target file to know if we really
        # need a update since SHA1 hashes differ
        # every week.
        self.updater.setApplicationName("FreeCAD")
        self.updater.start(self.updater.getConstant("Action::CheckForUpdate"))

        # QProgressDialog while checking for update.
        self.progress_dialog = QtWidgets.QProgressDialog("Checking for Update", None, 0, 100)
        self.progress_dialog.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
        self.progress_dialog.setValue(0)
        self.progress_dialog.show()

    def saveSettings(self):
        pass

FreeCADGui.addPreferencePage(AppImagePreferencePage,'AppImage')

preference_tabel = FreeCAD.ParamGet('User parameter:BaseApp/Preferences/AppImage')
Example #20
0
    def Initialize(self):
        "This function is executed when FreeCAD starts"
        import BOPTools  # as bop
        import Design456_Part as designPart
        import Design456_2Ddrawing as TwoDDraw
        import Design456_Part_Tools as _tools
        import Design456_Alignment as _alignment
        import Design456_SelectionGate as SelGate
        import DirectModeling.directModelingCommands as dModeling
        import DefeaturingWB.DefeaturingTools
        import DefeaturingWB.DefeaturingCMD
        import DefeaturingWB.FuzzyTools
        import Design456Init
        from Design456Pref import Design456Preferences
        import Design456_Segmented as _segmented

        # from Part import CommandShapes     #Tube  not working
        Gui.runCommand('Std_PerspectiveCamera', 1)

        self.appendToolbar("Design456_Part", designPart.Design456_Part.list)
        self.appendToolbar("Design456 2Ddrawing",
                           TwoDDraw.Design456_2Ddrawing.list)
        self.appendToolbar("Design456_Segmented",
                           _segmented.Design456_Segmented.list)

        self.appendToolbar("Design456 Tools", _tools.Design456_Part_Tools.list)
        self.appendToolbar("Design456 Alignment",
                           _alignment.Design456_Alignment_Tools.list)
        self.appendToolbar("Selection Mode",
                           SelGate.Design456_SelectionGate.list)
        self.appendToolbar("Direct Modeling",
                           dModeling.Design456_DirectModeling.list)

        self.appendMenu("Design456_Part", designPart.Design456_Part.list)
        self.appendMenu("Design456_2Ddrawing",
                        TwoDDraw.Design456_2Ddrawing.list)
        self.appendMenu("Design456 Tools", _tools.Design456_Part_Tools.list)
        self.appendMenu("Design456 Alignment",
                        _alignment.Design456_Alignment_Tools.list)

        # Defeaturing WB  added to Design456
        self.appendToolbar("Defeaturing Tools", [
            "DefeaturingTools", "DF_SelectLoop", "refineFeatureTool",
            "DefeatShapeFeature"
        ])
        #self.appendMenu("ksu Tools", ["ksuTools","ksuToolsEdit"])
        self.appendMenu(
            "Defeaturing Tools",
            ["refineFeatureTool", "DefeaturingTools", "DF_SelectLoop"])
        self.appendToolbar("Fuzzy Tools",
                           ["FuzzyCut", "FuzzyUnion", "FuzzyCommon"])
        self.appendMenu("Fuzzy Tools",
                        ["FuzzyCut", "FuzzyUnion", "FuzzyCommon"])
        Gui.addIconPath(Design456Init.ICON_PATH)

        # Design456_Part
        # self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Drafting"), self.drawing_commands)

        # Design456_Part
        # DRAFT
        def QT_TRANSLATE_NOOP(context, text):
            return text

        # Run self-tests
        dependencies_OK = False
        try:
            from pivy import coin
            import FreeCAD
            import FreeCADGui
            if FreeCADGui.getSoDBVersion() != coin.SoDB.getVersion():
                raise AssertionError("FreeCAD and Pivy use different versions "
                                     "of Coin. "
                                     "This will lead to unexpected behaviour.")
        except AssertionError:
            FreeCAD.Console.PrintWarning("Error: FreeCAD and Pivy "
                                         "use different versions of Coin. "
                                         "This will lead to unexpected "
                                         "behaviour.\n")
        except ImportError:
            FreeCAD.Console.PrintWarning("Error: Pivy not found, "
                                         "Draft Workbench will be disabled.\n")
        except Exception:
            FreeCAD.Console.PrintWarning("Error: Unknown error "
                                         "while trying to load Pivy.\n")
        else:
            dependencies_OK = True

        if not dependencies_OK:
            return

        # Import Draft tools, icons
        try:
            import Draft_rc
            import DraftTools
            import DraftGui
            import DraftFillet
            import FreeCAD
            import FreeCADGui

            FreeCADGui.addLanguagePath(":/translations")
            FreeCADGui.addIconPath(":/icons")
        except Exception as exc:
            FreeCAD.Console.PrintError(exc)
            FreeCAD.Console.PrintError("Error: Initializing one or more "
                                       "of the Draft modules failed, "
                                       "Draft will not work as expected.\n")
        try:
            # Set up command lists
            import draftutils.init_tools as it
            self.drawing_commands = it.get_draft_drawing_commands()
            self.annotation_commands = it.get_draft_annotation_commands()
            self.modification_commands = it.get_draft_modification_commands()
            self.utility_commands_menu = it.get_draft_utility_commands_menu()
            self.utility_commands_toolbar = it.get_draft_utility_commands_toolbar(
            )
            self.context_commands = it.get_draft_context_commands()

            # Set up toolbars
            it.init_toolbar(self,
                            QT_TRANSLATE_NOOP("Draft", "Draft creation tools"),
                            self.drawing_commands)
            it.init_toolbar(
                self, QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"),
                self.annotation_commands)
            it.init_toolbar(
                self, QT_TRANSLATE_NOOP("Draft", "Draft modification tools"),
                self.modification_commands)
            it.init_toolbar(self,
                            QT_TRANSLATE_NOOP("Draft", "Draft utility tools"),
                            self.utility_commands_toolbar)

            # Set up menus
            it.init_menu(self, [QT_TRANSLATE_NOOP("Draft", "&Drafting")],
                         self.drawing_commands)
            it.init_menu(self, [QT_TRANSLATE_NOOP("Draft", "&Annotation")],
                         self.annotation_commands)
            it.init_menu(self, [QT_TRANSLATE_NOOP("Draft", "&Modification")],
                         self.modification_commands)
            it.init_menu(self, [QT_TRANSLATE_NOOP("Draft", "&Utilities")],
                         self.utility_commands_menu)

            # Set up preferences pages
            if hasattr(FreeCADGui, "draftToolBar"):
                if not hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
                    FreeCADGui.addPreferencePage(
                        ":/ui/preferences-draft.ui",
                        QT_TRANSLATE_NOOP("Draft", "Draft"))
                    FreeCADGui.addPreferencePage(
                        ":/ui/preferences-draftinterface.ui",
                        QT_TRANSLATE_NOOP("Draft", "Draft"))
                    FreeCADGui.addPreferencePage(
                        ":/ui/preferences-draftsnap.ui",
                        QT_TRANSLATE_NOOP("Draft", "Draft"))
                    FreeCADGui.addPreferencePage(
                        ":/ui/preferences-draftvisual.ui",
                        QT_TRANSLATE_NOOP("Draft", "Draft"))
                    FreeCADGui.addPreferencePage(
                        ":/ui/preferences-drafttexts.ui",
                        QT_TRANSLATE_NOOP("Draft", "Draft"))
                    FreeCADGui.draftToolBar.loadedPreferences = True

            FreeCAD.Console.PrintLog('Loading Draft workbench, done.\n')

            # END DRAFT
        except Exception as exc:
            App.Console.PrintError(exc)
            App.Console.PrintError("Error: Initializing one or more "
                                   "of the Draft modules failed, "
                                   "Design456 will not work as expected.\n")
Example #21
0
    def Initialize(self):
        """When the workbench is first loaded."""

        def QT_TRANSLATE_NOOP(context, text):
            return text

        import Draft_rc
        import DraftTools
        import DraftGui
        from draftguitools import gui_circulararray
        from draftguitools import gui_polararray
        from draftguitools import gui_orthoarray
        from draftguitools import gui_arrays
        import Arch_rc
        import Arch

        # Set up command lists
        self.archtools = ["Arch_Wall", "Arch_StructureTools", "Arch_Rebar",
                          "Arch_CurtainWall","Arch_BuildingPart",
                          "Arch_Project", "Arch_Site", "Arch_Building",
                          "Arch_Floor", "Arch_Reference",
                          "Arch_Window", "Arch_Roof", "Arch_AxisTools",
                          "Arch_SectionPlane", "Arch_Space", "Arch_Stairs",
                          "Arch_PanelTools", "Arch_Equipment",
                          "Arch_Frame", "Arch_Fence", "Arch_Truss",
                          "Arch_Profile","Arch_MaterialTools",
                          "Arch_Schedule", "Arch_PipeTools",
                          "Arch_CutPlane", "Arch_CutLine",
                          "Arch_Add", "Arch_Remove", "Arch_Survey"]
        self.utilities = ["Arch_Component", "Arch_CloneComponent",
                          "Arch_SplitMesh", "Arch_MeshToShape",
                          "Arch_SelectNonSolidMeshes", "Arch_RemoveShape",
                          "Arch_CloseHoles", "Arch_MergeWalls", "Arch_Check",
                          "Arch_ToggleIfcBrepFlag", "Arch_3Views",
                          "Arch_IfcSpreadsheet", "Arch_ToggleSubs"]

        # Add the rebar tools from the Reinforcement addon, if available
        try:
            import RebarTools
        except Exception:
            pass
        else:
            class RebarGroupCommand:
                def GetCommands(self):
                    return tuple(RebarTools.RebarCommands + ["Arch_Rebar"])

                def GetResources(self):
                    _tooltip = ("Create various types of rebars, "
                                "including U-shaped, L-shaped, and stirrup")
                    return {'MenuText': QT_TRANSLATE_NOOP("Arch", 'Rebar tools'),
                            'ToolTip': QT_TRANSLATE_NOOP("Arch", _tooltip)}

                def IsActive(self):
                    return not FreeCAD.ActiveDocument is None
            FreeCADGui.addCommand('Arch_RebarTools', RebarGroupCommand())
            self.archtools[2] = "Arch_RebarTools"

        # Set up Draft command lists
        import draftutils.init_tools as it
        self.draft_drawing_commands = it.get_draft_drawing_commands()
        self.draft_annotation_commands = it.get_draft_annotation_commands()
        self.draft_modification_commands = it.get_draft_modification_commands()
        self.draft_context_commands = it.get_draft_context_commands()
        self.draft_line_commands = it.get_draft_line_commands()
        self.draft_utility_commands = it.get_draft_utility_commands()

        # Set up toolbars
        self.appendToolbar(QT_TRANSLATE_NOOP("Workbench", "Arch tools"), self.archtools)
        self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft creation tools"), self.draft_drawing_commands)
        self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"), self.draft_annotation_commands)
        self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft modification tools"), self.draft_modification_commands)

        # Set up menus
        self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Arch"),
                         QT_TRANSLATE_NOOP("arch", "Utilities")],
                        self.utilities)
        self.appendMenu(QT_TRANSLATE_NOOP("arch", "&Arch"), self.archtools)

        self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"),
                         QT_TRANSLATE_NOOP("arch", "Creation")],
                        self.draft_drawing_commands)
        self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"),
                         QT_TRANSLATE_NOOP("arch", "Annotation")],
                        self.draft_annotation_commands)
        self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"),
                         QT_TRANSLATE_NOOP("arch", "Modification")],
                        self.draft_modification_commands)
        self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"),
                         QT_TRANSLATE_NOOP("arch", "Utilities")],
                        self.draft_utility_commands
                        + self.draft_context_commands)
        FreeCADGui.addIconPath(":/icons")
        FreeCADGui.addLanguagePath(":/translations")

        # Set up preferences pages
        if hasattr(FreeCADGui, "draftToolBar"):
            if not hasattr(FreeCADGui.draftToolBar, "loadedArchPreferences"):
                FreeCADGui.addPreferencePage(":/ui/preferences-arch.ui", QT_TRANSLATE_NOOP("Arch", "Arch"))
                FreeCADGui.addPreferencePage(":/ui/preferences-archdefaults.ui", QT_TRANSLATE_NOOP("Arch", "Arch"))
                FreeCADGui.draftToolBar.loadedArchPreferences = True
            if not hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
                FreeCADGui.addPreferencePage(":/ui/preferences-draft.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(":/ui/preferences-draftsnap.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(":/ui/preferences-draftvisual.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(":/ui/preferences-drafttexts.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.draftToolBar.loadedPreferences = True

        FreeCAD.Console.PrintLog('Loading Arch workbench, done.\n')
Example #22
0
    pref = Design456_preferences()
    pref.SetBool("GridEnabled", enabled)


def setSimplified(enabled=False):
    pref = Design456_preferences()
    pref.SetBool("Simplified", enabled)


class Design456Preferences:
    def __init__(self, parent=None):
        self.form = Gui.PySideUic.loadUi(Design456Init.UI_PATH +
                                         'Design456Pref.ui')

    def saveSettings(self):
        Design456_preferences().setPreferencesAdvanced(
            self.form.chkDisableGrid.isChecked(),
            self.form.chkSimplify.isChecked())

    def loadSettings(self):
        self.form.chkDisableGrid.setChecked(
            Design456Init.PATH_PREF.chkDisableGrid())
        self.form.chkSimplify.setChecked(Design456Init.PATH_PREF.chkSimplify())
        self.updateSelection()

    def updateSelection(self, state=None):
        pass


Gui.addPreferencePage(Design456Preferences, "Design456")
Example #23
0
    def Initialize(self):
        """ Run at start of FreeCAD.
        """
        import WF
        try:
            import WF_general
            import WF_centerLinePoint
            import WF_extremaLinePoint
            import WF_alongLinePoint
            import WF_nPointsPoint
            # import WF_centerCirclePoint
            import WF_centerFacePoint
            import WF_projectedPoint
            # import WF_pointFacePoint
            # import WF_lineFacePoint

            import WF_twoPointsLine
            import WF_nPointsLine

            import WF_threePointsPlane
            import WF_linePointPlane
            # import WF_perpendicularLinePointPlane
        except ImportError:
            m_error = "Error: One of WF_ module not found,"
            m_error += "WorkFeature workbench will be disabled.\n"
            App.Console.PrintWarning(m_error)
            m_error = "Error: Unknown error while trying"
            m_error += "to load one of WF_ module !\n"
            App.Console.PrintWarning(m_error)

        # Set menu and commands for Points
        self.General_menu = ["Work Feature", "General"]
        self.General_commands_list = [
            "ShowHideDynamic",
            "ShowHideInteractive",
            "ShowHideNo",
            "Refresh",
        ]
        self.appendCommandbar("General", self.General_commands_list)
        self.appendMenu(self.General_menu, self.General_commands_list)
        self.appendToolbar("WF General", self.General_commands_list)

        # Set menu and commands for Points
        self.Point_menu = ["Work Feature", "Points"]
        self.Point_commands_list = [
            "CenterLinePoint",  # done but to test
            "ExtremaLinePoint",  # done but to test
            "AlongLinePoint",  # done but to test
            "NPointsPoint",  # done but to test
            # "CenterCirclePoint",
            "CenterFacePoint",
            # "PointFacePoint",
            # "LineFacePoint",
            "ProjectedPoint"
        ]
        self.appendCommandbar("Points", self.Point_commands_list)
        self.appendMenu(self.Point_menu, self.Point_commands_list)
        self.appendToolbar("WF Points", self.Point_commands_list)

        # Set menu and commands for Lines
        self.m_Line_menu = ["Work Feature", "Lines"]
        self.m_Line_commands_list = [
            "TwoPointsLine",  # done but to test
            "NPointsLine",  # done but to test
        ]
        self.appendCommandbar("Lines", self.m_Line_commands_list)
        self.appendMenu(self.m_Line_menu, self.m_Line_commands_list)
        self.appendToolbar("WF Lines", self.m_Line_commands_list)

        # Set menu and commands for Planes
        self.m_Plane_menu = ["Work Feature", "Planes"]
        self.m_Plane_commands_list = [
            "ThreePointsPlane",  # done but to test
            "LinePointPlane",  # done but to test
            # "PerpendicularLinePointPlane",
        ]
        self.appendCommandbar("Planes", self.m_Plane_commands_list)
        self.appendMenu(self.m_Plane_menu, self.m_Plane_commands_list)
        self.appendToolbar("WF Planes", self.m_Plane_commands_list)

        # m_submenu = ['WorkFeature.pdf']
        # self.appendMenu(["Work Feature", "Help"], m_submenu)

        Gui.addIconPath(PATH_WF_ICONS)
        Gui.addResourcePath(PATH_WF_ICONS)
        Gui.addPreferencePage(PATH_WF_UI + "/WorkFeature_prefs.ui",
                              "Work Feature")

        WF.set_release(WF_Release)
        Log('Loading WorkFeature workbench...done\n')
        if M_DEBUG:
            print("DEBUG : WF_Release is " + str(WF_Release))
Example #24
0
        """When leaving the workbench."""
        if hasattr(FreeCADGui, "draftToolBar"):
            FreeCADGui.draftToolBar.Deactivated()
        if hasattr(FreeCADGui, "Snapper"):
            FreeCADGui.Snapper.hide()
        FreeCAD.Console.PrintLog("Arch workbench deactivated.\n")

    def ContextMenu(self, recipient):
        """Define an optional custom context menu."""
        self.appendContextMenu("Utilities", self.draft_context_commands)

    def GetClassName(self):
        """Type of workbench."""
        return "Gui::PythonWorkbench"


FreeCADGui.addWorkbench(ArchWorkbench)

# Preference pages for importing and exporting various file formats
# are independent of the loading of the workbench and can be loaded at startup
import Arch_rc
from PySide.QtCore import QT_TRANSLATE_NOOP
FreeCADGui.addPreferencePage(":/ui/preferences-ifc.ui",
                             QT_TRANSLATE_NOOP("Draft", "Import-Export"))
FreeCADGui.addPreferencePage(":/ui/preferences-ifc-export.ui",
                             QT_TRANSLATE_NOOP("Draft", "Import-Export"))
FreeCADGui.addPreferencePage(":/ui/preferences-dae.ui",
                             QT_TRANSLATE_NOOP("Draft", "Import-Export"))

FreeCAD.__unit_test__ += ["TestArch"]
Example #25
0
    def Initialize(self):
        if not hasattr(Gui, "listCommands"):
            Gui.listCommands = Gui.Command.listAll

        from PySide.QtCore import QT_TRANSLATE_NOOP

        import DraftTools
        import Arch
        import envis.commands

        from draftutils.messages import _log

        try:
            Gui.activateWorkbench("BIMWorkbench")
        except KeyError:
            print(
                "BIM Workbench not available. Some commands will be missing.")

        self.draftingtools = [
            "BIM_Sketch", "Draft_Line", "Draft_Wire", "Draft_Circle",
            "Draft_Arc", "Draft_Arc_3Points", "Draft_Ellipse", "Draft_Polygon",
            "Draft_Rectangle", "Draft_Point"
        ]

        self.annotationtools = [
            "Draft_Text", "Draft_ShapeString", "Draft_Dimension",
            "Draft_Label", "Arch_Axis", "Arch_AxisSystem", "Arch_Grid",
            "Arch_SectionPlane"
        ]

        self.bimtools = [
            "Arch_Site", "Arch_Building", "Arch_Floor", "Arch_Space",
            "Separator", "Arch_Wall", "BIM_Slab", "BIM_Door", "Arch_Window",
            "Arch_Roof", "Arch_Panel", "Arch_Frame", "Separator", "BIM_Box",
            "Draft_Facebinder", "BIM_Library", "Arch_Component"
        ]

        self.modify = [
            "Draft_Move", "BIM_Copy", "Draft_Rotate", "BIM_Clone",
            "BIM_Unclone", "Draft_Offset", "BIM_Offset2D", "Draft_Trimex",
            "Draft_Join", "Draft_Split", "Draft_Scale", "Draft_Stretch",
            "BIM_Rewire", "BIM_Glue", "Draft_Upgrade", "Draft_Downgrade",
            "Draft_Draft2Sketch", "Arch_CutPlane", "Arch_Add", "Arch_Remove",
            "BIM_Reextrude", "BIM_Cut", "Draft_Shape2DView"
        ]

        self.snap = [
            'Draft_ToggleGrid', 'Draft_Snap_Lock', 'Draft_Snap_Midpoint',
            'Draft_Snap_Perpendicular', 'Draft_Snap_Grid',
            'Draft_Snap_Intersection', 'Draft_Snap_Parallel',
            'Draft_Snap_Endpoint', 'Draft_Snap_Angle', 'Draft_Snap_Center',
            'Draft_Snap_Extension', 'Draft_Snap_Near', 'Draft_Snap_Ortho',
            'Draft_Snap_Special', 'Draft_Snap_Dimensions',
            'Draft_Snap_WorkingPlane', 'BIM_SetWPTop', 'BIM_SetWPFront',
            'BIM_SetWPSide'
        ]

        self.manage = [
            "BIM_Setup", "BIM_Project", "BIM_Views", "BIM_Windows",
            "BIM_IfcElements", "BIM_IfcQuantities", "BIM_IfcProperties",
            "BIM_Classification", "BIM_Material", "Arch_Schedule",
            "BIM_Preflight", "BIM_Layers"
        ]

        self.utils = [
            "BIM_TogglePanels", "BIM_Trash", "BIM_WPView", "Draft_Slope",
            "Draft_WorkingPlaneProxy", "Draft_AddConstruction",
            "Arch_SplitMesh", "Arch_MeshToShape", "Arch_SelectNonSolidMeshes",
            "Arch_RemoveShape", "Arch_CloseHoles", "Arch_MergeWalls",
            "Arch_Check", "Arch_ToggleIfcBrepFlag", "Arch_ToggleSubs",
            "Arch_Survey", "BIM_Diff", "BIM_IfcExplorer"
        ]

        self.envis = [
            "EnVis_Import", "EnVis_BruttoFl", "EnVis_Setup",
            "EnVis_SelectRelated"
        ]

        # post-0.18 tools
        if "Arch_Project" in Gui.listCommands():
            self.bimtools.insert(0, "Arch_Project")
        if "Arch_Reference" in Gui.listCommands():
            self.bimtools.insert(-5, "Arch_Reference")
        if "Draft_Arc_3Points" in Gui.listCommands():
            self.draftingtools.insert(5, "Draft_Arc_3Points")
        if "Arch_Truss" in Gui.listCommands():
            self.bimtools.insert(
                self.bimtools.index("Arch_Frame") + 1, "Arch_Truss")
        if "Arch_CurtainWall" in Gui.listCommands():
            self.bimtools.insert(
                self.bimtools.index("Arch_Wall") + 1, "Arch_CurtainWall")

        # try to load bimbots
        try:
            import bimbots
        except ImportError:
            pass
        else:

            class BIMBots:
                def GetResources(self):
                    return bimbots.get_plugin_info()

                def Activated(self):
                    bimbots.launch_ui()

            Gui.addCommand('BIMBots', BIMBots())
            self.utils.append("BIMBots")

        # load Reporting
        try:
            import report
        except ImportError:
            pass
        else:
            if "Report_Create" in Gui.listCommands():
                self.manage[self.manage.index(
                    "Arch_Schedule")] = "Report_Create"

        # load webtools
        try:
            import BIMServer, Git, Sketchfab
        except ImportError:
            pass
        else:
            self.utils.extend(
                ["WebTools_Git", "WebTools_BimServer", "WebTools_Sketchfab"])

        # create toolbars
        self.appendToolbar(QT_TRANSLATE_NOOP("BIM", "Drafting tools"),
                           self.draftingtools)
        self.appendToolbar(QT_TRANSLATE_NOOP("BIM", "3D/BIM tools"),
                           self.bimtools)
        self.appendToolbar(QT_TRANSLATE_NOOP("BIM", "Annotation tools"),
                           self.annotationtools)
        self.appendToolbar(QT_TRANSLATE_NOOP("BIM", "Modification tools"),
                           self.modify)
        self.appendToolbar("EnVis tools", self.envis)

        # create menus
        self.appendMenu(QT_TRANSLATE_NOOP("BIM", "&2D Drafting"),
                        self.draftingtools)
        self.appendMenu(QT_TRANSLATE_NOOP("BIM", "&3D/BIM"), self.bimtools)
        self.appendMenu(QT_TRANSLATE_NOOP("BIM", "&Annotation"),
                        self.annotationtools)
        self.appendMenu(QT_TRANSLATE_NOOP("BIM", "&Snapping"), self.snap)
        self.appendMenu(QT_TRANSLATE_NOOP("BIM", "&Modify"), self.modify)
        self.appendMenu(QT_TRANSLATE_NOOP("BIM", "&Manage"), self.manage)
        self.appendMenu(QT_TRANSLATE_NOOP("BIM", "&Utils"), self.utils)
        self.appendMenu("EnVis", self.envis)

        # load Arch & Draft preference pages
        if hasattr(Gui, "draftToolBar"):
            if not hasattr(Gui.draftToolBar, "loadedArchPreferences"):
                import Arch_rc
                Gui.addPreferencePage(":/ui/preferences-arch.ui", "Arch")
                Gui.addPreferencePage(":/ui/preferences-archdefaults.ui",
                                      "Arch")
                Gui.draftToolBar.loadedArchPreferences = True

            if not hasattr(Gui.draftToolBar, "loadedPreferences"):
                import Draft_rc
                Gui.addPreferencePage(":/ui/preferences-draft.ui", "Draft")
                Gui.addPreferencePage(":/ui/preferences-draftsnap.ui", "Draft")
                Gui.addPreferencePage(":/ui/preferences-draftvisual.ui",
                                      "Draft")
                Gui.addPreferencePage(":/ui/preferences-drafttexts.ui",
                                      "Draft")
                Gui.draftToolBar.loadedPreferences = True

        _log('Loading EnVis module... done')
        Gui.updateLocale()
Example #26
0
    def Initialize(self):
        from a2p_translateUtils import QT_TRANSLATE_NOOP
        from a2p_translateUtils import translate
        from a2p_translateUtils import tr_

        import sys
        PyVersion = sys.version_info[0]
        if PyVersion == 2:
            import a2p_Resources2
        else:
            import a2p_Resources3
        import a2plib

        # add translations path
        FreeCADGui.addLanguagePath(a2plib.getLanguagePath())
        FreeCADGui.updateLocale()
        print("languagePath of A2plus Workbench is: {}".format(
            a2plib.getLanguagePath()))

        import a2p_importpart
        import a2p_recursiveUpdatePlanner
        import a2p_convertPart
        import a2p_solversystem
        import a2p_MuxAssembly
        import a2p_partinformation
        import a2p_constraintDialog
        import a2p_constraintcommands
        import a2p_bom  # bom == bill of materials == partslist
        import a2p_constraintServices
        import a2p_searchConstraintConflicts
        import CD_A2plusupdater  # for Constraint Diagnostic function
        if a2plib.getRecursiveUpdateEnabled():
            partCommands = [
                'a2p_ImportPart',
                'a2p_ImportShapeReferenceCommand',
                'a2p_updateImportedParts',
                'a2p_recursiveUpdateImportedPartsCommand',
                'a2p_movePart',
                'a2p_MovePartUnderConstraints',
                'a2p_duplicatePart',
                'a2p_ConvertPart',
                'a2p_editImportedPart',
                'a2p_SaveAndExit_Command',
            ]
        else:
            partCommands = [
                'a2p_ImportPart',
                'a2p_ImportShapeReferenceCommand',
                'a2p_updateImportedParts',
                'a2p_movePart',
                'a2p_MovePartUnderConstraints',
                'a2p_duplicatePart',
                'a2p_ConvertPart',
                'a2p_editImportedPart',
                'a2p_SaveAndExit_Command',
            ]

        if a2plib.SHOW_CONSTRAINTS_ON_TOOLBAR:
            constraintCommands = [
                'a2p_ConstraintDialogCommand',
                'a2p_EditConstraintCommand',
                'a2p_reAdjustConstraintDirectionsCommand',
                'a2p_DeleteConnectionsCommand',
                'a2p_PointIdentityConstraintCommand',
                'a2p_PointOnLineConstraintCommand',
                'a2p_PointOnPlaneConstraintCommand',
                'a2p_SphericalSurfaceConstraintCommand',
                'a2p_CircularEdgeConnection',
                'a2p_AxialConstraintCommand',
                'a2p_AxisParallelConstraintCommand',
                'a2p_AxisPlaneParallelCommand',
                'a2p_AxisPlaneNormalCommand',
                'a2p_AxisPlaneAngleCommand',
                'a2p_PlanesParallelConstraintCommand',
                'a2p_PlaneCoincidentConstraintCommand',
                'a2p_AngledPlanesConstraintCommand',
                'a2p_CenterOfMassConstraintCommand',
            ]
        else:
            constraintCommands = [
                'a2p_ConstraintDialogCommand',
                'a2p_EditConstraintCommand',
                'a2p_reAdjustConstraintDirectionsCommand',
                'a2p_DeleteConnectionsCommand',
            ]

        if a2plib.GRAPHICALDEBUG:
            solverCommands = [
                'a2p_SolverCommand', 'a2p_ToggleAutoSolveCommand',
                'a2p_FlipConstraintDirectionCommand',
                'a2p_Show_Hierarchy_Command',
                'a2p_SearchConstraintConflictsCommand',
                'a2p_cleanUpDebug3dCommand'
            ]
        else:
            solverCommands = [
                'a2p_SolverCommand', 'a2p_ToggleAutoSolveCommand',
                'a2p_FlipConstraintDirectionCommand',
                'a2p_Show_Hierarchy_Command',
                'a2p_SearchConstraintConflictsCommand'
            ]
        viewCommands = [
            'a2p_isolateCommand',
            'a2p_ViewConnectionsCommand',
            'a2p_Restore_Transparency',
            'a2p_ToggleTransparencyCommand',
            'a2p_Show_PartLabels_Command',
            'a2p_Show_DOF_info_Command',
        ]
        miscCommands = [
            'a2p_SimpleAssemblyShapeCommand',
            'a2p_repairTreeViewCommand',
            'a2p_CreatePartInformationSheet_Command',
            'a2p_CreatePartlist',
        ]

        self.appendToolbar('A2p_Part', partCommands)
        self.appendToolbar('A2p_Constraint', constraintCommands)
        self.appendToolbar('A2p_Solver', solverCommands)
        self.appendToolbar('A2p_View', viewCommands)
        self.appendToolbar('A2p_Misc', miscCommands)

        self.appendMenu('A2plus', partCommands)
        self.appendMenu(
            ['A2plus', translate("A2plus_appendMenu", 'Constraint')],
            constraintCommands)
        self.appendMenu(
            ['A2plus', translate("A2plus_appendMenu", 'Solver')],
            solverCommands)
        self.appendMenu(
            ['A2plus', translate("A2plus_appendMenu", 'View')], viewCommands)
        self.appendMenu(
            ['A2plus', translate("A2plus_appendMenu", 'Misc')], miscCommands)

        menuEntries = [
            'a2p_absPath_to_relPath_Command', 'a2p_MigrateProxiesCommand'
        ]
        self.appendMenu(['A2plus', 'Misc'], menuEntries)
        FreeCADGui.addIconPath(':/icons')

        FreeCADGui.addPreferencePage(
            a2plib.pathOfModule() + '/GuiA2p/Resources/ui/a2p_prefs.ui',
            'A2plus')

        DiagnosticCommands = [
            'rnp_Constraint_Viewer',
            'rnp_Update_A2pParts',
        ]

        self.appendToolbar('A2Diagnostics', DiagnosticCommands)
Example #27
0
    def Initialize(self):
        """When the workbench is first loaded."""
        def QT_TRANSLATE_NOOP(context, text):
            return text

        import Draft_rc
        import DraftTools
        import DraftGui
        import Arch_rc
        import Arch

        from ArchStructure import _ArchStructureGroupCommand
        from ArchAxis import _ArchAxisGroupCommand
        from ArchPanel import CommandPanelGroup
        from ArchMaterial import _ArchMaterialToolsCommand
        from ArchPipe import _ArchPipeGroupCommand

        stru_group = _ArchStructureGroupCommand
        axis_group = _ArchAxisGroupCommand
        pan_group = CommandPanelGroup
        mat_group = _ArchMaterialToolsCommand
        pipe_group = _ArchPipeGroupCommand

        # Set up command lists
        self.archtools = [
            "Arch_Wall",
            ([QT_TRANSLATE_NOOP("Workbench", "Structure tools")],
             list(stru_group.GetCommands(stru_group))),  # tuple len=2: submenu
            ("Arch_StructureTools", ),  # tuple len=1: toolbar flyout
            "Arch_Rebar_Submenu",  # will be replaced or removed
            "Arch_Rebar",  # may be replaced
            "Arch_CurtainWall",
            "Arch_BuildingPart",
            "Arch_Project",
            "Arch_Site",
            "Arch_Building",
            "Arch_Floor",
            "Arch_Reference",
            "Arch_Window",
            "Arch_Roof",
            ([QT_TRANSLATE_NOOP("Workbench", "Axis tools")],
             list(axis_group.GetCommands(axis_group))),
            ("Arch_AxisTools", ),
            "Arch_SectionPlane",
            "Arch_Space",
            "Arch_Stairs",
            ([QT_TRANSLATE_NOOP("Workbench", "Panel tools")],
             list(pan_group.GetCommands(pan_group))),
            ("Arch_PanelTools", ),
            "Arch_Equipment",
            "Arch_Frame",
            "Arch_Fence",
            "Arch_Truss",
            "Arch_Profile",
            ([QT_TRANSLATE_NOOP("Workbench", "Material tools")],
             list(mat_group.GetCommands(mat_group))),
            ("Arch_MaterialTools", ),
            "Arch_Schedule",
            ([QT_TRANSLATE_NOOP("Workbench", "Pipe tools")],
             list(pipe_group.GetCommands(pipe_group))),
            ("Arch_PipeTools", ),
            "Arch_CutPlane",
            "Arch_CutLine",
            "Arch_Add",
            "Arch_Remove",
            "Arch_Survey"
        ]

        self.utilities = [
            "Arch_Component", "Arch_CloneComponent", "Arch_SplitMesh",
            "Arch_MeshToShape", "Arch_SelectNonSolidMeshes",
            "Arch_RemoveShape", "Arch_CloseHoles", "Arch_MergeWalls",
            "Arch_Check", "Arch_ToggleIfcBrepFlag", "Arch_3Views",
            "Arch_IfcSpreadsheet", "Arch_ToggleSubs"
        ]

        # Add the rebar tools from the Reinforcement addon, if available
        try:
            import RebarTools
        except Exception:
            del self.archtools[3]  # remove "Arch_Rebar_Submenu"
        else:

            class RebarGroupCommand:
                def GetCommands(self):
                    return tuple(RebarTools.RebarCommands + ["Arch_Rebar"])

                def GetResources(self):
                    return {
                        'MenuText':
                        QT_TRANSLATE_NOOP("Arch_RebarTools", "Rebar tools"),
                        'ToolTip':
                        QT_TRANSLATE_NOOP(
                            "Arch_RebarTools",
                            "Create various types of rebars, "
                            "including U-shaped, L-shaped, and stirrup")
                    }

                def IsActive(self):
                    return not FreeCAD.ActiveDocument is None

            FreeCADGui.addCommand('Arch_RebarTools', RebarGroupCommand())
            self.archtools[3] = ([
                QT_TRANSLATE_NOOP("Workbench", "Rebar tools")
            ], RebarTools.RebarCommands + ["Arch_Rebar"])
            self.archtools[4] = ("Arch_RebarTools", )

        # Set up Draft command lists
        import draftutils.init_tools as it
        self.draft_drawing_commands = it.get_draft_drawing_commands()
        self.draft_annotation_commands = it.get_draft_annotation_commands()
        self.draft_modification_commands = it.get_draft_modification_commands()
        self.draft_utility_commands = it.get_draft_utility_commands_menu()
        self.draft_context_commands = it.get_draft_context_commands()

        # Set up toolbars
        it.init_toolbar(self, QT_TRANSLATE_NOOP("Workbench", "Arch tools"),
                        self.archtools)
        it.init_toolbar(self,
                        QT_TRANSLATE_NOOP("Workbench", "Draft creation tools"),
                        self.draft_drawing_commands)
        it.init_toolbar(
            self, QT_TRANSLATE_NOOP("Workbench", "Draft annotation tools"),
            self.draft_annotation_commands)
        it.init_toolbar(
            self, QT_TRANSLATE_NOOP("Workbench", "Draft modification tools"),
            self.draft_modification_commands)

        # Set up menus
        it.init_menu(self, [
            QT_TRANSLATE_NOOP("Workbench", "&Arch"),
            QT_TRANSLATE_NOOP("Workbench", "Utilities")
        ], self.utilities)
        it.init_menu(self, [QT_TRANSLATE_NOOP("Workbench", "&Arch")],
                     self.archtools)
        it.init_menu(self, [
            QT_TRANSLATE_NOOP("Workbench", "&Draft"),
            QT_TRANSLATE_NOOP("Workbench", "Creation")
        ], self.draft_drawing_commands)
        it.init_menu(self, [
            QT_TRANSLATE_NOOP("Workbench", "&Draft"),
            QT_TRANSLATE_NOOP("Workbench", "Annotation")
        ], self.draft_annotation_commands)
        it.init_menu(self, [
            QT_TRANSLATE_NOOP("Workbench", "&Draft"),
            QT_TRANSLATE_NOOP("Workbench", "Modification")
        ], self.draft_modification_commands)
        it.init_menu(self, [
            QT_TRANSLATE_NOOP("Workbench", "&Draft"),
            QT_TRANSLATE_NOOP("Workbench", "Utilities")
        ], self.draft_utility_commands)

        FreeCADGui.addIconPath(":/icons")
        FreeCADGui.addLanguagePath(":/translations")

        # Set up preferences pages
        if hasattr(FreeCADGui, "draftToolBar"):
            if not hasattr(FreeCADGui.draftToolBar, "loadedArchPreferences"):
                FreeCADGui.addPreferencePage(":/ui/preferences-arch.ui",
                                             QT_TRANSLATE_NOOP("Arch", "Arch"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-archdefaults.ui",
                    QT_TRANSLATE_NOOP("Arch", "Arch"))
                FreeCADGui.draftToolBar.loadedArchPreferences = True
            if not hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draft.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draftsnap.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draftvisual.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-drafttexts.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.draftToolBar.loadedPreferences = True

        FreeCAD.Console.PrintLog('Loading Arch workbench, done.\n')
Example #28
0
import SelectionTools_rc

TOOLS = [
    ("ListSelect", ListSelect.select, "S, E"),
]


def activateTool(name, callback, defaultShortcut):
    from PySide import QtGui
    pref = App.ParamGet(
        "User parameter:BaseApp/Preferences/Mod/SelectionTools/" + name)
    if not pref.GetBool("disabled"):
        action = QtGui.QAction(Gui.getMainWindow())
        Gui.getMainWindow().addAction(action)
        action.setText(name)
        action.setObjectName("Std_%s" % name)
        shortcut = pref.GetString("shortcut")
        if shortcut == "":
            shortcut = defaultShortcut
        action.setShortcut(QtGui.QKeySequence(shortcut))
        action.triggered.connect(callback)


################
# Main Routine #
################

Gui.addPreferencePage(":/ui/SelectionToolsSettings.ui", "Display")
for t in TOOLS:
    activateTool(*t)