Example #1
0
	def Initialize(self):
		# load the module
		import SurfaceToolsGui
                import FreeCADGui

                # Set path to icon labels
                FreeCADGui.addIconPath('./Gui/Resources/Icons/')
Example #2
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 #3
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 #4
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 #5
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 #6
0
    def Initialize(self):
        # load the module
        import SurfaceGui
        import FreeCADGui
        import Surface

        # Set path to icon labels
        FreeCADGui.addIconPath('./Gui/Resources/Icons/')
Example #7
0
    def Initialize(self):
        "This function is executed when FreeCAD starts"
        import GazeboSDFExportStatic, GazeboSDFExport, CreateJoint # import here all the needed files that create your FreeCAD commands
        self.list = ['RC_GazeboSDFExportStatic','RC_GazeboSDFExport', 'RC_CreateJoint'] # A list of command names created in the line above
        self.appendToolbar("RobotCreator",self.list) # creates a new toolbar with your commands
        self.appendMenu("My New Menu",self.list) # creates a new menu
        self.appendMenu(["An existing Menu","My submenu"],self.list) # appends a submenu to an existing menu
	FreeCADGui.addIconPath( '~/.FreeCAD/Mod/RobotCreator/icons' )
Example #8
0
    def Initialize(self):

        from gearfunc import CreateCycloideGear, CreateInvoluteGear, CreateBevelGear

        self.appendToolbar("Gear", ["CreateInvoluteGear", "CreateCycloideGear", "CreateBevelGear"])
        self.appendMenu("Gear", ["CreateInvoluteGear", "CreateCycloideGear","CreateBevelGear"])
        Gui.addIconPath(FreeCAD.getHomePath()+"Mod/gear/icons/")
        Gui.addCommand('CreateInvoluteGear', CreateInvoluteGear())
        Gui.addCommand('CreateCycloideGear', CreateCycloideGear())
        Gui.addCommand('CreateBevelGear', CreateBevelGear())
Example #9
0
 def Initialize(self):
     # imports
     from .commands import CreatePlate, CreateSeparator, CreateWasher, CreateScrew
     self.appendToolbar("Construction Toy", self.commands)
     self.appendMenu("Construction Toy", self.commands)
     Gui.addIconPath(App.getHomePath() + "Mod/constructiontoy/icons/")
     Gui.addCommand('CreatePlate', CreatePlate())
     Gui.addCommand('CreateSeparator', CreateSeparator())
     Gui.addCommand('CreateWasher', CreateWasher())
     Gui.addCommand('CreateScrew', CreateScrew())
Example #10
0
    def Initialize(self):
        # run self-tests
        depsOK = 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, DDA workbench will be disabled.\n")
        except:
            FreeCAD.Console.PrintWarning("Error: Unknown error while trying to load Pivy\n")
        else:
            try:
                import PyQt4
            except ImportError:
                FreeCAD.Console.PrintWarning("Error: PyQt4 not found, DDA workbench will be disabled.\n")
            else:
                depsOK = True

#        import FreeCAD , FreeCADGui

        import DDA_rc
        import FreeCADGui

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


#            try:
        import DDAShapes
#            except:
#                FreeCAD.Console.PrintWarning("'DDAShapes' moudle import failed.")

        import DGPlayer , DFCalculation , DDAPanel
#            try:
        import drawGui 
#            except:
#                FreeCAD.Console.PrintWarning("'drawGui' moudle import failed.")
        import DDAToolbars

        import interfaceTools
        import storeScene
        import loadDataTools
        import DDAStdCommands
        import AnalysisDDAResult
#        FreeCADGui.addPreferencePage(":/DDA-preferences.ui","DDA")
#        FreeCADGui.addPreferencePage(":/userprefs-base.ui","DDA")
#        FreeCAD.Console.PrintMessage('Loading DDA GUI...\n')
        
        import DDAGui
        list = ['DDA_NewDoc' , 'DDA_Undo' , 'DDA_Redo',  'Std_ViewFitAll' , 'DDA_ChooseProjectPath' , 'DDA_Examples', 'DDA_DL' , 'DDA_DC','DFCalculation','PlayDF', 'DDA_DGAnalysiser' ]
#        list = ['DDA_NewDoc' , 'DDA_Undo' , 'DDA_Redo', 'DDA_ChooseProjectPath' , 'DDA_SetPanelSize' , 'DDA_DL' , 'DDA_DC','DFCalculation','PlayDF']
        self.appendToolbar('DDACmds' , list)
Example #11
0
 def Initialize(self):
     from gearfunc import CreateCycloideGear, CreateInvoluteGear
     from gearfunc import CreateBevelGear, CreateInvoluteRack, CreateCrownGear
     self.appendToolbar("Gear", self.commands)
     self.appendMenu("Gear", self.commands)
     Gui.addIconPath(App.getHomePath() + "Mod/gear/icons/")
     Gui.addCommand('CreateInvoluteGear', CreateInvoluteGear())
     Gui.addCommand('CreateCycloideGear', CreateCycloideGear())
     Gui.addCommand('CreateBevelGear', CreateBevelGear())
     Gui.addCommand('CreateInvoluteRack', CreateInvoluteRack())
     Gui.addCommand('CreateCrownGear', CreateCrownGear())
Example #12
0
 def Initialize(self):
     from .commands import CreateCycloideGear, CreateInvoluteGear
     from .commands import CreateBevelGear, CreateInvoluteRack, CreateCrownGear
     self.appendToolbar("Gear", self.commands)
     self.appendMenu("Gear", self.commands)
     Gui.addIconPath(App.getHomePath()+"Mod/gear/icons/")
     Gui.addCommand('CreateInvoluteGear', CreateInvoluteGear())
     Gui.addCommand('CreateCycloideGear', CreateCycloideGear())
     Gui.addCommand('CreateBevelGear', CreateBevelGear())
     Gui.addCommand('CreateInvoluteRack', CreateInvoluteRack())
     Gui.addCommand('CreateCrownGear', CreateCrownGear())
Example #13
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 #14
0
    def Initialize(self):
        #"This function is executed when FreeCAD starts"
        import EB_Commands, MeasureEdges  # import here all the needed files that create your FreeCAD commands
        self.listTests = ([
            "Clear_Console", "EnableConnectionToEB", "DisableConnectionToEB",
            "ShowTestsConsole"
        ])
        self.appendToolbar("EB Tests", self.listTests)

        self.list = ([
            "Get_EB_Shape", "Get_EB_Shape_Step", "Add_EB_Shape_With_Shift",
            "Add_EB_Shape_With_Shift_Step", "Add_EB_Step_Assembly",
            "Select_EB_Shape"
        ])  # A list of command names created in the line above
        self.appendToolbar(
            "EB Commands",
            self.list)  # creates a new toolbar with your commands
        self.appendMenu("Engineering Base", self.list)  # creates a new menu
        self.listAux = ([
            "Get_DIN_Rail_TS35", "Get_Terminal_Block", "Get_GuiTab"
        ])
        self.appendToolbar("EB Aux", self.listAux)
        # import Draft tools, icons
        try:
            import os, Draft_rc, DraftTools, DraftGui, Draft
            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.createList = [
            "Draft_Line", "Draft_Wire", "Draft_Circle", "Draft_Ellipse",
            "Draft_Polygon", "Draft_Rectangle", "Draft_Point"
        ]
        self.appendToolbar("Create", self.createList)
        self.moveList = [
            "Mover_For_Object", "Draft_Move", "Draft_Rotate",
            "Move_Piont_To_Point", "Rotate_Sel_Object_15"
        ]
        self.appendToolbar("EB Move", self.moveList)
        self.visibilityList = [
            "Set_Transparancy", "Set_Display_Mode_Wire_Frame",
            "Set_Display_Mode_Flat_Lines", "Set_Visibility_True"
        ]
        self.appendToolbar("EB Visibility", self.visibilityList)
Example #15
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 #16
0
    def Initialize(self):
        def QT_TRANSLATE_NOOP(scope, text):
            return text

        #import 2SCommands
        commands=['toSPlaneCommand','toSketchCommand','toMacroCommand', \
                  'toCurveFitCommand', \
                  'toScaleCommand','toResetOriginCommand']

        toolbarcommands=['toSPlaneCommand','toSketchCommand','toMacroCommand', \
                  'toCurveFitCommand', \
                  'toScaleCommand','toResetOriginCommand']

        import PartGui
        parttoolbarcommands = ['Part_Loft']
        self.appendToolbar(QT_TRANSLATE_NOOP('Workbench', \
                           'toSketch_Tools'),toolbarcommands)
        self.appendToolbar(QT_TRANSLATE_NOOP('Workbench', \
                           'toSketch_Tools Part Tools'),parttoolbarcommands)
        self.appendMenu('toSketch', commands)
        FreeCADGui.addIconPath(joinDir("Resources/icons"))
        FreeCADGui.addLanguagePath(joinDir("Resources/translations"))
Example #17
0
import os
try:
    import FreeCADGui as Gui
    import FreeCAD
except ImportError:
    print("module not loaded with freecad")

import glider_metadata
Dir = os.path.dirname(glider_metadata.__file__)

Gui.addIconPath(Dir + "/icons")


class gliderWorkbench(Gui.Workbench):
    """probe workbench object"""
    MenuText = "glider"
    ToolTip = "glider workbench"
    Icon = "glider_workbench.svg"
    toolBox = [
        "CreateGlider",
        "ImportGlider",
        "ShapeCommand",
        "ArcCommand",
        "AoaCommand",
        "ZrotCommand",
        "AirfoilCommand",
        "AirfoilMergeCommand",
        "BallooningCommand",
        "BallooningMergeCommand",
        "CellCommand",
        "LineCommand",
Example #18
0
    def isEnabled(self,but):
        "returns true if the given button is turned on"
        for b in self.toolbarButtons:
            if str(b.objectName()) == "SnapButton" + but:
                return (b.isEnabled() and b.isChecked())
        return False

    def show(self):
        "shows the toolbar"
        if not hasattr(self,"toolbar"):
            self.makeSnapToolBar()
        mw = getMainWindow()
        bt = mw.findChild(QtGui.QToolBar,"Draft Snap")
        if not bt:
            mw.addToolBar(self.toolbar)
        self.toolbar.show()

    def setGrid(self):
        "sets the grid, if visible"
        if self.grid:
            if self.grid.Visible:
                self.grid.set()

if not hasattr(FreeCADGui,"Snapper"):
    FreeCADGui.Snapper = Snapper()
if not hasattr(FreeCAD,"DraftWorkingPlane"):
    import WorkingPlane, Draft_rc
    FreeCAD.DraftWorkingPlane = WorkingPlane.plane()
    print FreeCAD.DraftWorkingPlane
    FreeCADGui.addIconPath(":/icons")
Example #19
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 #20
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 #21
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 #22
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 #23
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 #24
0
import sys
import time
import os
from PySide2 import QtWidgets, QtGui, QtCore

import FreeCAD
import FreeCADGui

DIR = os.path.dirname(__file__)
FreeCADGui.addIconPath(os.path.join(DIR, "icons"))

class AppImagePreferencePage:
    def __init__(self):
        ui_file = os.path.join(DIR, "ui", "preferences.ui")
        self.form = FreeCADGui.PySideUic.loadUi(ui_file)
        self.form.check_updates_button.clicked.connect(self.start_updater)
        self.revision = int(FreeCAD.Version()[2].split(" ")[0])

        self.progress_dialog = None

        # Dialog boxes
        self.box = QtWidgets.QMessageBox()
        self.box.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)

        # importing the plugin and creating an instance
        self.loader = QtCore.QPluginLoader()
        self.loader.setFileName("libQAppImageUpdate")
        self.loaded = self.loader.load()
        if self.loaded:
            self.updater = self.loader.instance()
            self.updater.quit.connect(self.quit_freecad)
Example #25
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 #26
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 #27
0
import FreeCADGui as Gui
import FreeCAD


Gui.addIconPath(FreeCAD.getHomePath() + "Mod/glider/icons")

from profiles import LoadProfile
from glider import CreateGlider

Gui.addCommand("LoadProfile", LoadProfile())
Gui.addCommand("CreateGlider", CreateGlider())
Example #28
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 #29
0
#*   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
#*   USA                                                                   *
#*                                                                         *
#***************************************************************************

import PySide
from PySide import QtCore, QtGui
import FreeCAD
import FreeCADGui
import os

import Ship_rc


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


class LoadExample:
    def Activated(self):
        import shipLoadExample
        shipLoadExample.load()

    def GetResources(self):
        MenuText = QtCore.QT_TRANSLATE_NOOP(
            'Ship_LoadExample',
            'Load an example ship geometry')
        ToolTip = QtCore.QT_TRANSLATE_NOOP(
            'Ship_LoadExample',
            'Load an example ship hull geometry.')
        return {'Pixmap': 'Ship_Load',
Example #30
0
    def Initialize(self):
        # run self-tests
        depsOK = 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, DDA workbench will be disabled.\n")
        except:
            FreeCAD.Console.PrintWarning(
                "Error: Unknown error while trying to load Pivy\n")
        else:
            try:
                import PyQt4
            except ImportError:
                FreeCAD.Console.PrintWarning(
                    "Error: PyQt4 not found, DDA workbench will be disabled.\n"
                )
            else:
                depsOK = True

#        import FreeCAD , FreeCADGui

        import DDA_rc
        import FreeCADGui

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

        #            try:
        import DDAShapes
        #            except:
        #                FreeCAD.Console.PrintWarning("'DDAShapes' moudle import failed.")

        import DGPlayer, DFCalculation, DDAPanel
        #            try:
        import drawGui
        #            except:
        #                FreeCAD.Console.PrintWarning("'drawGui' moudle import failed.")
        import DDAToolbars

        import interfaceTools
        import storeScene
        import loadDataTools
        import DDAStdCommands
        import AnalysisDDAResult
        #        FreeCADGui.addPreferencePage(":/DDA-preferences.ui","DDA")
        #        FreeCADGui.addPreferencePage(":/userprefs-base.ui","DDA")
        #        FreeCAD.Console.PrintMessage('Loading DDA GUI...\n')

        import DDAGui
        list = [
            'DDA_NewDoc', 'DDA_Undo', 'DDA_Redo', 'Std_ViewFitAll',
            'DDA_ChooseProjectPath', 'DDA_DL', 'DDA_DC', 'DFCalculation',
            'PlayDF', 'DDA_DGAnalysiser', 'DDA_Examples'
        ]
        #        list = ['DDA_NewDoc' , 'DDA_Undo' , 'DDA_Redo', 'DDA_ChooseProjectPath' , 'DDA_SetPanelSize' , 'DDA_DL' , 'DDA_DC','DFCalculation','PlayDF']
        self.appendToolbar('DDACmds', list)
Example #31
0
import FreeCADGui as Gui
import FreeCAD

Gui.addIconPath(FreeCAD.getHomePath() + "Mod/glider/icons")

from shape import ChangeShape
from examples import LoadGlider
from profiles import LoadProfile, ChangeProfile, RunXfoil, CompareProfile, MergeProfile

Gui.addCommand('LoadGlider', LoadGlider())
Gui.addCommand('ChangeShape', ChangeShape())
Gui.addCommand('LoadProfile', LoadProfile())
Gui.addCommand('ChangeProfile', ChangeProfile())
Gui.addCommand('RunXfoil', RunXfoil())
Gui.addCommand('CompareProfile', CompareProfile())
Gui.addCommand('MergeProfile', MergeProfile())
Example #32
0

def SoGroup_getByName(self, name):
    for child in self:
        if name == child.getName():
            return child
    return None


coin.SoGroup.__iadd__ = SoGroup__iadd__
coin.SoGroup.__isub__ = SoGroup__isub__
coin.SoGroup.getByName = SoGroup_getByName
########################################################################################

Dir = os.path.abspath(os.path.dirname(__file__))
Gui.addIconPath(os.path.join(Dir, 'icons'))


class gliderWorkbench(Gui.Workbench):
    MenuText = 'glider'
    ToolTip = 'glider workbench'
    Icon = os.path.join(Dir, 'icons', 'glider_workbench.svg')
    toolBox = [
        'CreateGlider', 'ImportGlider', 'ShapeCommand', 'ArcCommand',
        'AoaCommand', 'ZrotCommand', 'AirfoilCommand', 'AirfoilMergeCommand',
        'BallooningCommand', 'BallooningMergeCommand', 'CellCommand',
        'LineCommand', 'LineObserveCommand', 'CutCommand', 'ColorCommand',
        'Gl2dExport'
    ]

    featureBox = [
Example #33
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 #34
0
#*   GNU Library General Public License for more details.                  *
#*                                                                         *
#*   You should have received a copy of the GNU Library General Public     *
#*   License along with this program; if not, write to the Free Software   *
#*   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
#*   USA                                                                   *
#*                                                                         *
#***************************************************************************

from PyQt4 import QtCore, QtGui
import FreeCAD, FreeCADGui, os

# Load resources
import Plot_rc
FreeCADGui.addLanguagePath(":/Plot/translations")
FreeCADGui.addIconPath(":/Plot/icons")

"""
# Setup tranlations
from plotUtils import Paths
path = Paths.translationsPath()
FreeCADGui.addLanguagePath(path)
import os
import FreeCAD
translator = QtCore.QTranslator()
dirList=os.listdir(path)
for fname in dirList:
	valid = translator.load(os.path.join(path, fname))
	if valid:
		QtGui.QApplication.installTranslator(translator)
"""