Skip to content

Commit

Permalink
Used Gui.addModule() instead of import in Draft & Arch
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Aug 5, 2014
1 parent 81e983b commit 46583f2
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 102 deletions.
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchAxis.py
Expand Up @@ -64,7 +64,7 @@ def GetResources(self):

def Activated(self):
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Axis"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
sel = FreeCADGui.Selection.getSelection()
st = Draft.getObjectsOfType(sel,"Structure")
if st:
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Arch/ArchBuilding.py
Expand Up @@ -62,7 +62,7 @@ def Activated(self):
if (len(sel) == 1):
if Draft.getType(sel[0]) in ["Cell","Site","Floor"]:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Type conversion"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makeBuilding()")
FreeCADGui.doCommand("Arch.copyProperties(FreeCAD.ActiveDocument."+sel[0].Name+",obj)")
FreeCADGui.doCommand('FreeCAD.ActiveDocument.removeObject("'+sel[0].Name+'")')
Expand All @@ -77,7 +77,7 @@ def Activated(self):
ss += "FreeCAD.ActiveDocument."+o.Name
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Floor"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeBuilding("+ss+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand Down
14 changes: 7 additions & 7 deletions src/Mod/Arch/ArchCommands.py
Expand Up @@ -874,7 +874,7 @@ def Activated(self):
sel = FreeCADGui.Selection.getSelection()
if Draft.getType(sel[-1]) == "Space":
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Add space boundary")))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.addSpaceBoundaries( FreeCAD.ActiveDocument."+sel[-1].Name+", FreeCADGui.Selection.getSelectionEx() )")
else:
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Grouping")))
Expand All @@ -886,7 +886,7 @@ def Activated(self):
ss += ","
ss += "FreeCAD.ActiveDocument."+o.Name
ss += "]"
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.addComponents("+ss+",FreeCAD.ActiveDocument."+host.Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand All @@ -906,7 +906,7 @@ def Activated(self):
sel = FreeCADGui.Selection.getSelection()
if Draft.getType(sel[-1]) == "Space":
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Remove space boundary")))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.removeSpaceBoundaries( FreeCAD.ActiveDocument."+sel[-1].Name+", FreeCADGui.Selection.getSelection() )")
else:
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Ungrouping")))
Expand All @@ -918,10 +918,10 @@ def Activated(self):
ss += ","
ss += "FreeCAD.ActiveDocument."+o.Name
ss += "]"
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.removeComponents("+ss+",FreeCAD.ActiveDocument."+host.Name+")")
else:
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.removeComponents(FreeCAD.ActiveDocument."+sel[-1].Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand Down Expand Up @@ -1091,8 +1091,8 @@ def IsActive(self):
return not FreeCAD.ActiveDocument is None

def Activated(self):
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("Arch.survey()")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommandGui("Arch.survey()")


class _ToggleIfcBrepFlag:
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Arch/ArchFloor.py
Expand Up @@ -62,7 +62,7 @@ def Activated(self):
if (len(sel) == 1):
if Draft.getType(sel[0]) in ["Cell","Site","Building"]:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Type conversion"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makeFloor()")
FreeCADGui.doCommand("Arch.copyProperties(FreeCAD.ActiveDocument."+sel[0].Name+",obj)")
FreeCADGui.doCommand('FreeCAD.ActiveDocument.removeObject("'+sel[0].Name+'")')
Expand All @@ -76,7 +76,7 @@ def Activated(self):
ss += "FreeCAD.ActiveDocument."+o.Name
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Floor"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeFloor("+ss+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchFrame.py
Expand Up @@ -69,7 +69,7 @@ def Activated(self):
s = FreeCADGui.Selection.getSelection()
if len(s) == 2:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Frame"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeFrame(FreeCAD.ActiveDocument."+s[0].Name+",FreeCAD.ActiveDocument."+s[1].Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Arch/ArchPanel.py
Expand Up @@ -110,7 +110,7 @@ def Activated(self):
if Draft.getType(sel[0]) == "Panel":
return
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Panel")))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
for obj in sel:
FreeCADGui.doCommand("Arch.makePanel(FreeCAD.ActiveDocument." + obj.Name + ",thickness=" + str(self.Thickness) + ")")
FreeCAD.ActiveDocument.commitTransaction()
Expand All @@ -135,7 +135,7 @@ def getPoint(self,point=None,obj=None):
if point == None:
return
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Panel")))
FreeCADGui.doCommand('import Arch')
FreeCADGui.addModule("Arch")
if self.Profile:
pr = Presets[self.Profile]
FreeCADGui.doCommand('p = Arch.makeProfile('+str(pr[2])+','+str(pr[3])+','+str(pr[4])+','+str(pr[5])+')')
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Arch/ArchRebar.py
Expand Up @@ -94,7 +94,7 @@ def Activated(self):
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.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeRebar(FreeCAD.ActiveDocument."+obj.Name+",FreeCAD.ActiveDocument."+sk.Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand All @@ -115,7 +115,7 @@ def Activated(self):
else:
sup = obj.Support
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Rebar"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeRebar(FreeCAD.ActiveDocument."+sup.Name+",FreeCAD.ActiveDocument."+obj.Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Arch/ArchRoof.py
Expand Up @@ -71,15 +71,15 @@ def Activated(self):
if "Face" in sel.SubElementNames[0]:
idx = int(sel.SubElementNames[0][4:])
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Roof"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+","+str(idx)+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
if obj.isDerivedFrom("Part::Feature"):
if obj.Shape.Wires:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Roof"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchSectionPlane.py
Expand Up @@ -88,7 +88,7 @@ def Activated(self):
ss += "FreeCAD.ActiveDocument."+o.Name
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Section Plane"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("section = Arch.makeSectionPlane("+ss+")")
#FreeCADGui.doCommand("Arch.makeSectionView(section)")
FreeCAD.ActiveDocument.commitTransaction()
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Arch/ArchSite.py
Expand Up @@ -64,7 +64,7 @@ def Activated(self):
if (len(sel) == 1):
if Draft.getType(sel[0]) in ["Cell","Building","Floor"]:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Type conversion"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makeSite()")
FreeCADGui.doCommand("Arch.copyProperties(FreeCAD.ActiveDocument."+sel[0].Name+",obj)")
FreeCADGui.doCommand('FreeCAD.ActiveDocument.removeObject("'+sel[0].Name+'")')
Expand All @@ -82,7 +82,7 @@ def Activated(self):
ss += "FreeCAD.ActiveDocument."+o.Name
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Site"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeSite("+ss+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchSpace.py
Expand Up @@ -87,7 +87,7 @@ def IsActive(self):

def Activated(self):
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Space"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
sel = FreeCADGui.Selection.getSelection()
if sel:
FreeCADGui.Control.closeDialog()
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchStairs.py
Expand Up @@ -77,7 +77,7 @@ def IsActive(self):
def Activated(self):
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Stairs"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
if len(FreeCADGui.Selection.getSelection()) == 1:
n = FreeCADGui.Selection.getSelection()[0].Name
FreeCADGui.doCommand("Arch.makeStairs(baseobj=FreeCAD.ActiveDocument."+n+")")
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Arch/ArchStructure.py
Expand Up @@ -388,14 +388,14 @@ def Activated(self):
ax = Draft.getObjectsOfType(sel,"Axis")
if st and ax:
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Structural System")))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeStructuralSystem(" + ArchCommands.getStringList(st) + "," + ArchCommands.getStringList(ax) + ")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
elif not(ax) and not(st):
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Structure")))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
for obj in sel:
FreeCADGui.doCommand("Arch.makeStructure(FreeCAD.ActiveDocument." + obj.Name + ")")
FreeCAD.ActiveDocument.commitTransaction()
Expand All @@ -420,7 +420,7 @@ def getPoint(self,point=None,obj=None):
if point == None:
return
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Structure")))
FreeCADGui.doCommand('import Arch')
FreeCADGui.addModule("Arch")
if self.Profile:
pr = Presets[self.Profile]
FreeCADGui.doCommand('p = Arch.makeProfile('+str(pr[2])+','+str(pr[3])+','+str(pr[4])+','+str(pr[5])+')')
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Arch/ArchWall.py
Expand Up @@ -176,7 +176,7 @@ def Activated(self):
import Draft
if Draft.getType(sel[0].Object) != "Wall":
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Wall"))
FreeCADGui.doCommand('import Arch')
FreeCADGui.addModule("Arch")
for selobj in sel:
if Draft.getType(selobj.Object) == "Space":
spacedone = False
Expand Down Expand Up @@ -222,7 +222,7 @@ def getPoint(self,point=None,obj=None):
l = Part.Line(self.points[0],self.points[1])
self.tracker.finalize()
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Wall"))
FreeCADGui.doCommand('import Arch')
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand('import Part')
FreeCADGui.doCommand('trace=Part.Line(FreeCAD.'+str(l.StartPoint)+',FreeCAD.'+str(l.EndPoint)+')')
if not self.existing:
Expand Down Expand Up @@ -364,7 +364,7 @@ def Activated(self):
ok = True
if ok:
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Merge Wall")))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.joinWalls(["+ostr+"],delete=True)")
FreeCAD.ActiveDocument.commitTransaction()
return
Expand All @@ -379,7 +379,7 @@ def Activated(self):
FreeCAD.Console.PrintMessage(str(translate("Arch","Please select only wall objects")))
return
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Merge Walls")))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.joinWalls(FreeCADGui.Selection.getSelection(),delete=True)")
FreeCAD.ActiveDocument.commitTransaction()

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchWindow.py
Expand Up @@ -420,7 +420,7 @@ def Activated(self):
host = obj.Objects[0].Inlist[0]

FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Window"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("win = Arch.makeWindow(FreeCAD.ActiveDocument."+obj.Name+")")
if host:
FreeCADGui.doCommand("Arch.removeComponents(win,host=FreeCAD.ActiveDocument."+host.Name+")")
Expand Down

0 comments on commit 46583f2

Please sign in to comment.