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

        import OpenSCAD_rc, OpenSCADCommands
        commands = [
            'OpenSCAD_ReplaceObject', 'OpenSCAD_RemoveSubtree',
            'OpenSCAD_RefineShapeFeature', 'OpenSCAD_MirrorMeshFeature',
            'OpenSCAD_ScaleMeshFeature', 'OpenSCAD_ResizeMeshFeature',
            'OpenSCAD_IncreaseToleranceFeature', 'OpenSCAD_Edgestofaces',
            'OpenSCAD_ExpandPlacements', 'OpenSCAD_ExplodeGroup'
        ]
        toolbarcommands = [
            'OpenSCAD_ReplaceObject', 'OpenSCAD_RemoveSubtree',
            'OpenSCAD_ExplodeGroup', 'OpenSCAD_RefineShapeFeature',
            'OpenSCAD_IncreaseToleranceFeature'
        ]
        import PartGui
        parttoolbarcommands = [
            'Part_CheckGeometry', 'Part_Primitives', 'Part_Builder',
            'Part_Cut', 'Part_Fuse', 'Part_Common', 'Part_Extrude',
            'Part_Revolve'
        ]
        import FreeCAD
        param = FreeCAD.ParamGet(
            "User parameter:BaseApp/Preferences/Mod/OpenSCAD")
        openscadfilename = param.GetString('openscadexecutable')
        if not openscadfilename:

            import OpenSCADUtils
            openscadfilename = OpenSCADUtils.searchforopenscadexe()
            if openscadfilename:  #automatic search was succsessful
                FreeCAD.addImportType("OpenSCAD Format (*.scad)", "importCSG")
                param.SetString('openscadexecutable',
                                openscadfilename)  #save the result
        if openscadfilename:
            commands.extend([
                'OpenSCAD_AddOpenSCADElement', 'OpenSCAD_MeshBoolean',
                'OpenSCAD_Hull', 'OpenSCAD_Minkowski'
            ])

            toolbarcommands.extend([
                'OpenSCAD_AddOpenSCADElement', 'OpenSCAD_MeshBoolean',
                'OpenSCAD_Hull', 'OpenSCAD_Minkowski'
            ])
        else:
            FreeCAD.Console.PrintWarning('OpenSCAD executable not found\n')

        self.appendToolbar(QT_TRANSLATE_NOOP('Workbench', 'OpenSCADTools'),
                           toolbarcommands)
        self.appendMenu('OpenSCAD', commands)
        self.appendToolbar(
            QT_TRANSLATE_NOOP('Workbech', 'OpenSCAD Part tools'),
            parttoolbarcommands)
        #self.appendMenu('OpenSCAD',["AddOpenSCADElement"])
        ###self.appendCommandbar("&Generic Tools",["ColorCodeShape"])
        FreeCADGui.addIconPath(":/icons")
        FreeCADGui.addLanguagePath(":/translations")
        FreeCADGui.addPreferencePage(":/ui/openscadprefs-base.ui", "OpenSCAD")
Beispiel #2
0
    def Initialize(self):
        def QT_TRANSLATE_NOOP(scope, text):
            return text
        import OpenSCAD_rc,OpenSCADCommands
        commands=['OpenSCAD_ReplaceObject','OpenSCAD_RemoveSubtree',\
            'OpenSCAD_RefineShapeFeature',\
            'OpenSCAD_IncreaseToleranceFeature', 'OpenSCAD_Edgestofaces', \
            'OpenSCAD_ExpandPlacements','OpenSCAD_ExplodeGroup']
        toolbarcommands=['OpenSCAD_ReplaceObject','OpenSCAD_RemoveSubtree',\
            'OpenSCAD_ExplodeGroup','OpenSCAD_RefineShapeFeature']
            #'OpenSCAD_IncreaseToleranceFeature' #icon still missing
        import PartGui
        parttoolbarcommands = ['Part_CheckGeometry',"Part_Primitives",\
            "Part_Builder",'Part_Cut','Part_Fuse','Part_Common',\
            'Part_Extrude',"Part_Revolve"]
        import FreeCAD
        param = FreeCAD.ParamGet(\
            "User parameter:BaseApp/Preferences/Mod/OpenSCAD")
        openscadfilename = param.GetString('openscadexecutable')
        if not openscadfilename:

            import OpenSCADUtils
            openscadfilename = OpenSCADUtils.searchforopenscadexe()
            if openscadfilename: #automatic search was succsessful
                FreeCAD.addImportType("OpenSCAD Format (*.scad)","importCSG") 
                param.SetString('openscadexecutable',openscadfilename) #save the result
        if openscadfilename:
            commands.extend(['OpenSCAD_AddOpenSCADElement',
                'OpenSCAD_MeshBoolean','OpenSCAD_Hull','OpenSCAD_Minkowski'])
            toolbarcommands.extend(['OpenSCAD_AddOpenSCADElement',
                'OpenSCAD_MeshBoolean','OpenSCAD_Hull','OpenSCAD_Minkowski'])
        else:
            FreeCAD.Console.PrintWarning('OpenSCAD executable not found\n')

        self.appendToolbar(QT_TRANSLATE_NOOP('Workbench','OpenSCADTools'),toolbarcommands)
        self.appendMenu('OpenSCAD',commands)
        self.appendToolbar(QT_TRANSLATE_NOOP('Workbech','OpenSCAD Part tools'),parttoolbarcommands)
        #self.appendMenu('OpenSCAD',["AddOpenSCADElement"])
        ###self.appendCommandbar("&Generic Tools",["ColorCodeShape"])
        FreeCADGui.addIconPath(":/icons")
        FreeCADGui.addLanguagePath(":/translations")
        FreeCADGui.addPreferencePage(":/ui/openscadprefs-base.ui","OpenSCAD")
Beispiel #3
0
    def Initialize(self):
        import OpenSCAD_rc, OpenSCADCommands
        commands=['OpenSCAD_ReplaceObject','OpenSCAD_RemoveSubtree',\
            'OpenSCAD_RefineShapeFeature',"OpenSCAD_Edgestofaces",\
            'OpenSCAD_ExpandPlacements']
        toolbarcommands=['OpenSCAD_ReplaceObject','OpenSCAD_RemoveSubtree',\
            'OpenSCAD_RefineShapeFeature']
        import PartGui
        parttoolbarcommands = ['Part_CheckGeometry',"Part_Primitives",\
            "Part_Builder",'Part_Cut','Part_Fuse','Part_Common',\
            'Part_Extrude',"Part_Revolve"]
        import FreeCAD
        param = FreeCAD.ParamGet(\
            "User parameter:BaseApp/Preferences/Mod/OpenSCAD")
        openscadfilename = param.GetString('openscadexecutable')
        if not openscadfilename:

            import OpenSCADUtils
            openscadfilename = OpenSCADUtils.searchforopenscadexe()
            if openscadfilename:  #automatic search was succsessful
                FreeCAD.addImportType("OpenSCAD Format (*.scad)", "importCSG")
                param.SetString('openscadexecutable',
                                openscadfilename)  #save the result
        if openscadfilename:
            commands.extend(['OpenSCAD_AddOpenSCADElement'])
            toolbarcommands.extend(['OpenSCAD_AddOpenSCADElement'])
        else:
            FreeCAD.Console.PrintWarning('OpenSCAD executable not found\n')

        self.appendToolbar("OpenSCADTools", toolbarcommands)
        self.appendMenu('OpenSCAD', commands)
        self.appendToolbar('OpenSCAD Part tools', parttoolbarcommands)
        #self.appendMenu('OpenSCAD',["AddOpenSCADElement"])
        ###self.appendCommandbar("&Generic Tools",["ColorCodeShape"])
        FreeCADGui.addIconPath(":/icons")
        FreeCADGui.addLanguagePath(":/translations")
        FreeCADGui.addPreferencePage(":/ui/openscadprefs-base.ui", "OpenSCAD")
Beispiel #4
0
            ])

            toolbarcommands.extend([
                'OpenSCAD_AddOpenSCADElement', 'OpenSCAD_MeshBoolean',
                'OpenSCAD_Hull', 'OpenSCAD_Minkowski'
            ])
        else:
            FreeCAD.Console.PrintWarning('OpenSCAD executable not found\n')

        self.appendToolbar(QT_TRANSLATE_NOOP('Workbench', 'OpenSCADTools'),
                           toolbarcommands)
        self.appendMenu('OpenSCAD', commands)
        self.appendToolbar(
            QT_TRANSLATE_NOOP('Workbech', 'OpenSCAD Part tools'),
            parttoolbarcommands)
        #self.appendMenu('OpenSCAD',["AddOpenSCADElement"])
        ###self.appendCommandbar("&Generic Tools",["ColorCodeShape"])
        FreeCADGui.addIconPath(":/icons")
        FreeCADGui.addLanguagePath(":/translations")
        FreeCADGui.addPreferencePage(":/ui/openscadprefs-base.ui", "OpenSCAD")

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


Gui.addWorkbench(OpenSCADWorkbench())

openscadfilename = OpenSCADUtils.searchforopenscadexe()
if openscadfilename:  #automatic search was succsessful
    FreeCAD.__unit_test__ += ["TestOpenSCADGui"]
Beispiel #5
0
    def Initialize(self):
        def QT_TRANSLATE_NOOP(scope, text):
            return text

        import OpenSCAD_rc, OpenSCADCommands

        commands = [
            "OpenSCAD_ReplaceObject",
            "OpenSCAD_RemoveSubtree",
            "OpenSCAD_RefineShapeFeature",
            "OpenSCAD_MirrorMeshFeature",
            "OpenSCAD_ScaleMeshFeature",
            "OpenSCAD_ResizeMeshFeature",
            "OpenSCAD_IncreaseToleranceFeature",
            "OpenSCAD_Edgestofaces",
            "OpenSCAD_ExpandPlacements",
            "OpenSCAD_ExplodeGroup",
        ]
        toolbarcommands = [
            "OpenSCAD_ReplaceObject",
            "OpenSCAD_RemoveSubtree",
            "OpenSCAD_ExplodeGroup",
            "OpenSCAD_RefineShapeFeature",
            "OpenSCAD_IncreaseToleranceFeature",
        ]
        import PartGui

        parttoolbarcommands = [
            "Part_CheckGeometry",
            "Part_Primitives",
            "Part_Builder",
            "Part_Cut",
            "Part_Fuse",
            "Part_Common",
            "Part_Extrude",
            "Part_Revolve",
        ]
        import FreeCAD
        translate = FreeCAD.Qt.translate

        param = FreeCAD.ParamGet(
            "User parameter:BaseApp/Preferences/Mod/OpenSCAD")
        openscadfilename = param.GetString("openscadexecutable")
        if not openscadfilename:
            import OpenSCADUtils

            openscadfilename = OpenSCADUtils.searchforopenscadexe()
            if openscadfilename:  # automatic search was succsessful
                FreeCAD.addImportType("OpenSCAD Format (*.scad)", "importCSG")
                param.SetString("openscadexecutable",
                                openscadfilename)  # save the result
        if openscadfilename:
            commands.extend([
                "OpenSCAD_AddOpenSCADElement",
                "OpenSCAD_MeshBoolean",
                "OpenSCAD_Hull",
                "OpenSCAD_Minkowski",
            ])

            toolbarcommands.extend([
                "OpenSCAD_AddOpenSCADElement",
                "OpenSCAD_MeshBoolean",
                "OpenSCAD_Hull",
                "OpenSCAD_Minkowski",
            ])
        else:
            FreeCAD.Console.PrintWarning("OpenSCAD executable not found\n")

        transferMechanism = param.GetInt("transfermechanism", 0)
        if openscadfilename and transferMechanism == 0:
            # We are using the Python temp-directory creation function
            if "snap" in openscadfilename:
                FreeCAD.Console.PrintMessage(
                    translate(
                        "OpenSCAD",
                        "It looks like you may be using a Snap version of OpenSCAD.",
                    ) + " " + translate(
                        "OpenSCAD",
                        "If OpenSCAD execution fails to load the temporary file, use FreeCAD's OpenSCAD Workbench Preferences to change the transfer mechanism.",
                    ) + "\n")
            elif sys.executable.startswith("/tmp/"):  # Heuristic for AppImages
                FreeCAD.Console.PrintMessage(
                    translate(
                        "OpenSCAD",
                        "It looks like you may be using a sandboxed version of FreeCAD.",
                    ) + " " + translate(
                        "OpenSCAD",
                        "If OpenSCAD execution fails to load the temporary file, use FreeCAD's OpenSCAD Workbench Preferences to change the transfer mechanism.",
                    ) + "\n")

        self.appendToolbar(QT_TRANSLATE_NOOP("Workbench", "OpenSCADTools"),
                           toolbarcommands)
        self.appendMenu("OpenSCAD", commands)
        self.appendToolbar(
            QT_TRANSLATE_NOOP("Workbech", "OpenSCAD Part tools"),
            parttoolbarcommands)
        # self.appendMenu('OpenSCAD',["AddOpenSCADElement"])
        ###self.appendCommandbar("&Generic Tools",["ColorCodeShape"])
        FreeCADGui.addIconPath(":/icons")
        FreeCADGui.addLanguagePath(":/translations")
        FreeCADGui.addPreferencePage(":/ui/openscadprefs-base.ui", "OpenSCAD")