def getCommands(self, group):      
   cmdlist = []
   cmdsubs = {}
   for cmd in self.commands[group]:
     command, subgroup = cmd
     if subgroup != None and GroupButtonMode > 0:
       if not(subgroup in cmdsubs):
         cmdsubs[subgroup] = []
         if GroupButtonMode == 2:
           cmdlist.append(subgroup.replace(" ", ""))
           cmdlist.append("Separator")
       cmdsubs[subgroup].append(command)     
     else:
       cmdlist.append(command)
   for subcommand in cmdsubs:
     if GroupButtonMode == 2:
       Gui.addCommand(subcommand.replace(" ", ""), FSGroupCommand(cmdsubs[subcommand], subcommand, subcommand))
     else:
       cmdlist.append((subcommand.replace(" ", ""), cmdsubs[subcommand]))
   return cmdlist
Exemple #2
0
            new_part = freecad_document.addObject("Part::Feature", "test")

            transform_shape(part, new_part, freecad_document)
            bound_box = new_part.Shape.BoundBox
            shift_vector = FreeCAD.Vector(-bound_box.XMin + x_pos,
                                          -bound_box.YMin + y_pos,
                                          z_fix - bound_box.ZMin)
            x_pos += bound_box.XLength + margin
            new_part.Placement.Base = new_part.Placement.Base.add(shift_vector)
            bound_box = new_part.Shape.BoundBox
            freecad_document.recompute()

            if (bound_box.YLength + y_pos) > max_line_y:
                max_line_y = bound_box.YLength + y_pos

            if (i + 1) % per_line == 0:
                y_pos = max_line_y + margin
                x_pos = 0

            new_parts_list.append(new_part)

        for tmppart in new_parts_list:
            Draft.makeShape2DView(tmppart)

        freecad_document.recompute()

        return new_parts_list


Gui.addCommand('export_command', ExportCommand())
        return {
            'Pixmap':
            icon,  # the name of a svg file available in the resources
            'MenuText': "Add Press-Nut",
            'ToolTip': "Add PEM Self Clinching Metric Nut"
        }

    def Activated(self):
        FastenerBase.FSGenerateObjects(FSPressNutObject, "PressNut")
        return

    def IsActive(self):
        return Gui.ActiveDocument != None


Gui.addCommand("FSPressNut", FSPressnutCommand())
FastenerBase.FSCommands.append("FSPressNut", "screws", "PEM Inserts")

###################################################################################
# PEM Self Clinching standoffs types: SO/SOS/SOA/SO4
SOLengths = {
    '3': 0,
    '4': 0,
    '6': 0,
    '8': 0,
    '10': 4,
    '12': 4,
    '14': 4,
    '16': 8,
    '18': 8,
    '20': 8,
Exemple #4
0
      activeBody = view.getActiveObject('pdbody')
    if not smIsOperationLegal(activeBody, selobj):
        return
    doc.openTransaction("Add Bend")
    if activeBody is None or not smIsPartDesign(selobj):
      a = doc.addObject("Part::FeaturePython","SolidBend")
      SMSolidBend(a)
      SMBendViewProviderTree(a.ViewObject)
    else:
      #FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
      a = doc.addObject("PartDesign::FeaturePython","SolidBend")
      SMSolidBend(a)
      SMBendViewProviderFlat(a.ViewObject)
      activeBody.addObject(a)
    FreeCADGui.Selection.clearSelection()
    doc.recompute()
    doc.commitTransaction()
    return

  def IsActive(self):
    if len(Gui.Selection.getSelection()) < 1 or len(Gui.Selection.getSelectionEx()[0].SubElementNames) < 1:
      return False
#    selobj = Gui.Selection.getSelection()[0]
    for selFace in Gui.Selection.getSelectionEx()[0].SubObjects:
      if type(selFace) != Part.Edge :
        return False
    return True

Gui.addCommand('SMMakeBend',AddBendCommandClass())

    def Activated(self):
        doc = FreeCAD.ActiveDocument
        modifiers = QtGui.QApplication.keyboardModifiers()
        pg = FreeCAD.ParamGet("User parameter:Plugins/MeshRemodel")
        prec = pg.GetInt("SketchRadiusPrecision", 1)

        if modifiers == QtCore.Qt.NoModifier:
            if not "Sketcher_NewSketch" in Gui.listCommands():
                Gui.activateWorkbench("SketcherWorkbench")
                Gui.activateWorkbench("MeshRemodelWorkbench")
            Gui.runCommand("Sketcher_NewSketch")
            return

        doc.openTransaction("Create sketch")
        if modifiers == QtCore.Qt.AltModifier:
            #alternative method: on alt+click make separate sketch from each object, then merge them together
            sketches = []
            for obj in self.objs:
                sketches.append(
                    Draft.makeSketch(obj,
                                     autoconstraints=True,
                                     radiusPrecision=prec))
            doc.recompute()
            FreeCADGui.Selection.clearSelection()
            for sk in sketches:
                if sk:
                    FreeCADGui.Selection.addSelection(sk)
            if len(sketches) >= 2:
                if not "Sketcher_NewSketch" in Gui.listCommands():
                    Gui.activateWorkbench("SketcherWorkbench")
                    Gui.activateWorkbench("MeshRemodelWorkbench")
                FreeCADGui.runCommand("Sketcher_MergeSketches")

            sketch = doc.ActiveObject
            doc.recompute()
            for sk in sketches:
                if sk:
                    doc.removeObject(sk.Name)
        elif modifiers == QtCore.Qt.ControlModifier:
            #on ctrl+click make single sketch out of selected objects
            sketch = Draft.makeSketch(self.objs,
                                      autoconstraints=True,
                                      radiusPrecision=prec)
            doc.recompute()

        for o in self.objs:
            if hasattr(o, "ViewObject"):
                o.ViewObject.Visibility = False

        doc.recompute()
        doc.commitTransaction()
        return
    shape = origshape
    for diam in fp.diameters:
      FreeCAD.Console.PrintLog("Generating hole tool for: " + diam + "\n")
      edge, m, f, o, type = cshSplitEdgeDiam(diam)
      cshole = cshMakeCSHole(m, type)
      FastenerBase.FSMoveToObject(cshole, origshape.getElement(edge), f == '1', float(o))
      shape = shape.cut(cshole)
    fp.Shape = shape


class FSFilletCommand:
  """Make holes for countersunk screws"""

  def GetResources(self):
    icon = os.path.join( iconPath , 'IconCSHole.svg')
    return {'Pixmap'  : icon , # the name of a svg file available in the resources
            'MenuText': "Make countersunk" ,
            'ToolTip' : "Chamfer holes for countersunk screws"}
 
  def Activated(self):
    Gui.Control.showDialog(FSTaskFilletDialog(None))
    return
   
  def IsActive(self):
    return len(Gui.Selection.getSelectionEx()) == 1

Gui.addCommand("FSFillet", FSFilletCommand())
FastenerBase.FSCommands.append("FSFillet", "command")

# to monitor selections: add SelObserver http://www.freecadweb.org/wiki/index.php?title=Code_snippets#Function_resident_with_the_mouse_click_action
# to filter selections: use Gui.Selection.SelectionGate
  def IsActive(self):
    selObjs = self.GetSelection()
    return len(selObjs) > 0

  def GetSelection(self):
    screwObj = []
    for selobj in Gui.Selection.getSelectionEx():
      obj = selobj.Object
      #FreeCAD.Console.PrintLog("sel obj: " + str(obj) + "\n")
      if (hasattr(obj, 'Proxy') and isinstance(obj.Proxy, FSBaseObject)):
        if obj.baseObject != None:
          screwObj.append(obj)
    return screwObj
        
        
Gui.addCommand('FSFlip',FSFlipCommand())
FSCommands.append('FSFlip', "command")

class FSMoveCommand:
  """Move Screw command"""

  def GetResources(self):
    icon = os.path.join( iconPath , 'IconMove.svg')
    return {'Pixmap'  : icon , # the name of a svg file available in the resources
            'MenuText': "Move fastner" ,
            'ToolTip' : "Move fastner to a new location"}
 
  def Activated(self):
    selObj = self.GetSelection()
    if selObj[0] == None:
      return
".............   ",
".............   ",
"        ....    ",
"         ..     ",
"       .    .   ",
"      .      .  ",
"     .        . ",
"                ",
"                "};
"""
 
    def Initialize(self):
        import ExportPanel
        from panel import multiplejoins
        cmd_list = ["multiple_tabs_command", "export_command"]  # A list of command names created in the line above
        self.appendToolbar("Laser Cut Commands", cmd_list)  # creates a new toolbar with your commands
 
    def Activated(self):
        return
 
    def Deactivated(self):
        return
 
    def ContextMenu(self, recipient):
        self.appendContextMenu("My commands", self.list)
 
    def GetClassName(self):
        return "Gui::PythonWorkbench"
 
Gui.addWorkbench(LCInterlockingWorkbench())
Exemple #9
0
      activeBody = view.getActiveObject('pdbody')
    if not smIsOperationLegal(activeBody, selobj):
        return
    doc.openTransaction("Add Junction")
    if activeBody is None or not smIsPartDesign(selobj):
      a = doc.addObject("Part::FeaturePython","Junction")
      SMJunction(a)
      SMJViewProviderTree(a.ViewObject)
    else:
      #FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
      a = doc.addObject("PartDesign::FeaturePython","Junction")
      SMJunction(a)
      SMJViewProviderFlat(a.ViewObject)
      activeBody.addObject(a)
    FreeCADGui.Selection.clearSelection()
    doc.recompute()
    doc.commitTransaction()
    return

  def IsActive(self):
    if len(Gui.Selection.getSelection()) < 1 or len(Gui.Selection.getSelectionEx()[0].SubElementNames) < 1:
      return False
#    selobj = Gui.Selection.getSelection()[0]
    for selEdge in Gui.Selection.getSelectionEx()[0].SubObjects:
      if type(selEdge) != Part.Edge :
        return False
    return True

Gui.addCommand('SMMakeJunction',AddJunctionCommandClass())

        new_parts_list = []
        per_line = int(math.sqrt(len(parts_list)))
        for i in range(len(parts_list)):
            part = parts_list[i]
            new_part = freecad_document.addObject("Part::Feature", "test")

            transform_shape(part, new_part, freecad_document)
            bound_box = new_part.Shape.BoundBox
            shift_vector = FreeCAD.Vector(-bound_box.XMin + x_pos, -bound_box.YMin + y_pos, z_fix - bound_box.ZMin)
            x_pos += bound_box.XLength + margin
            new_part.Placement.Base = new_part.Placement.Base.add(shift_vector)
            bound_box = new_part.Shape.BoundBox
            freecad_document.recompute()

            if (bound_box.YLength + y_pos) > max_line_y:
                max_line_y = bound_box.YLength + y_pos

            if (i+1) % per_line == 0:
                y_pos = max_line_y + margin
                x_pos = 0

            new_parts_list.append(new_part)
            Draft.makeShape2DView(new_part)

        freecad_document.recompute()

        return new_parts_list


Gui.addCommand('export_command', ExportCommand())
Exemple #11
0
        self.top_box_param.get_properties()
        self.obj_box.need_recompute = True


class MakeRoundedBoxCommand:
    def __init__(self):
        return

    def GetResources(self):
        return {
            'Pixmap': os.path.join(
                iconPath, 'roundbox.xpm'
            ),  # the name of a svg file available in the resources
            'MenuText': "Rounded box",
            'ToolTip': "Make rounded box without tab"
        }

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

    def Activated(self):
        groupRoundedBox = FreeCAD.ActiveDocument.addObject(
            "Part::FeaturePython", "RoundedBox")
        GroupRoundedBox(groupRoundedBox)
        vp = ViewProviderGroupRoundedBox(groupRoundedBox.ViewObject)
        vp.setEdit(ViewProviderGroupRoundedBox)
        return


Gui.addCommand('make_rounded_box_command', MakeRoundedBoxCommand())
            'Pixmap':
            icon,  # the name of a svg file available in the resources
            'MenuText': "Add threaded rod for tapping holes",
            'ToolTip': "Add arbitrary length threaded rod for tapping holes"
        }

    def Activated(self):
        for selObj in FastenerBase.FSGetAttachableSelections():
            a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                                 "ScrewTap")
            FSScrewRodObject(a, selObj)
            a.Label = a.Proxy.itemText
            FSViewProviderTree(a.ViewObject)
        FreeCAD.ActiveDocument.recompute()
        return

    def IsActive(self):
        return Gui.ActiveDocument != None


Gui.addCommand("FSScrewTap", FSScrewRodCommand())
FastenerBase.FSCommands.append("FSScrewTap", "screws", "misc")

## add fastener types
FastenerBase.FSAddFastenerType("Screw")
FastenerBase.FSAddFastenerType("Washer", False)
FastenerBase.FSAddFastenerType("Nut", False)
FastenerBase.FSAddFastenerType("ScrewTap", True, False)
for item in ScrewMaker.screwTables:
    FastenerBase.FSAddItemsToType(ScrewMaker.screwTables[item][0], item)
Exemple #13
0
from FreeCAD import Base
from FreeCAD import Gui
import ArachNURBS as AN

# Locate Workbench Directory
import os, Silk_dummy
path_Silk = os.path.dirname(Silk_dummy.__file__)
path_Silk_icons = os.path.join(path_Silk, 'Resources', 'Icons')


class StarTrim_CubicNStar():
    def Activated(self):
        CubicNStar = Gui.Selection.getSelection()[0]
        a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                             "StarTrim_CubicNStar")
        AN.StarTrim_CubicNStar(a, CubicNStar)
        a.ViewObject.Proxy = 0  # just set it to something different from None (this assignment is needed to run an internal notification)
        a.ViewObject.DisplayMode = u"Shaded"
        a.ViewObject.ShapeColor = (0.33, 0.67, 1.00)
        FreeCAD.ActiveDocument.recompute()

    def GetResources(self):
        return {
            'Pixmap': path_Silk_icons + '/StarTrim_CubicNStar.svg',
            'MenuText': 'StarTrim_CubicNStar',
            'ToolTip': 'StarTrim_CubicNStar'
        }


Gui.addCommand('StarTrim_CubicNStar', StarTrim_CubicNStar())
            cshole = cshMakeCSHole(m, type)
            FastenerBase.FSMoveToObject(cshole, origshape.getElement(edge),
                                        f == '1', float(o))
            shape = shape.cut(cshole)
        fp.Shape = shape


class FSFilletCommand:
    """Make holes for countersunk screws"""
    def GetResources(self):
        icon = os.path.join(iconPath, 'IconCSHole.svg')
        return {
            'Pixmap':
            icon,  # the name of a svg file available in the resources
            'MenuText': "Make countersunk",
            'ToolTip': "Chamfer holes for countersunk screws"
        }

    def Activated(self):
        Gui.Control.showDialog(FSTaskFilletDialog(None))
        return

    def IsActive(self):
        return len(Gui.Selection.getSelectionEx()) == 1


Gui.addCommand("FSFillet", FSFilletCommand())
FastenerBase.FSCommands.append("FSFillet", "command")

# to monitor selections: add SelObserver http://www.freecadweb.org/wiki/index.php?title=Code_snippets#Function_resident_with_the_mouse_click_action
# to filter selections: use Gui.Selection.SelectionGate
        if hasattr(view, 'getActiveObject'):
            activeBody = view.getActiveObject('pdbody')
        if not smIsOperationLegal(activeBody, selobj):
            return
        doc.openTransaction("SketchOnSheet")
        if activeBody is None or not smIsPartDesign(selobj):
            a = doc.addObject("Part::FeaturePython", "SketchOnSheet")
            SMSketchOnSheet(a)
            SMSketchOnSheetVP(a.ViewObject)
        else:
            #FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
            a = doc.addObject("PartDesign::FeaturePython", "SketchOnSheet")
            SMSketchOnSheet(a)
            SMSketchOnSheetPDVP(a.ViewObject)
            activeBody.addObject(a)
        doc.recompute()
        doc.commitTransaction()
        return

    def IsActive(self):
        if len(Gui.Selection.getSelection()) < 2:
            return False


#    selobj = Gui.Selection.getSelection()[1]
#    if str(type(selobj)) != "<type 'Sketcher.SketchObject'>" :
#      return False
        return True

Gui.addCommand('SMSketchOnSheet', AddSketchOnSheetCommandClass())
    def IsActive(self):
        selObjs = self.GetSelection()
        return len(selObjs) > 0

    def GetSelection(self):
        screwObj = []
        for selobj in Gui.Selection.getSelectionEx():
            obj = selobj.Object
            #FreeCAD.Console.PrintLog("sel obj: " + str(obj) + "\n")
            if (hasattr(obj, 'Proxy') and isinstance(obj.Proxy, FSBaseObject)):
                if obj.baseObject != None:
                    screwObj.append(obj)
        return screwObj


Gui.addCommand('FSFlip', FSFlipCommand())
FSCommands.append('FSFlip', "command")


class FSMoveCommand:
    """Move Screw command"""
    def GetResources(self):
        icon = os.path.join(iconPath, 'IconMove.svg')
        return {
            'Pixmap':
            icon,  # the name of a svg file available in the resources
            'MenuText': "Move fastner",
            'ToolTip': "Move fastner to a new location"
        }

    def Activated(self):
Exemple #17
0
class ControlGrid5Star66_5Sub():
    def Activated(self):
        sel = Gui.Selection.getSelection()
        Sub_0 = Gui.Selection.getSelection()[0]
        Sub_1 = Gui.Selection.getSelection()[1]
        Sub_2 = Gui.Selection.getSelection()[2]
        Sub_3 = Gui.Selection.getSelection()[3]
        Sub_4 = Gui.Selection.getSelection()[4]
        SubList = [Sub_0, Sub_1, Sub_2, Sub_3, Sub_4]

        a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                             "ControlGrid5Star66_5Sub")
        AN.ControlGrid5Star66_5Sub(a, SubList)
        a.ViewObject.Proxy = 0  # just set it to something different from None (this assignment is needed to run an internal notification)
        a.ViewObject.LineWidth = 1.00
        a.ViewObject.LineColor = (1.00, 0.67, 0.00)
        a.ViewObject.PointSize = 2.00
        a.ViewObject.PointColor = (1.00, 1.00, 0.00)
        FreeCAD.ActiveDocument.recompute()

    def GetResources(self):
        return {
            'Pixmap': path_Silk_icons + '/ControlGrid5Star66_5Sub.svg',
            'MenuText': 'ControlGrid5Star66_5Sub',
            'ToolTip': 'ControlGrid5Star66_5Sub'
        }


Gui.addCommand('ControlGrid5Star66_5Sub', ControlGrid5Star66_5Sub())
Exemple #18
0
 def activated(self): 
     #FreeCAD.Console.PrintMessage("activate\n")
     self.obj=None
     self.view=Gui.activeDocument().activeView()
     self.call = self.view.addEventCallback("SoEvent",self.observe)
     FreeCADGui.seToolbar.show(self.mode)
Exemple #19
0
class SubGrid33_2Grid64():
    def Activated(self):
        sel = Gui.Selection.getSelection()

        Grid_a = Gui.Selection.getSelection()[0]
        Grid_b = Gui.Selection.getSelection()[1]

        a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                             "SubGrid33_2Grid64")
        AN.SubGrid33_2Grid64(a, Grid_a, Grid_b)
        a.ViewObject.Proxy = 0  # just set it to something different from None (this assignment is needed to run an internal notification)
        a.ViewObject.LineWidth = 1.00
        a.ViewObject.LineColor = (0.67, 1.00, 1.00)
        a.ViewObject.PointSize = 4.00
        a.ViewObject.PointColor = (0.00, 0.33, 1.00)
        FreeCAD.ActiveDocument.recompute()

    def GetResources(self):
        return {
            'Pixmap':
            path_Silk_icons + '/SubGrid33_2Grid64.svg',
            'MenuText':
            'SubGrid33_2Grid64',
            'ToolTip':
            'SubGrid33_2Grid64: \n Select two ControlGrid_64 objects meeting at a corner \n to generate a corner blend partial grid. \n this is intended for the case where the two ControlGrid_64 objects \n are blends grids which have segments of one common surface as inputs'
        }


Gui.addCommand('SubGrid33_2Grid64', SubGrid33_2Grid64())
  """Add Screw Rod command"""

  def GetResources(self):
    icon = os.path.join( iconPath , 'ScrewTap.svg')
    return {'Pixmap'  : icon , # the name of a svg file available in the resources
            'MenuText': "Add Threaded Rod" ,
            'ToolTip' : "Add arbitrary length threaded rod"}
 
  def Activated(self):
    for selObj in FastenerBase.FSGetAttachableSelections():
      a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","ScrewTap")
      FSScrewRodObject(a, selObj)
      a.Label = a.Proxy.itemText
      FSViewProviderTree(a.ViewObject)
    FreeCAD.ActiveDocument.recompute()
    return
   
  def IsActive(self):
    return Gui.ActiveDocument != None

Gui.addCommand("FSScrewTap",FSScrewRodCommand())
FastenerBase.FSCommands.append("FSScrewTap", "screws", "misc")

## add fastener types
FastenerBase.FSAddFastenerType("Screw")
FastenerBase.FSAddFastenerType("Washer", False)
FastenerBase.FSAddFastenerType("Nut", False)
FastenerBase.FSAddFastenerType("ScrewTap", True, False)
for item in ScrewMaker.screwTables:
  FastenerBase.FSAddItemsToType(ScrewMaker.screwTables[item][0], item)
    activeBody = None
    selobj = Gui.Selection.getSelectionEx()[0].Object
    if hasattr(view,'getActiveObject'):
      activeBody = view.getActiveObject('pdbody')
    if not smIsOperationLegal(activeBody, selobj):
        return
    doc.openTransaction("Bend")
    if activeBody == None or not smIsPartDesign(selobj):
      a = doc.addObject("Part::FeaturePython","Fold")
      SMFoldWall(a)
      SMFoldViewProvider(a.ViewObject)
    else:
      #FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
      a = doc.addObject("PartDesign::FeaturePython","Fold")
      SMFoldWall(a)
      SMFoldPDViewProvider(a.ViewObject)
      activeBody.addObject(a)
    doc.recompute()
    doc.commitTransaction()
    return
   
  def IsActive(self):
    if len(Gui.Selection.getSelection()) < 2 :
      return False
#    selobj = Gui.Selection.getSelection()[1]
#    if str(type(selobj)) != "<type 'Sketcher.SketchObject'>" :
#      return False
    return True

Gui.addCommand('SMFoldWall',AddFoldWallCommandClass())
 def activated(self):
     #FreeCAD.Console.PrintMessage("activate\n")
     self.obj = None
     self.view = Gui.activeDocument().activeView()
     self.call = self.view.addEventCallback("SoEvent", self.observe)
     FreeCADGui.seToolbar.show(self.mode)
    def Activated(self):
        for selObj in FastenerBase.FSGetAttachableSelections():
            a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                                 "ScrewTap")
            FSScrewRodObject(a, selObj)
            a.Label = a.Proxy.itemText
            FSViewProviderTree(a.ViewObject)
        FreeCAD.ActiveDocument.recompute()
        return

    def IsActive(self):
        return Gui.ActiveDocument != None


Gui.addCommand("FSScrewTap", FSScrewRodCommand())
FastenerBase.FSCommands.append("FSScrewTap", "screws", "misc")


class FSScrewDieObject(FSBaseObject):
    def __init__(self, obj, attachTo):
        '''"Add screw die" '''
        FSBaseObject.__init__(self, obj, attachTo)
        self.itemText = "ScrewDie"
        self.type = 'ScrewDie'
        diameters = screwMaker.GetAllDiams(self.type)
        diameters.insert(0, 'Auto')
        #self.Proxy = obj.Name

        obj.addProperty("App::PropertyEnumeration", "diameter", "Parameters",
                        "Screw diameter standard").diameter = diameters
            return
        doc.openTransaction("Add Relief")
        if activeBody is None or not smIsPartDesign(selobj):
            a = doc.addObject("Part::FeaturePython", "Relief")
            SMRelief(a)
            SMReliefViewProviderTree(a.ViewObject)
        else:
            #FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
            a = doc.addObject("PartDesign::FeaturePython", "Relief")
            SMRelief(a)
            SMReliefViewProviderFlat(a.ViewObject)
            activeBody.addObject(a)
        FreeCADGui.Selection.clearSelection()
        doc.recompute()
        doc.commitTransaction()
        return

    def IsActive(self):
        if len(Gui.Selection.getSelection()) < 1 or len(
                Gui.Selection.getSelectionEx()[0].SubElementNames) < 1:
            return False


#    selobj = Gui.Selection.getSelection()[0]
        for selVertex in Gui.Selection.getSelectionEx()[0].SubObjects:
            if type(selVertex) != Part.Vertex:
                return False
        return True

Gui.addCommand('SMMakeRelief', AddReliefCommandClass())
def FSAddScrewCommand(type, help, dropGroup=None):
    cmd = 'FS' + type
    Gui.addCommand(cmd, FSScrewCommand(type, help))
    FastenerBase.FSCommands.append(cmd, "screws", dropGroup)
Exemple #26
0
            AN.ControlPoly6_2N(a, sketch0, sketch1)
            a.ViewObject.Proxy = 0  # just set it to something different from None (this assignment is needed to run an internal notification)
            a.ViewObject.LineWidth = 1.00
            a.ViewObject.LineColor = (0.00, 1.00, 1.00)
            a.ViewObject.PointSize = 4.00
            a.ViewObject.PointColor = (0.00, 0.00, 1.00)
            FreeCAD.ActiveDocument.recompute()

        if mode == 'FilletBezier':
            CubicCurve4_0 = Gui.Selection.getSelection()[0]
            CubicCurve4_1 = Gui.Selection.getSelection()[1]
            a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                                 "ControlPoly6_FilletBezier")
            AN.ControlPoly6_FilletBezier(a, CubicCurve4_0, CubicCurve4_1)
            a.ViewObject.Proxy = 0  # just set it to something different from None (this assignment is needed to run an internal notification)
            a.ViewObject.LineWidth = 1.00
            a.ViewObject.LineColor = (0.00, 1.00, 1.00)
            a.ViewObject.PointSize = 4.00
            a.ViewObject.PointColor = (0.00, 0.00, 1.00)
            FreeCAD.ActiveDocument.recompute()

    def GetResources(self):
        return {
            'Pixmap': path_Silk_icons + '/ControlPoly6.svg',
            'MenuText': 'ControlPoly6',
            'ToolTip': 'ControlPoly6'
        }


Gui.addCommand('ControlPoly6', ControlPoly6())
Exemple #27
0
        return
    doc.openTransaction("Bend")
    if activeBody is None or not smIsPartDesign(selobj):
      a = doc.addObject("Part::FeaturePython","Bend")
      SMBendWall(a)
      SMViewProviderTree(a.ViewObject)
    else:
      #FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
      a = doc.addObject("PartDesign::FeaturePython","Bend")
      SMBendWall(a)
      SMViewProviderFlat(a.ViewObject)
      activeBody.addObject(a)
    FreeCADGui.Selection.clearSelection()
    doc.recompute()
    doc.commitTransaction()
    return
   
  def IsActive(self):
    if len(Gui.Selection.getSelection()) < 1 or len(Gui.Selection.getSelectionEx()[0].SubElementNames) < 1:
      return False
    selobj = Gui.Selection.getSelection()[0]
    if selobj.isDerivedFrom("Sketcher::SketchObject"):
      return False
    for selFace in Gui.Selection.getSelectionEx()[0].SubObjects:
      if type(selFace) == Part.Vertex :
        return False
    return True

Gui.addCommand('SMMakeWall',AddWallCommandClass())

Exemple #28
0
            a.ViewObject.LineColor = (0.00, 1.00, 1.00)
            a.ViewObject.PointSize = 4.00
            a.ViewObject.PointColor = (0.00, 0.00, 1.00)
            FreeCAD.ActiveDocument.recompute()

        if mode == '2N':
            sketch0 = Gui.Selection.getSelection()[0]
            sketch1 = Gui.Selection.getSelection()[1]
            a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                                 "ControlPoly4_2N")
            AN.ControlPoly4_2N(a, sketch0, sketch1)
            a.ViewObject.Proxy = 0  # just set it to something different from None (this assignment is needed to run an internal notification)
            a.ViewObject.LineWidth = 1.00
            a.ViewObject.LineColor = (0.00, 1.00, 1.00)
            a.ViewObject.PointSize = 4.00
            a.ViewObject.PointColor = (0.00, 0.00, 1.00)
            FreeCAD.ActiveDocument.recompute()

    def GetResources(self):
        return {
            'Pixmap':
            path_Silk_icons + '/ControlPoly4.svg',
            'MenuText':
            'ControlPoly4',
            'ToolTip':
            'ControlPoly4: \n Creates a 4 point control polygon from a variety of inputs. \n -a sketch of three lines connected end to end \n -two sketches containing a circle and a line each \n -if a single sketch is selected that does not contain \n three elements, the first element is converted \n (this works for line, arc of circle, and arc of ellipse elements)'
        }


Gui.addCommand('ControlPoly4', ControlPoly4())
Exemple #29
0
        if not smIsOperationLegal(activeBody, selobj):
            return
        doc.openTransaction("Corner Relief")
        if activeBody is None or not smIsPartDesign(selobj):
            a = doc.addObject("Part::FeaturePython", "CornerRelief")
            SMCornerRelief(a)
            SMCornerReliefVP(a.ViewObject)
        else:
            #FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
            a = doc.addObject("PartDesign::FeaturePython", "CornerRelief")
            SMCornerRelief(a)
            SMCornerReliefPDVP(a.ViewObject)
            activeBody.addObject(a)
        doc.recompute()
        doc.commitTransaction()
        return

    def IsActive(self):
        if len(Gui.Selection.getSelection()) < 1 or len(
                Gui.Selection.getSelectionEx()[0].SubElementNames) < 2:
            return False


#    selobj = Gui.Selection.getSelection()[0]
        for selVertex in Gui.Selection.getSelectionEx()[0].SubObjects:
            if type(selVertex) != Part.Edge:
                return False
        return True

Gui.addCommand('SMCornerRelief', AddCornerReliefCommandClass())
Exemple #30
0
# Locate Workbench Directory
import os, Silk_dummy
path_Silk = os.path.dirname(Silk_dummy.__file__)
path_Silk_icons = os.path.join(path_Silk, 'Resources', 'Icons')


class ControlGrid44_EdgeSegment():
    def Activated(self):
        surface = Gui.Selection.getSelection()[0]
        curve = Gui.Selection.getSelection()[1]
        a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                             "ControlGrid44_EdgeSegment")
        AN.ControlGrid44_EdgeSegment(a, surface, curve)
        a.ViewObject.Proxy = 0  # just set it to something different from None (this assignment is needed to run an internal notification)
        a.ViewObject.LineWidth = 1.00
        a.ViewObject.LineColor = (0.67, 1.00, 1.00)
        a.ViewObject.PointSize = 4.00
        a.ViewObject.PointColor = (0.00, 0.33, 1.00)
        FreeCAD.ActiveDocument.recompute()

    def GetResources(self):
        return {
            'Pixmap': path_Silk_icons + '/ControlGrid44_EdgeSegment.svg',
            'MenuText': 'ControlGrid44_EdgeSegment',
            'ToolTip': 'ControlGrid44_EdgeSegment'
        }


Gui.addCommand('ControlGrid44_EdgeSegment', ControlGrid44_EdgeSegment())
Exemple #31
0
  """Add Preass-nut command"""

  def GetResources(self):
    icon = os.path.join( iconPath , 'PEMPressNut.svg')
    return {'Pixmap'  : icon , # the name of a svg file available in the resources
            'MenuText': "Add Press-Nut" ,
            'ToolTip' : "Add PEM Self Clinching Metric Nut"}
 
  def Activated(self):
    FastenerBase.FSGenerateObjects(FSPressNutObject, "PressNut")
    return
   
  def IsActive(self):
    return Gui.ActiveDocument != None

Gui.addCommand("FSPressNut", FSPressnutCommand())
FastenerBase.FSCommands.append("FSPressNut", "screws", "PEM Inserts")


###################################################################################
# PEM Self Clinching standoffs types: SO/SOS/SOA/SO4
SOLengths = {'3':0, '4':0, '6':0, '8':0, '10':4, '12':4, '14':4, '16':8, '18':8, '20':8, '22':11, '25':11}
#BSLengths = {'6':3.2, '8':4, '10':4, '12':5, '14':6.5, '16':6.5, '18':9.5, '20':9.5, '22':9.5, '25':9.5}
SODiameters = ['Auto', 'M3', '3.5M3', 'M3.5', 'M4', 'M5' ]
SOPEMTable = {
#          B,    C,    H,   d, Lmin, Lmax
  'M3':   (3.2,  4.2,  4.8, 2.5, 3, 18),
  '3.5M3':(3.2,  5.39, 6.4, 2.5, 3, 25),
  'M3.5': (3.9,  5.39, 6.4, 2.9, 3, 25),
  'M4':   (4.8,  7.12, 7.9, 3.3, 3, 25),
  'M5':   (5.36, 7.12, 7.9, 4.2, 3, 25)
    a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Bend")
    SMBendWall(a)
    SMViewProviderTree(a.ViewObject)
    FreeCAD.ActiveDocument.recompute()
    return
   
  def IsActive(self):
    if len(Gui.Selection.getSelection()) < 1 or len(Gui.Selection.getSelectionEx()[0].SubElementNames) < 1:
      return False
    selobj = Gui.Selection.getSelection()[0]
    for selFace in Gui.Selection.getSelectionEx()[0].SubObjects:
      if type(selFace) != Part.Face:
        return False
    return True

Gui.addCommand('SMMakeWall',AddWallCommandClass())

###########################################################################################
# Extrude
###########################################################################################

def smExtrude(extLength = 10.0, selFaceNames = '', selObjectName = ''):
  
#  selFace = Gui.Selection.getSelectionEx()[0].SubObjects[0]
#  selObjectName = Gui.Selection.getSelection()[0].Name
  AAD = FreeCAD.ActiveDocument
  MainObject = AAD.getObject( selObjectName )
  finalShape = MainObject.Shape
  for selFaceName in selFaceNames:
    selFace = AAD.getObject(selObjectName).Shape.getElement(selFaceName)
            'MenuText': "Change fastener parameters" ,
            'ToolTip' : "Change parameters of selected fasteners"}
 
  def Activated(self):
    dlg = FSTaskChangeParamDialog(None)
    fstype = FastenerBase.FSFasenerTypeDB[self.type]
    dlg.FillFields(fstype)
    Gui.Control.showDialog(dlg)
    return
   
  def IsActive(self):
    sel = Gui.Selection.getSelection()
    if len(sel) == 0:
      return False
    self.type = None
    tmaxlen = 0
    for typename in FastenerBase.FSFasenerTypeDB:
      #FreeCAD.Console.PrintLog(typename + "\n")
      if filter(lambda c: not c.isdigit(), sel[0].Name) == typename:
        self.type = typename
    if self.type == None:
      return False
    for obj in sel:
      if filter(lambda c: not c.isdigit(), obj.Name) != self.type:
        return False
    return True
      

Gui.addCommand("FSChangeParams", FSChangeParamCommand())
FastenerBase.FSCommands.append("FSChangeParams", "command")
Exemple #34
0
from FreeCAD import Base
from FreeCAD import Gui
import ArachNURBS as AN

# Locate Workbench Directory
import os, Silk_dummy
path_Silk = os.path.dirname(Silk_dummy.__file__)
path_Silk_icons = os.path.join(path_Silk, 'Resources', 'Icons')


class CubicNStarSurface_NStar66():
    def Activated(self):
        NStar66 = Gui.Selection.getSelection()[0]
        a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                             "CubicNStarSurface_NStar66")
        AN.CubicNStarSurface_NStar66(a, NStar66)
        a.ViewObject.Proxy = 0  # just set it to something different from None (this assignment is needed to run an internal notification)
        a.ViewObject.DisplayMode = u"Shaded"
        a.ViewObject.ShapeColor = (0.33, 0.67, 1.00)
        FreeCAD.ActiveDocument.recompute()

    def GetResources(self):
        return {
            'Pixmap': path_Silk_icons + '/CubicNStarSurface_NStar66.svg',
            'MenuText': 'CubicNStarSurface_NStar66',
            'ToolTip': 'CubicNStarSurface_NStar66'
        }


Gui.addCommand('CubicNStarSurface_NStar66', CubicNStarSurface_NStar66())
        if hasattr(view, 'getActiveObject'):
            activeBody = view.getActiveObject('pdbody')


#    if not smIsOperationLegal(activeBody, selobj):
#        return
        doc.openTransaction("BaseBend")
        if activeBody is None or not smIsSketchObject(selobj):
            a = doc.addObject("Part::FeaturePython", "BaseBend")
            SMBaseBend(a)
            SMBaseViewProvider(a.ViewObject)
        else:
            #FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
            a = doc.addObject("PartDesign::FeaturePython", "BaseBend")
            SMBaseBend(a)
            SMBaseViewProvider(a.ViewObject)
            activeBody.addObject(a)
        doc.recompute()
        doc.commitTransaction()
        return

    def IsActive(self):
        if len(Gui.Selection.getSelection()) != 1:
            return False
        selobj = Gui.Selection.getSelection()[0]
        if not (selobj.isDerivedFrom("Sketcher::SketchObject")):
            return False
        return True

Gui.addCommand('SMBase', AddBaseCommandClass())
  """Add Preass-nut command"""

  def GetResources(self):
    icon = os.path.join( iconPath , 'PEMPressNut.svg')
    return {'Pixmap'  : icon , # the name of a svg file available in the resources
            'MenuText': "Add Press-Nut" ,
            'ToolTip' : "Add PEM Self Clinching Metric Nut"}
 
  def Activated(self):
    FastenerBase.FSGenerateObjects(FSPressNutObject, "PressNut")
    return
   
  def IsActive(self):
    return Gui.ActiveDocument != None

Gui.addCommand("FSPressNut", FSPressnutCommand())
FastenerBase.FSCommands.append("FSPressNut", "screws", "PEM Inserts")


###################################################################################
# PEM Self Clinching standoffs types: SO/SOS/SOA/SO4
SOLengths = {'3':0, '4':0, '6':0, '8':0, '10':4, '12':4, '14':4, '16':8, '18':8, '20':8, '22':11, '25':11}
#BSLengths = {'6':3.2, '8':4, '10':4, '12':5, '14':6.5, '16':6.5, '18':9.5, '20':9.5, '22':9.5, '25':9.5}
SODiameters = ['Auto', 'M3', '3.5M3', 'M3.5', 'M4', 'M5' ]
SOPEMTable = {
#          B,    C,    H,   d, Lmin, Lmax
  'M3':   (3.2,  4.2,  4.8, 2.5, 3, 18),
  '3.5M3':(3.2,  5.39, 6.4, 2.5, 3, 25),
  'M3.5': (3.9,  5.39, 6.4, 2.9, 3, 25),
  'M4':   (4.8,  7.12, 7.9, 3.3, 3, 25),
  'M5':   (5.36, 7.12, 7.9, 4.2, 3, 25)
Exemple #37
0
      activeBody = view.getActiveObject('pdbody')
    if not smIsOperationLegal(activeBody, selobj):
        return
    doc.openTransaction("Bend")
    if activeBody is None or not smIsPartDesign(selobj):
      a = doc.addObject("Part::FeaturePython","Fold")
      SMFoldWall(a)
      SMFoldViewProvider(a.ViewObject)
    else:
      #FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
      a = doc.addObject("PartDesign::FeaturePython","Fold")
      SMFoldWall(a)
      SMFoldPDViewProvider(a.ViewObject)
      activeBody.addObject(a)
    doc.recompute()
    doc.commitTransaction()
    return

  def IsActive(self):
    if len(Gui.Selection.getSelection()) < 2 :
      return False
    selFace = Gui.Selection.getSelectionEx()[0].SubObjects[0]
    if type(selFace) != Part.Face:
      return False
    selobj = Gui.Selection.getSelection()[1]
    if not(selobj.isDerivedFrom('Sketcher::SketchObject')) :
      return False
    return True

Gui.addCommand('SMFoldWall',AddFoldWallCommandClass())
  ("M6", 6),
  ("M8", 8)
)

FSCScrewTypes = (
  ("ISO7045.svg", "Metric Screw", ScrewMaker.FSCScrewHoleChart),
  ("PEMPressNut.svg", "PEM Press-nut", FSCPEMPressNutHoleChart),
  ("PEMBLStandoff.svg", "PEM Stand-off", FSCPEMStudHoleChart),
  ("PEMStud.svg", "PEM Stud", FSCPEMStudHoleChart)
)
       
FSScrewCalcDlg = QtGui.QDockWidget()
FSScrewCalcDlg.ui = Ui_DockWidget()
FSScrewCalcDlg.ui.setupUi(FSScrewCalcDlg)
FSScrewCalcDlg.ui.fillScrewTypes()
Gui.getMainWindow().addDockWidget(QtCore.Qt.RightDockWidgetArea, FSScrewCalcDlg)
FSScrewCalcDlg.setFloating(True)
FSScrewCalcDlg.hide()
   

class FSScrewCalcCommand:
  """Display a calculator for needed screw holes"""

  def GetResources(self):
    FreeCAD.Console.PrintLog("Getting resources\n")
    icon = os.path.join( iconPath , 'IconScrewCalc.svg')
    return {'Pixmap'  : icon , # the name of a svg file available in the resources
            'MenuText': "Screw calculator" ,
            'ToolTip' : "Show a screw hole calculator"}
 
  def Activated(self):
Exemple #39
0
import os, Silk_dummy
path_Silk = os.path.dirname(Silk_dummy.__file__)
path_Silk_icons = os.path.join(path_Silk, 'Resources', 'Icons')


class SubGrid63_2Surf64():
    def Activated(self):
        sel = Gui.Selection.getSelection()
        Surf_0 = Gui.Selection.getSelection()[0]
        Surf_1 = Gui.Selection.getSelection()[1]

        a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                             "SubGrid63_2Surf64")
        AN.SubGrid63_2Surf64(a, Surf_0, Surf_1)
        a.ViewObject.Proxy = 0  # just set it to something different from None (this assignment is needed to run an internal notification)
        a.ViewObject.LineWidth = 1.00
        a.ViewObject.LineColor = (1.00, 0.67, 0.00)
        a.ViewObject.PointSize = 2.00
        a.ViewObject.PointColor = (1.00, 1.00, 0.00)
        FreeCAD.ActiveDocument.recompute()

    def GetResources(self):
        return {
            'Pixmap': path_Silk_icons + '/SubGrid63_2Surf64.svg',
            'MenuText': 'SubGrid63_2Surf64',
            'ToolTip': 'SubGrid63_2Surf64'
        }


Gui.addCommand('SubGrid63_2Surf64', SubGrid63_2Surf64())
 def Activated(self):
     if not "Sketcher_NewSketch" in Gui.listCommands():
         Gui.activateWorkbench("SketcherWorkbench")
         Gui.activateWorkbench("MeshRemodelWorkbench")
     Gui.runCommand("Sketcher_ValidateSketch")
     return
def initialize():
    if FreeCAD.GuiUp:
        Gui.addCommand("MeshRemodelCreatePointsObject",
                       MeshRemodelCreatePointsObjectCommandClass())
        Gui.addCommand("MeshRemodelCreateCoplanarPointsObject",
                       MeshRemodelCreateCoplanarPointsObjectCommandClass())
        Gui.addCommand("MeshRemodelCreateLine",
                       MeshRemodelCreateLineCommandClass())
        Gui.addCommand("MeshRemodelCreatePolygon",
                       MeshRemodelCreatePolygonCommandClass())
        Gui.addCommand("MeshRemodelCreateBSpline",
                       MeshRemodelCreateBSplineCommandClass())
        Gui.addCommand("MeshRemodelCreateCircle",
                       MeshRemodelCreateCircleCommandClass())
        Gui.addCommand("MeshRemodelCreateArc",
                       MeshRemodelCreateArcCommandClass())
        Gui.addCommand("MeshRemodelCreateWire",
                       MeshRemodelCreateWireCommandClass())
        Gui.addCommand("MeshRemodelCreateSketch",
                       MeshRemodelCreateSketchCommandClass())
        Gui.addCommand("MeshRemodelMergeSketches",
                       MeshRemodelMergeSketchesCommandClass())
        Gui.addCommand("MeshRemodelValidateSketch",
                       MeshRemodelValidateSketchCommandClass())
        Gui.addCommand("MeshRemodelSettings",
                       MeshRemodelSettingsCommandClass())
def FSAddScrewCommand(type, help, dropGroup = None):
  cmd = 'FS' + type
  Gui.addCommand(cmd,FSScrewCommand(type, help))
  FastenerBase.FSCommands.append(cmd, "screws", dropGroup)
    def Activated(self):
        doc = FreeCAD.ActiveDocument
        pg = FreeCAD.ParamGet("User parameter:Plugins/MeshRemodel")
        line_width = pg.GetFloat("LineWidth", 5.0)
        point_size = pg.GetFloat("PointSize", 4.0)
        coplanar_tolerance = pg.GetFloat("CoplanarTolerance", .001)
        #QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
        doc.openTransaction("Create coplanar")
        modifiers = QtGui.QApplication.keyboardModifiers()
        trio = [self.pts[0], self.pts[1], self.pts[2]]
        candidates = []
        if self.obj and hasattr(self.obj, "Shape"):
            candidates = self.obj.Shape.Vertexes
        coplanar = []

        for v in candidates:
            if modifiers == QtCore.Qt.AltModifier or modifiers == QtCore.Qt.AltModifier.__or__(
                    QtCore.Qt.ShiftModifier):
                poly = Part.makePolygon([trio[0], trio[1], trio[2], v.Point])
                if DraftGeomUtils.isPlanar(poly):
                    planar = True
                else:
                    planar = False
            else:  #use our own complanar check
                if gu.isCoplanar(trio, v.Point, coplanar_tolerance):
                    planar = True
                else:
                    planar = False

            if planar:
                coplanar.append(Part.Point(v.Point).toShape())
        coplanar.extend([Part.Point(v).toShape() for v in trio])

        Part.show(Part.makeCompound(coplanar), "MR_Points_Coplanar")
        doc.ActiveObject.ViewObject.PointSize = point_size
        mr = doc.ActiveObject
        if not "Sketcher_NewSketch" in Gui.listCommands():
            Gui.activateWorkbench("SketcherWorkbench")
            Gui.activateWorkbench("MeshRemodelWorkbench")
        Gui.runCommand("Sketcher_NewSketch")
        sketch = doc.ActiveObject
        sketch.Label = mr.Name + '_Sketch'
        sketch.MapReversed = True
        for ii in range(0, len(mr.Shape.Vertexes)):
            vname = 'Vertex' + str(ii + 1)
            sketch.addExternal(mr.Name, vname)

        doc.recompute()

        if self.obj and hasattr(self.obj, "ViewObject"):
            self.obj.ViewObject.Visibility = False
        doc.recompute()
        doc.commitTransaction()
        if modifiers == QtCore.Qt.ShiftModifier or modifiers == QtCore.Qt.ShiftModifier.__or__(
                QtCore.Qt.AltModifier):
            doc.openTransaction("explode coplanar points")
            import CompoundTools.Explode
            input_obj = doc.ActiveObject
            comp = CompoundTools.Explode.explodeCompound(input_obj)
            input_obj.ViewObject.hide()
            for obj in comp[1]:
                obj.ViewObject.PointSize = point_size
            doc.recompute()
            doc.commitTransaction()
        #QtGui.QApplication.restoreOverrideCursor()
        return
      s = nutMakeSolid(d)
      self.diameter = fp.diameter
      fp.Shape = s
      fp.Label = fp.diameter + '-Nut'
    else:
      FreeCAD.Console.PrintLog("Using cached object\n")
    if shape != None:
      #fp.Placement = FreeCAD.Placement() # reset placement
      FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)

FastenerBase.FSClassIcons[FSHexNutObject] = 'HexNut.svg'    

class FSHexNutCommand:
  """Add Preass-nut command"""

  def GetResources(self):
    icon = os.path.join( iconPath , 'HexNut.svg')
    return {'Pixmap'  : icon , # the name of a svg file available in the resources
            'MenuText': "Add Hex Nut" ,
            'ToolTip' : "Add Metric Hexagon Nut - ISO 4032, Style 3"}
 
  def Activated(self):
    FastenerBase.FSGenerateObjects(FSHexNutObject, "Nut")
    return
   
  def IsActive(self):
    return Gui.ActiveDocument != None

Gui.addCommand("FSHexNut", FSHexNutCommand())
#FastenerBase.FSCommands.append("FSHexNut", "screws", "Nut")
    def set_transparency(self):
        for obj in self.other_object_list:
            freecad_object = obj['obj']
            freecad_object.ViewObject.Transparency = 90

    def check_is_in_active_view(self):
        if self.active_document != FreeCAD.ActiveDocument:
            raise ValueError("You have to select original document")
        return True

class MultipleCommand:

    def __init__(self):
        return

    def GetResources(self):
        return {'Pixmap': os.path.join(iconPath, 'one_tab.xpm'),  # the name of a svg file available in the resources
                'MenuText': "Slots",
                'ToolTip': "Slots"}

    def IsActive(self):
        return True

    def Activated(self):
        panel = MultipleJoins()
        FreeCADGui.Control.showDialog(panel)
        return

Gui.addCommand('multiple_tabs_command', MultipleCommand())