Пример #1
0
 def removeElement(self):
     if self.obj:
         it = self.tree.currentItem()
         if it:
             comp = FreeCAD.ActiveDocument.getObject(str(it.toolTip(0)))
             ArchComponent.removeFromComponent(self.obj,comp)
         self.update()
Пример #2
0
 def removeElement(self):
     if self.obj:
         it = self.tree.currentItem()
         if it:
             comp = FreeCAD.ActiveDocument.getObject(str(it.text(0)))
             ArchComponent.removeFromComponent(self.obj, comp)
         self.update()
Пример #3
0
    def Activated(self):

        FreeCAD.ActiveDocument.openTransaction(
            translate("Arch", "Create Space"))
        FreeCADGui.addModule("Arch")
        sel = FreeCADGui.Selection.getSelection()
        if sel:
            FreeCADGui.Control.closeDialog()
            if len(sel) == 1:
                FreeCADGui.doCommand(
                    "obj = Arch.makeSpace(FreeCADGui.Selection.getSelection())"
                )
            else:
                FreeCADGui.doCommand(
                    "obj = Arch.makeSpace(FreeCADGui.Selection.getSelectionEx())"
                )
            FreeCADGui.addModule("Draft")
            FreeCADGui.doCommand("Draft.autogroup(obj)")
            FreeCAD.ActiveDocument.commitTransaction()
            FreeCAD.ActiveDocument.recompute()
        else:
            FreeCAD.Console.PrintMessage(
                translate("Arch", "Please select a base object") + "\n")
            FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel())
            FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(
                nextCommand="Arch_Space")
            FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
Пример #4
0
    def Activated(self):

        sel = FreeCADGui.Selection.getSelectionEx()
        if sel:
            obj = sel[0].Object
            if Draft.getType(obj) == "Structure":
                if len(sel) > 1:
                    sk = sel[1].Object
                    if hasattr(sk, 'Shape'):
                        if len(sk.Shape.Wires) == 1:
                            # we have a structure and a wire: create the rebar now
                            FreeCAD.ActiveDocument.openTransaction(
                                translate("Arch", "Create Rebar"))
                            FreeCADGui.addModule("Arch")
                            FreeCADGui.doCommand(
                                "Arch.makeRebar(FreeCAD.ActiveDocument." +
                                obj.Name + ",FreeCAD.ActiveDocument." +
                                sk.Name + ")")
                            FreeCAD.ActiveDocument.commitTransaction()
                            FreeCAD.ActiveDocument.recompute()
                            return
                else:
                    # we have only a structure: open the sketcher
                    FreeCADGui.activateWorkbench("SketcherWorkbench")
                    FreeCADGui.runCommand("Sketcher_NewSketch")
                    FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(
                        obj,
                        FreeCAD.ActiveDocument.Objects[-1],
                        hide=False,
                        nextCommand="Arch_Rebar")
                    FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
                    return
            elif hasattr(obj, 'Shape'):
                if len(obj.Shape.Wires) == 1:
                    # we have only a wire: extract its support object, if available, and make the rebar
                    support = "None"
                    if hasattr(obj, "Support"):
                        if obj.Support:
                            if len(obj.Support) != 0:
                                support = "FreeCAD.ActiveDocument." + obj.Support[
                                    0][0].Name
                    FreeCAD.ActiveDocument.openTransaction(
                        translate("Arch", "Create Rebar"))
                    FreeCADGui.addModule("Arch")
                    FreeCADGui.doCommand("Arch.makeRebar(" + support +
                                         ",FreeCAD.ActiveDocument." +
                                         obj.Name + ")")
                    FreeCAD.ActiveDocument.commitTransaction()
                    FreeCAD.ActiveDocument.recompute()
                    return

        FreeCAD.Console.PrintMessage(
            translate("Arch",
                      "Please select a base face on a structural object") +
            "\n")
        FreeCADGui.Control.closeDialog()
        FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel())
        FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(
            nextCommand="Arch_Rebar")
        FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
Пример #5
0
    def Activated(self):
        sel = FreeCADGui.Selection.getSelectionEx()
        if sel:
            obj = sel[0].Object
            if Draft.getType(obj) == "Structure":
                if len(sel) > 1:
                    sk = sel[1].Object
                    if Draft.getType(sk) == "Sketch":
                        # we have a base object and a sketch: create the rebar now
                        FreeCAD.ActiveDocument.openTransaction(
                            translate("Arch", "Create Rebar"))
                        FreeCADGui.addModule("Arch")
                        FreeCADGui.doCommand(
                            "Arch.makeRebar(FreeCAD.ActiveDocument." +
                            obj.Name + ",FreeCAD.ActiveDocument." + sk.Name +
                            ")")
                        FreeCAD.ActiveDocument.commitTransaction()
                        FreeCAD.ActiveDocument.recompute()
                        return
                else:
                    # we have only a base object: open the sketcher
                    FreeCADGui.activateWorkbench("SketcherWorkbench")
                    FreeCADGui.runCommand("Sketcher_NewSketch")
                    FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(
                        obj,
                        FreeCAD.ActiveDocument.Objects[-1],
                        hide=False,
                        nextCommand="Arch_Rebar")
                    FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
                    return
            elif Draft.getType(obj) == "Sketch":
                # we have only the sketch: extract the base object from it
                if hasattr(obj, "Support"):
                    if obj.Support:
                        if len(obj.Support) != 0:
                            sup = obj.Support[0][0]
                        else:
                            print "Arch: error: couldn't extract a base object"
                            return
                        FreeCAD.ActiveDocument.openTransaction(
                            translate("Arch", "Create Rebar"))
                        FreeCADGui.addModule("Arch")
                        FreeCADGui.doCommand(
                            "Arch.makeRebar(FreeCAD.ActiveDocument." +
                            sup.Name + ",FreeCAD.ActiveDocument." + obj.Name +
                            ")")
                        FreeCAD.ActiveDocument.commitTransaction()
                        FreeCAD.ActiveDocument.recompute()
                        return
                    else:
                        print "Arch: error: couldn't extract a base object"
                        return

        FreeCAD.Console.PrintMessage(
            translate("Arch",
                      "Please select a base face on a structural object\n"))
        FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel())
        FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(
            nextCommand="Arch_Rebar")
        FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
Пример #6
0
    def Activated(self):

        sel = FreeCADGui.Selection.getSelectionEx()
        if sel:
            sel = sel[0]
            obj = sel.Object
            FreeCADGui.Control.closeDialog()
            if sel.HasSubObjects:
                if "Face" in sel.SubElementNames[0]:
                    idx = int(sel.SubElementNames[0][4:])
                    FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Roof"))
                    FreeCADGui.addModule("Arch")
                    FreeCADGui.doCommand("obj = Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+","+str(idx)+")")
                    FreeCADGui.addModule("Draft")
                    FreeCADGui.doCommand("Draft.autogroup(obj)")
                    FreeCAD.ActiveDocument.commitTransaction()
                    FreeCAD.ActiveDocument.recompute()
                    return
            if obj.isDerivedFrom("Part::Feature"):
                if obj.Shape.Wires:
                    FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Roof"))
                    FreeCADGui.addModule("Arch")
                    FreeCADGui.doCommand("obj = Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+")")
                    FreeCADGui.addModule("Draft")
                    FreeCADGui.doCommand("Draft.autogroup(obj)")
                    FreeCAD.ActiveDocument.commitTransaction()
                    FreeCAD.ActiveDocument.recompute()
                    return
            else:
                FreeCAD.Console.PrintMessage(translate("Arch","Unable to create a roof"))
        else:
            FreeCAD.Console.PrintMessage(translate("Arch","Please select a base object")+"\n")
            FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel())
            FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(nextCommand="Arch_Roof")
            FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
 def addElement(self):
     if self.obj:
         added = False
         for o in FreeCADGui.Selection.getSelection():
             if o != self.obj:
                 ArchComponent.addToComponent(self.obj,o,"Objects")
                 added = True
         if added:
             self.update()
         else:
             FreeCAD.Console.PrintWarning("Please select objects in the 3D view or in the model tree before pressing the button\n")
Пример #8
0
 def addElement(self):
     it = self.tree.currentItem()
     if it:
         mod = None
         for a in self.attribs:
             if it.text(0) == getattr(self, "tree" + a).text(0):
                 mod = a
         if mod == "Machinings":
             print("TODO : Add Machinings")
         else:
             for o in FreeCADGui.Selection.getSelection():
                 ArchComponent.addToComponent(self.obj, o, mod)
     self.update()
Пример #9
0
 def addElement(self):
     it = self.tree.currentItem()
     if it:
         mod = None
         for a in self.attribs:
             if it.text(0) == getattr(self,"tree"+a).text(0):
                 mod = a
         if mod == "Machinings":
             print "TODO : Add Machinings"
         else :
             for o in FreeCADGui.Selection.getSelection():
                 ArchComponent.addToComponent(self.obj,o,mod)
     self.update()
Пример #10
0
 def Activated(self):
     sel = FreeCADGui.Selection.getSelection()
     if sel:
         if Draft.getType(sel[0]) == "Wall":
             FreeCADGui.activateWorkbench("SketcherWorkbench")
             FreeCADGui.runCommand("Sketcher_NewSketch")
             FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(sel[0],FreeCAD.ActiveDocument.Objects[-1],hide=False,nextCommand="Arch_Window")
             FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
         else:
             FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Window")))
             FreeCADGui.doCommand("import Arch")
             for obj in sel:
                 FreeCADGui.doCommand("Arch.makeWindow(FreeCAD.ActiveDocument."+obj.Name+")")
                 if hasattr(obj,"Support"):
                     if obj.Support:
                         if isinstance(obj.Support,tuple):
                             s = obj.Support[0]
                         else:
                             s = obj.Support
                         w = FreeCAD.ActiveDocument.Objects[-1] # last created object
                         FreeCADGui.doCommand("Arch.removeComponents(FreeCAD.ActiveDocument."+w.Name+",host=FreeCAD.ActiveDocument."+s.Name+")")
                 elif Draft.isClone(obj,"Window"):
                     if obj.Objects[0].Inlist:
                         FreeCADGui.doCommand("Arch.removeComponents(FreeCAD.ActiveDocument."+obj.Name+",host=FreeCAD.ActiveDocument."+obj.Objects[0].Inlist[0].Name+")")
             FreeCAD.ActiveDocument.commitTransaction()
Пример #11
0
    def setEdit(self, vobj, mode):
        """Method called when the document requests the object to enter edit mode.

        Edit mode is entered when a user double clicks on an object in the tree
        view, or when they use the menu option [Edit -> Toggle Edit Mode].

        Just display the standard Arch component task panel.

        Parameters
        ----------
        mode: int or str
            The edit mode the document has requested. Set to 0 when requested via
            a double click or [Edit -> Toggle Edit Mode].

        Returns
        -------
        bool
            If edit mode was entered.
        """

        if (mode == 0) and hasattr(self, "Object"):
            import ArchComponent
            taskd = ArchComponent.ComponentTaskPanel()
            taskd.obj = self.Object
            taskd.update()
            FreeCADGui.Control.showDialog(taskd)
            return True
        return False
Пример #12
0
 def setEdit(self, vobj, mode):
     if mode == 0:
         import ArchComponent
         taskd = ArchComponent.ComponentTaskPanel()
         taskd.obj = self.Object
         taskd.update()
         FreeCADGui.Control.showDialog(taskd)
         return True
     return False
Пример #13
0
    def editProperties(self):

        sel = self.form.tree.selectedIndexes()
        if len(sel) <= 3:
            obj = FreeCAD.ActiveDocument.getObject(
                self.model.itemFromIndex(sel[0]).toolTip())
            if obj:
                import ArchComponent
                p = ArchComponent.ComponentTaskPanel()
                p.obj = obj
                p.editIfcProperties()
Пример #14
0
 def Activated(self):
     sel = FreeCADGui.Selection.getSelectionEx()
     if sel:
         sel = sel[0]
         obj = sel.Object
         if obj.isDerivedFrom("Part::Part2DObjectPython"):
             base_obj = Draft.make_sketch(obj,
                                          autoconstraints=True,
                                          delete=True)
         elif obj.isDerivedFrom("Sketcher::SketchObject"):
             base_obj = obj
         FreeCADGui.Control.closeDialog()
         roof3d.make_roof(base_obj)
     else:
         FreeCAD.Console.PrintMessage("Please select a base object first" +
                                      "\n")
         FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel())
         FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(
             nextCommand="pitched_roof_create_3d")
         FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
Пример #15
0
 def __init__(self,obj):
     ArchComponent.Component.__init__(self,obj)
     obj.addProperty("App::PropertyLength","Length","1Timber","The length of this element.")
     obj.addProperty("App::PropertyLength","Width","1Timber","The width of this element.")
     obj.addProperty("App::PropertyLength","Height","1Timber","The height of this element.")
     obj.addProperty("App::PropertyEnumeration","Preset","1Timber","Preset parameters for this beam")
     obj.Preset = TimberComponent.getPresetsList()
     #obj.addProperty("App::PropertyLinkList","Armatures","Arch","Armatures contained in this element")
     #obj.addProperty("App::PropertyVector","Normal","Arch","The normal extrusion direction of this object (keep (0,0,0) for automatic normal)")
     #obj.addProperty("App::PropertyVectorList","Nodes","Arch","The structural nodes of this element")
     #obj.addProperty("App::PropertyString","Profile","Arch","A description of the standard profile this element is based upon")
     self.Type = "TBeam"
     obj.Role = Roles
     structure = Arch.makeStructure()
     #structure.setEditorMode("Width", 1)
     #structure.setEditorMode("Height", 1)
     #structure.setEditorMode("Length", 1)
     #structure.setEditorMode("Placement", 1)
     structure.MoveWithHost = True
     ArchComponent.addToComponent( obj , structure , "Base" )
Пример #16
0
 def setEdit(self, vobj, mode=0):
     if vobj.Object.Base.Shape.Solids:
         taskd = ArchComponent.ComponentTaskPanel()
         taskd.obj = self.Object
         taskd.update()
         FreeCADGui.Control.showDialog(taskd)
     else:
         taskd = _RoofTaskPanel()
         taskd.obj = self.Object
         taskd.update()
         FreeCADGui.Control.showDialog(taskd)
     return True
Пример #17
0
def makeComponent(baseobj=None,name="Component",delete=False):
    '''makeComponent([baseobj]): creates an undefined, non-parametric Arch
    component from the given base object'''
    obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
    obj.Label = translate("Arch",name)
    ArchComponent.Component(obj)
    if FreeCAD.GuiUp:
        ArchComponent.ViewProviderComponent(obj.ViewObject)
    if baseobj:
        import Part
        if baseobj.isDerivedFrom("Part::Feature"):
            obj.Shape = baseobj.Shape
            obj.Placement = baseobj.Placement
            if delete:
                FreeCAD.ActiveDocument.removeObject(baseobj.Name)
            else:
                obj.Base = baseobj
                if FreeCAD.GuiUp:
                    baseobj.ViewObject.hide()
        elif isinstance(baseobj,Part.Shape):
            obj.Shape = baseobj
    return obj
Пример #18
0
 def setEdit(self, vobj, mode):
     if mode == 0:
         import FreeCADGui
         taskd = ArchComponent.ComponentTaskPanel()
         taskd.obj = self.Object
         taskd.update()
         if self.Object.Role == "Column":
             self.dentd = _DentsTaskPanel()
             self.dentd.form.show()
             self.dentd.fillDents(self.Object.Dents)
             taskd.form = [taskd.form, self.dentd.form]
         FreeCADGui.Control.showDialog(taskd)
         return True
     return False
Пример #19
0
 def __init__(self, obj):
     ArchComponent.Component.__init__(self, obj)
     obj.addProperty("App::PropertyLength", "Length", "1Timber",
                     "The length of this element.")
     obj.addProperty("App::PropertyLength", "Width", "1Timber",
                     "The width of this element.")
     obj.addProperty("App::PropertyLength", "Height", "1Timber",
                     "The height of this element.")
     obj.addProperty("App::PropertyEnumeration", "Preset", "1Timber",
                     "Preset parameters for this beam")
     obj.Preset = TimberComponent.getPresetsList()
     #obj.addProperty("App::PropertyLinkList","Armatures","Arch","Armatures contained in this element")
     #obj.addProperty("App::PropertyVector","Normal","Arch","The normal extrusion direction of this object (keep (0,0,0) for automatic normal)")
     #obj.addProperty("App::PropertyVectorList","Nodes","Arch","The structural nodes of this element")
     #obj.addProperty("App::PropertyString","Profile","Arch","A description of the standard profile this element is based upon")
     self.Type = "TBeam"
     obj.Role = Roles
     structure = Arch.makeStructure()
     #structure.setEditorMode("Width", 1)
     #structure.setEditorMode("Height", 1)
     #structure.setEditorMode("Length", 1)
     #structure.setEditorMode("Placement", 1)
     structure.MoveWithHost = True
     ArchComponent.addToComponent(obj, structure, "Base")
Пример #20
0
 def addElement(self):
     if self.obj:
         for o in FreeCADGui.Selection.getSelection():
             ArchComponent.addToComponent(self.obj, o, "Objects")
         self.update()
Пример #21
0
 def addElement(self):
     if self.obj:
         for o in FreeCADGui.Selection.getSelection():
             ArchComponent.addToComponent(self.obj,o,"Objects")
         self.update()