Skip to content

Commit

Permalink
Arch: Allow to make a rebar without host object from the GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Apr 29, 2019
1 parent d5432fc commit 7c26389
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/Mod/Arch/ArchRebar.py
Expand Up @@ -122,39 +122,34 @@ def Activated(self):
sk = sel[1].Object
if sk.isDerivedFrom("Part::Feature"):
if len(sk.Shape.Wires) == 1:
# we have a base object and a sketch: create the rebar now
# 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 base object: open the sketcher
# 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 obj.isDerivedFrom("Part::Feature"):
if len(obj.Shape.Wires) == 1:
# we have only the sketch: extract the base object from it
# 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:
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
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()
Expand Down

0 comments on commit 7c26389

Please sign in to comment.