Пример #1
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)
Пример #2
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)
Пример #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:
            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)
Пример #5
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)