From 6d8de2f1ab8e179010d92083a5cbaa6af5555bc2 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Fri, 18 May 2012 15:59:53 -0300 Subject: [PATCH] Cleaning in the Arch module --- src/Mod/Arch/ArchSectionPlane.py | 9 ++++++--- src/Mod/Arch/ArchWindow.py | 18 ++++++++++-------- src/Mod/Arch/InitGui.py | 16 +++++++++++----- src/Mod/Arch/importIFC.py | 4 ++-- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/Mod/Arch/ArchSectionPlane.py b/src/Mod/Arch/ArchSectionPlane.py index d4ae54c21..886cbb348 100644 --- a/src/Mod/Arch/ArchSectionPlane.py +++ b/src/Mod/Arch/ArchSectionPlane.py @@ -34,7 +34,7 @@ class _CommandSectionPlane: return {'Pixmap' : 'Arch_SectionPlane', 'Accel': "S, P", 'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_SectionPlane","Section Plane"), - 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_SectionPlane","Adds a section plane object to the document")} + 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_SectionPlane","Creates a section plane object, including the selected objects")} def Activated(self): sel = FreeCADGui.Selection.getSelection() @@ -47,6 +47,8 @@ class _CommandSectionPlane: for o in sel: if o.isDerivedFrom("Part::Feature"): g.append(o) + elif o.isDerivedFrom("App::DocumentObjectGroup"): + g.append(o) obj.Objects = g page = FreeCAD.ActiveDocument.addObject("Drawing::FeaturePage","Page") template = Draft.getParam("template") @@ -179,6 +181,7 @@ class _ArchDrawingView: if hasattr(obj,"Source"): if obj.Source: if obj.Source.Objects: + objs = Draft.getGroupContents(obj.Sourc.Objects) svg = '' # generating SVG @@ -188,7 +191,7 @@ class _ArchDrawingView: import ArchVRM render = ArchVRM.Renderer() render.setWorkingPlane(obj.Source.Placement) - render.addObjects(obj.Source.Objects) + render.addObjects(objs) render.cut(obj.Source.Shape) svg += render.getViewSVG(linewidth=linewidth) svg += render.getSectionSVG(linewidth=linewidth*2) @@ -197,7 +200,7 @@ class _ArchDrawingView: else: # render using the Drawing module shapes = [] - for o in obj.Source.Objects: + for o in objs: if o.isDerivedFrom("Part::Feature"): shapes.append(o.Shape) if shapes: diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index 382d9e3f9..2cdf513c9 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -78,17 +78,19 @@ class _CommandWindow: return {'Pixmap' : 'Arch_Window', 'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Window","Window"), 'Accel': "W, N", - 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Window","Creates a window object from scratch or from a selected object (wire, rectangle or sketch)")} + 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Window","Creates a window object from a selected object (wire, rectangle or sketch)")} + + def IsActive(self): + if FreeCADGui.Selection.getSelection(): + return True + else: + return False def Activated(self): sel = FreeCADGui.Selection.getSelection() - FreeCAD.ActiveDocument.openTransaction("Window") - if sel: - for obj in sel: - makeWindow(obj) - else: - rect = Draft.makeRectangle(1,1) - makeWindow(rect) + FreeCAD.ActiveDocument.openTransaction("Create Window") + for obj in sel: + makeWindow(obj) FreeCAD.ActiveDocument.commitTransaction() class _Window(ArchComponent.Component): diff --git a/src/Mod/Arch/InitGui.py b/src/Mod/Arch/InitGui.py index 52bf67165..1de87ed47 100644 --- a/src/Mod/Arch/InitGui.py +++ b/src/Mod/Arch/InitGui.py @@ -58,10 +58,10 @@ class ArchWorkbench(Workbench): def Initialize(self): import DraftTools,DraftGui,Arch_rc,Arch - self.archtools = ["Arch_Wall","Arch_Structure","Arch_Cell", + self.archtools = ["Arch_Wall","Arch_Structure", "Arch_Floor","Arch_Building","Arch_Site", - "Arch_Window","Arch_Axis", - "Arch_SectionPlane","Arch_Roof","Arch_Add","Arch_Remove"] + "Arch_Window","Arch_Roof","Arch_Axis", + "Arch_SectionPlane","Arch_Add","Arch_Remove"] self.drafttools = ["Draft_Line","Draft_Wire","Draft_Rectangle", "Draft_Polygon","Draft_Arc", "Draft_Circle","Draft_Dimension", @@ -100,6 +100,12 @@ class ArchWorkbench(Workbench): FreeCADGui.addWorkbench(ArchWorkbench) FreeCAD.addImportType("Industry Foundation Classes (*.ifc)","importIFC") FreeCAD.addExportType("Wavefront OBJ - Arch module (*.obj)","importOBJ") -FreeCAD.addImportType("Collada (*.dae)","importDAE") -FreeCAD.addExportType("Collada (*.dae)","importDAE") +# check for pycollada +try: + import collada +except: + FreeCAD.Console.PrintError("pycollada not found, no collada support.\n") +else: + FreeCAD.addImportType("Collada (*.dae)","importDAE") + FreeCAD.addExportType("Collada (*.dae)","importDAE") diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index f4a8f8392..7a0cf8ae0 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -108,7 +108,7 @@ def getIfcOpenShell(): return True def read(filename): - "Parses an IFC file with IfcOpenShell" + "Parses an IFC file" # parsing the IFC file t1 = time.time() @@ -186,7 +186,7 @@ def read(filename): IfcImport.CleanUp() else: - # use the internal python parser + # use only the internal python parser # getting walls for w in ifc.getEnt("IfcWallStandardCase"):