diff --git a/src/Mod/BIM/Arch.py b/src/Mod/BIM/Arch.py
index 818b860d2e..e9537176d8 100644
--- a/src/Mod/BIM/Arch.py
+++ b/src/Mod/BIM/Arch.py
@@ -114,7 +114,10 @@ def makeBuildingPart(objectslist=None,baseobj=None,name=None):
if FreeCAD.GuiUp:
ArchBuildingPart.ViewProviderBuildingPart(obj.ViewObject)
if objectslist:
- obj.addObjects(objectslist)
+ if isinstance(objectslist,(list,tuple)):
+ obj.addObjects(objectslist)
+ else:
+ obj.addObject(objectslist)
return obj
@@ -147,6 +150,25 @@ def makeBuilding(objectslist=None,baseobj=None,name=None):
return obj
+def make2DDrawing(objectslist=None,baseobj=None,name=None):
+
+ """makes a BuildingPart and turns it into a 2D drawing view"""
+
+ obj = makeBuildingPart(objectslist)
+ obj.Label = name if name else translate("Arch","Drawing")
+ obj.IfcType = "Annotation"
+ obj.ObjectType = "DRAWING"
+ obj.setEditorMode("Area",2)
+ obj.setEditorMode("Height",2)
+ obj.setEditorMode("LevelOffset",2)
+ obj.setEditorMode("OnlySolids",2)
+ obj.setEditorMode("HeightPropagate",2)
+ if FreeCAD.GuiUp:
+ obj.ViewObject.DisplayOffset = FreeCAD.Placement()
+ obj.ViewObject.ShowLevel = False
+ return obj
+
+
def convertFloors(floor=None):
"""convert the given Floor or Building (or all Arch Floors from the
diff --git a/src/Mod/BIM/ArchBuildingPart.py b/src/Mod/BIM/ArchBuildingPart.py
index 6c80064aed..421f7355c6 100644
--- a/src/Mod/BIM/ArchBuildingPart.py
+++ b/src/Mod/BIM/ArchBuildingPart.py
@@ -531,6 +531,8 @@ class ViewProviderBuildingPart:
return ":/icons/Arch_Floor_Tree.svg"
elif self.Object.IfcType == "Building":
return ":/icons/Arch_Building_Tree.svg"
+ elif self.Object.IfcType == "Annotation":
+ return ":/icons/BIM_ArchView.svg"
return ":/icons/Arch_BuildingPart_Tree.svg"
def attach(self,vobj):
diff --git a/src/Mod/BIM/CMakeLists.txt b/src/Mod/BIM/CMakeLists.txt
index 8b71a2cf24..df1dcb5c75 100644
--- a/src/Mod/BIM/CMakeLists.txt
+++ b/src/Mod/BIM/CMakeLists.txt
@@ -106,6 +106,7 @@ SET(bimcommands_SRCS
bimcommands/BimDiff.py
bimcommands/BimDimensions.py
bimcommands/BimDoor.py
+ bimcommands/BimDrawingView.py
bimcommands/BimEmptyTrash.py
bimcommands/BimEquipment.py
bimcommands/BimExamples.py
diff --git a/src/Mod/BIM/InitGui.py b/src/Mod/BIM/InitGui.py
index ce80711699..fb104f377b 100644
--- a/src/Mod/BIM/InitGui.py
+++ b/src/Mod/BIM/InitGui.py
@@ -95,14 +95,16 @@ class BIMWorkbench(Workbench):
"BIM_DimensionVertical",
"BIM_Leader",
"Draft_Label",
+ "Draft_Hatch",
"Arch_Axis",
"Arch_AxisSystem",
"Arch_Grid",
"Arch_SectionPlane",
- "Draft_Hatch",
+ "BIM_DrawingView",
+ "BIM_Shape2DView",
+ "BIM_Shape2DCut",
"BIM_TDPage",
"BIM_TDView",
- "BIM_Shape2DView",
]
self.bimtools = [
diff --git a/src/Mod/BIM/Resources/Arch.qrc b/src/Mod/BIM/Resources/Arch.qrc
index 360eb6d3ca..04568cfbba 100644
--- a/src/Mod/BIM/Resources/Arch.qrc
+++ b/src/Mod/BIM/Resources/Arch.qrc
@@ -81,6 +81,7 @@
icons/Arch_ToggleSubs.svg
icons/Arch_Truss.svg
icons/Arch_Truss_Tree.svg
+ icons/Arch_View_Cut.svg
icons/Arch_Wall.svg
icons/Arch_Wall_Clone.svg
icons/Arch_Wall_Tree.svg
@@ -89,6 +90,7 @@
icons/Arch_Window_Clone.svg
icons/Arch_Window_Tree.svg
icons/BIMWorkbench.svg
+ icons/BIM_ArchView.svg
icons/BIM_Background.svg
icons/BIM_Beam.svg
icons/BIM_Box.svg
@@ -108,6 +110,7 @@
icons/BIM_IfcProperties.svg
icons/BIM_IfcQuantities.svg
icons/BIM_ImagePlane.svg
+ icons/BIM_InsertView.svg
icons/BIM_Layers.svg
icons/BIM_Leader.svg
icons/BIM_Levels.svg
@@ -115,6 +118,7 @@
icons/BIM_Material.svg
icons/BIM_MoveView.svg
icons/BIM_Nudge.svg
+ icons/BIM_PageDefault.svg
icons/BIM_Phases.svg
icons/BIM_Preflight.svg
icons/BIM_Project.svg
@@ -142,8 +146,6 @@
icons/Tree_Part.svg
icons/banner.png
icons/preferences-bim.svg
- icons/techdraw-ArchView.svg
- icons/techdraw-PageDefault.svg
icons/warning.svg
icons/IFC/IfcBeam.svg
icons/IFC/IfcBuilding.svg
diff --git a/src/Mod/BIM/Resources/icons/Arch_View_Cut.svg b/src/Mod/BIM/Resources/icons/Arch_View_Cut.svg
new file mode 100644
index 0000000000..fe4747ae94
--- /dev/null
+++ b/src/Mod/BIM/Resources/icons/Arch_View_Cut.svg
@@ -0,0 +1,476 @@
+
+
+
+
diff --git a/src/Mod/BIM/Resources/icons/techdraw-ArchView.svg b/src/Mod/BIM/Resources/icons/BIM_ArchView.svg
similarity index 100%
rename from src/Mod/BIM/Resources/icons/techdraw-ArchView.svg
rename to src/Mod/BIM/Resources/icons/BIM_ArchView.svg
diff --git a/src/Mod/BIM/Resources/icons/BIM_InsertView.svg b/src/Mod/BIM/Resources/icons/BIM_InsertView.svg
new file mode 100644
index 0000000000..c923ec21be
--- /dev/null
+++ b/src/Mod/BIM/Resources/icons/BIM_InsertView.svg
@@ -0,0 +1,151 @@
+
+
+
+
diff --git a/src/Mod/BIM/Resources/icons/techdraw-PageDefault.svg b/src/Mod/BIM/Resources/icons/BIM_PageDefault.svg
similarity index 100%
rename from src/Mod/BIM/Resources/icons/techdraw-PageDefault.svg
rename to src/Mod/BIM/Resources/icons/BIM_PageDefault.svg
diff --git a/src/Mod/BIM/Resources/ui/dialogViews.ui b/src/Mod/BIM/Resources/ui/dialogViews.ui
index 1fc92a372c..fca2e6a220 100644
--- a/src/Mod/BIM/Resources/ui/dialogViews.ui
+++ b/src/Mod/BIM/Resources/ui/dialogViews.ui
@@ -6,8 +6,8 @@
0
0
- 340
- 485
+ 322
+ 502
@@ -70,6 +70,16 @@
+
+
+ false
+
+
+
+ 2D Views
+
+
+
diff --git a/src/Mod/BIM/Resources/ui/preferences-archdefaults.ui b/src/Mod/BIM/Resources/ui/preferences-archdefaults.ui
index 9f887b0185..0e6ff50655 100644
--- a/src/Mod/BIM/Resources/ui/preferences-archdefaults.ui
+++ b/src/Mod/BIM/Resources/ui/preferences-archdefaults.ui
@@ -7,7 +7,7 @@
0
0
522
- 851
+ 892
@@ -49,6 +49,12 @@
Qt::Horizontal
+
+
+ 0
+ 0
+
+
-
@@ -302,6 +308,13 @@
Other
+ -
+
+
+ Rebar offset
+
+
+
-
@@ -318,6 +331,32 @@
+ -
+
+
+ Stair length
+
+
+
+ -
+
+
+ mm
+
+
+ 0.000000000000000
+
+
+ 1000.000000000000000
+
+
+ StairsWidth
+
+
+ Mod/Arch
+
+
+
-
@@ -331,10 +370,10 @@
mm
- 0.0
+ 0.000000000000000
- 50.0
+ 50.000000000000000
PipeDiameter
@@ -344,20 +383,6 @@
- -
-
-
- Qt::Horizontal
-
-
-
- -
-
-
- Rebar diameter
-
-
-
-
@@ -370,10 +395,10 @@
mm
- 0.0
+ 0.000000000000000
- 6.0
+ 6.000000000000000
RebarDiameter
@@ -383,23 +408,16 @@
- -
-
-
- Rebar offset
-
-
-
-
mm
- 0.0
+ 0.000000000000000
- 30.0
+ 30.000000000000000
RebarOffset
@@ -409,91 +427,6 @@
- -
-
-
- Stair length
-
-
-
- -
-
-
- mm
-
-
- 0.0
-
-
- 4500.0
-
-
- StairsLength
-
-
- Mod/Arch
-
-
-
- -
-
-
- Stair width
-
-
-
- -
-
-
- mm
-
-
- 0.0
-
-
- 1000.0
-
-
- StairsWidth
-
-
- Mod/Arch
-
-
-
- -
-
-
- Stair height
-
-
-
- -
-
-
- mm
-
-
- 0.0
-
-
- 3000.0
-
-
- StairsHeight
-
-
- Mod/Arch
-
-
-
- -
-
-
- Number of stair steps
-
-
-
-
@@ -507,6 +440,101 @@
+ -
+
+
+ Number of stair steps
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 0
+ 0
+
+
+
+
+ -
+
+
+ Rebar diameter
+
+
+
+ -
+
+
+ Stair height
+
+
+
+ -
+
+
+ mm
+
+
+ 0.000000000000000
+
+
+ 3000.000000000000000
+
+
+ StairsHeight
+
+
+ Mod/Arch
+
+
+
+ -
+
+
+ mm
+
+
+ 0.000000000000000
+
+
+ 4500.000000000000000
+
+
+ StairsLength
+
+
+ Mod/Arch
+
+
+
+ -
+
+
+ Stair width
+
+
+
+ -
+
+
+ When clicking a view or level in the BIM views manager, this switches the background to plain color when activating a 2D view, and to gradient color when activating a level
+
+
+ Switch backgrounds
+
+
+ BimViewsSwitchBackground
+
+
+ Mod/BIM
+
+
+
@@ -515,6 +543,12 @@
Qt::Vertical
+
+
+ 0
+ 0
+
+
@@ -522,6 +556,26 @@
qPixmapFromMimeSource
+
+ Gui::QuantitySpinBox
+ QWidget
+
+
+
+ Gui::ColorButton
+ QPushButton
+
+
+
+ Gui::PrefSpinBox
+ QSpinBox
+
+
+
+ Gui::PrefColorButton
+ Gui::ColorButton
+
+
Gui::PrefCheckBox
QCheckBox
@@ -532,31 +586,11 @@
QComboBox
-
- Gui::PrefSpinBox
- QSpinBox
-
-
-
- Gui::QuantitySpinBox
- QWidget
-
-
Gui::PrefUnitSpinBox
Gui::QuantitySpinBox
-
- Gui::ColorButton
- QPushButton
-
-
-
- Gui::PrefColorButton
- Gui::ColorButton
-
-
diff --git a/src/Mod/BIM/TestArch.py b/src/Mod/BIM/TestArch.py
index 48ebc43a4e..27bbb9bff2 100644
--- a/src/Mod/BIM/TestArch.py
+++ b/src/Mod/BIM/TestArch.py
@@ -32,6 +32,7 @@ import Arch
import Draft
import Part
import Sketcher
+import TechDraw
from draftutils.messages import _msg
@@ -758,6 +759,53 @@ class ArchTest(unittest.TestCase):
App.ActiveDocument.recompute()
assert wall.Visibility
+ def testViewGeneration(self):
+ """Tests the whole TD view generation workflow"""
+
+ operation = "View generation"
+ _msg(" Test '{}'".format(operation))
+
+ # Create a few objects
+ points = [App.Vector(0.0, 0.0, 0.0), App.Vector(2000.0, 0.0, 0.0)]
+ line = Draft.make_wire(points)
+ wall = Arch.makeWall(line, height=2000)
+ wpl = App.Placement(App.Vector(500,0,1500), App.Vector(1,0,0),-90)
+ win = Arch.makeWindowPreset('Fixed', width=1000.0, height=1000.0, h1=50.0, h2=50.0, h3=50.0, w1=100.0, w2=50.0, o1=0.0, o2=50.0, placement=wpl)
+ win.Hosts = [wall]
+ profile = Arch.makeProfile([169, 'HEA', 'HEA100', 'H', 100.0, 96.0, 5.0, 8.0])
+ column = Arch.makeStructure(profile, height=2000.0)
+ column.Profile = "HEA100"
+ column.Placement.Base = App.Vector(500.0, 600.0, 0.0)
+ level = Arch.makeFloor()
+ level.addObjects([wall, column])
+ App.ActiveDocument.recompute()
+
+ # Create a drawing view
+ section = Arch.makeSectionPlane(level)
+ drawing = Arch.make2DDrawing()
+ view = Draft.make_shape2dview(section)
+ cut = Draft.make_shape2dview(section)
+ cut.InPlace = False
+ cut.ProjectionMode = "Cutfaces"
+ drawing.addObjects([view, cut])
+ App.ActiveDocument.recompute()
+
+ # Create a TD page
+ tpath = os.path.join(App.getResourceDir(),"Mod","TechDraw","Templates","A3_Landscape_blank.svg")
+ page = App.ActiveDocument.addObject("TechDraw::DrawPage", "Page")
+ template = App.ActiveDocument.addObject("TechDraw::DrawSVGTemplate", "Template")
+ template.Template = tpath
+ page.Template = template
+ view = App.ActiveDocument.addObject("TechDraw::DrawViewDraft", "DraftView")
+ view.Source = drawing
+ page.addView(view)
+ view.Scale = 1.0
+ view.X = "20cm"
+ view.Y = "15cm"
+ App.ActiveDocument.recompute()
+ assert True
+
+
def tearDown(self):
App.closeDocument("ArchTest")
pass
diff --git a/src/Mod/BIM/bimcommands/BimDrawingView.py b/src/Mod/BIM/bimcommands/BimDrawingView.py
new file mode 100644
index 0000000000..637a68fd01
--- /dev/null
+++ b/src/Mod/BIM/bimcommands/BimDrawingView.py
@@ -0,0 +1,83 @@
+# ***************************************************************************
+# * *
+# * Copyright (c) 2024 Yorik van Havre *
+# * *
+# * This program is free software; you can redistribute it and/or modify *
+# * it under the terms of the GNU Lesser General Public License (LGPL) *
+# * as published by the Free Software Foundation; either version 2 of *
+# * the License, or (at your option) any later version. *
+# * for detail see the LICENCE text file. *
+# * *
+# * This program is distributed in the hope that it will be useful, *
+# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# * GNU Library General Public License for more details. *
+# * *
+# * You should have received a copy of the GNU Library General Public *
+# * License along with this program; if not, write to the Free Software *
+# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
+# * USA *
+# * *
+# ***************************************************************************
+
+"""The BIM DrawingView command"""
+
+
+import os
+import FreeCAD
+import FreeCADGui
+from bimcommands import BimBuildingPart
+
+QT_TRANSLATE_NOOP = FreeCAD.Qt.QT_TRANSLATE_NOOP
+translate = FreeCAD.Qt.translate
+PARAMS = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM")
+
+
+class BIM_DrawingView:
+
+ """The command definition for the Drawing View command"""
+
+ def GetResources(self):
+
+ return {'Pixmap' : 'BIM_ArchView',
+ 'MenuText': QT_TRANSLATE_NOOP("BIM_DrawingView","2D Drawing"),
+ 'Accel': "V, D",
+ 'ToolTip': QT_TRANSLATE_NOOP("BIM_DrawingView","Creates a drawing container to contain elements of a 2D view")}
+
+ def IsActive(self):
+
+ v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
+ return v
+
+ def Activated(self):
+
+ import Draft
+ FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create 2D View"))
+ FreeCADGui.addModule("Arch")
+ FreeCADGui.addModule("Draft")
+ FreeCADGui.addModule("WorkingPlane")
+ FreeCADGui.doCommand("obj = Arch.make2DDrawing()")
+ FreeCADGui.doCommand("Draft.autogroup(obj)")
+ s = FreeCADGui.Selection.getSelection()
+ if len(s) == 1:
+ s = s[0]
+ if Draft.getType(s) == "SectionPlane":
+ FreeCADGui.doCommand("vobj = Draft.make_shape2dview(FreeCAD.ActiveDocument."+s.Name+")")
+ FreeCADGui.doCommand("vobj.Label = \""+translate("BIM","Viewed lines")+"\"")
+ FreeCADGui.doCommand("vobj.InPlace = False")
+ FreeCADGui.doCommand("obj.addObject(vobj)")
+ bb = FreeCAD.BoundBox()
+ for so in s.Objects:
+ if hasattr(so, "Shape"):
+ bb.add(so.Shape.BoundBox)
+ if bb.isInside(s.Shape.CenterOfMass):
+ FreeCADGui.doCommand("cobj = Draft.make_shape2dview(FreeCAD.ActiveDocument."+s.Name+")")
+ FreeCADGui.doCommand("cobj.Label = \""+translate("BIM","Cut lines")+"\"")
+ FreeCADGui.doCommand("cobj.InPlace = False")
+ FreeCADGui.doCommand("cobj.ProjectionMode = \"Cutfaces\"")
+ FreeCADGui.doCommand("obj.addObject(cobj)")
+ FreeCAD.ActiveDocument.commitTransaction()
+ FreeCAD.ActiveDocument.recompute()
+
+
+FreeCADGui.addCommand('BIM_DrawingView', BIM_DrawingView())
diff --git a/src/Mod/BIM/bimcommands/BimSectionPlane.py b/src/Mod/BIM/bimcommands/BimSectionPlane.py
index f558da15a5..549b1021a1 100644
--- a/src/Mod/BIM/bimcommands/BimSectionPlane.py
+++ b/src/Mod/BIM/bimcommands/BimSectionPlane.py
@@ -38,7 +38,7 @@ class Arch_SectionPlane:
def GetResources(self):
- return {'Pixmap' : 'Arch_SectionPlane',
+ return {'Pixmap' : 'Arch_SectionPlane_Tree',
'Accel': "S, E",
'MenuText': QT_TRANSLATE_NOOP("Arch_SectionPlane","Section Plane"),
'ToolTip': QT_TRANSLATE_NOOP("Arch_SectionPlane","Creates a section plane object, including the selected objects")}
diff --git a/src/Mod/BIM/bimcommands/BimShape2DView.py b/src/Mod/BIM/bimcommands/BimShape2DView.py
index 8aed84ee8d..fecbee7e8c 100644
--- a/src/Mod/BIM/bimcommands/BimShape2DView.py
+++ b/src/Mod/BIM/bimcommands/BimShape2DView.py
@@ -38,7 +38,8 @@ class BIM_Shape2DView(gui_shape2dview.Shape2DView):
def GetResources(self):
d = super().GetResources()
d["Pixmap"] = "Arch_BuildingPart_Tree"
- d["MenuText"] = QT_TRANSLATE_NOOP("BIM_Shape2DView", "Shape-based view")
+ d["MenuText"] = QT_TRANSLATE_NOOP("BIM_Shape2DView", "Section view")
+ d['Accel'] = "V, V"
return d
def proceed(self):
@@ -87,4 +88,19 @@ class BIM_Shape2DView(gui_shape2dview.Shape2DView):
self.finish()
+class BIM_Shape2DCut(BIM_Shape2DView):
+
+ def GetResources(self):
+ d = super().GetResources()
+ d["Pixmap"] = "Arch_View_Cut"
+ d["MenuText"] = QT_TRANSLATE_NOOP("BIM_Shape2DView", "Section cut")
+ d['Accel'] = "V, C"
+ return d
+
+ def proceed(self):
+ super().proceed()
+ FreeCADGui.doCommand("sv.ProjectionMode = \"Cutfaces\"")
+
+
FreeCADGui.addCommand("BIM_Shape2DView", BIM_Shape2DView())
+FreeCADGui.addCommand("BIM_Shape2DCut", BIM_Shape2DCut())
diff --git a/src/Mod/BIM/bimcommands/BimTDPage.py b/src/Mod/BIM/bimcommands/BimTDPage.py
index 0c5100ec0e..a4ec885fd9 100644
--- a/src/Mod/BIM/bimcommands/BimTDPage.py
+++ b/src/Mod/BIM/bimcommands/BimTDPage.py
@@ -36,11 +36,12 @@ translate = FreeCAD.Qt.translate
class BIM_TDPage:
def GetResources(self):
return {
- "Pixmap": "techdraw-PageDefault",
+ "Pixmap": "BIM_PageDefault",
"MenuText": QT_TRANSLATE_NOOP("BIM_TDPage", "Page"),
"ToolTip": QT_TRANSLATE_NOOP(
"BIM_TDPage", "Creates a new TechDraw page from a template"
),
+ 'Accel': "V, P",
}
def IsActive(self):
diff --git a/src/Mod/BIM/bimcommands/BimTDView.py b/src/Mod/BIM/bimcommands/BimTDView.py
index 554d1cdd6b..254bec5b98 100644
--- a/src/Mod/BIM/bimcommands/BimTDView.py
+++ b/src/Mod/BIM/bimcommands/BimTDView.py
@@ -35,12 +35,13 @@ translate = FreeCAD.Qt.translate
class BIM_TDView:
def GetResources(self):
return {
- "Pixmap": "techdraw-ArchView",
- "MenuText": QT_TRANSLATE_NOOP("BIM_TDView", "View"),
+ "Pixmap": "BIM_InsertView",
+ "MenuText": QT_TRANSLATE_NOOP("BIM_TDView", "Insert view"),
"ToolTip": QT_TRANSLATE_NOOP(
"BIM_TDView",
- "Creates a TechDraw view from a section plane or 2D objects",
+ "Inserts a drawing view on a page",
),
+ 'Accel': "V, I",
}
def IsActive(self):
diff --git a/src/Mod/BIM/bimcommands/BimViews.py b/src/Mod/BIM/bimcommands/BimViews.py
index 99ed00a9ab..0ff4a2f17c 100644
--- a/src/Mod/BIM/bimcommands/BimViews.py
+++ b/src/Mod/BIM/bimcommands/BimViews.py
@@ -73,6 +73,7 @@ class BIM_Views:
self.dialog = FreeCADGui.PySideUic.loadUi(":/ui/dialogViews.ui")
vm.setWidget(self.dialog)
vm.tree = self.dialog.tree
+ vm.viewtree = self.dialog.viewtree
vm.closeEvent = self.onClose
# set context menu
@@ -121,6 +122,7 @@ class BIM_Views:
self.dialog.buttonRename.triggered.connect(self.rename)
self.dialog.tree.itemClicked.connect(self.select)
self.dialog.tree.itemDoubleClicked.connect(show)
+ self.dialog.viewtree.itemDoubleClicked.connect(show)
self.dialog.tree.itemChanged.connect(self.editObject)
self.dialog.tree.customContextMenuRequested.connect(self.onContextMenu)
# delay connecting after FreeCAD finishes setting up
@@ -177,13 +179,12 @@ class BIM_Views:
"updates the view manager"
from PySide import QtCore, QtGui
+ import Draft
vm = findWidget()
if vm and FreeCAD.ActiveDocument:
if vm.isVisible() and (vm.tree.state() != vm.tree.State.EditingState):
vm.tree.clear()
- import Draft
-
treeViewItems = [] # QTreeWidgetItem to Display in tree
lvHold = []
soloProxyHold = []
@@ -260,6 +261,9 @@ class BIM_Views:
treeViewItems = treeViewItems + sortLvItems + soloProxyHold
vm.tree.addTopLevelItems(treeViewItems)
+ if vm.isVisible() and (vm.viewtree.state() != vm.viewtree.State.EditingState):
+ vm.viewtree.clear()
+
# add views
ficon = QtGui.QIcon.fromTheme("folder", QtGui.QIcon(":/icons/folder.svg"))
views = self.getViews()
@@ -273,7 +277,7 @@ class BIM_Views:
i.setIcon(0, v.ViewObject.Icon)
i.setToolTip(0, v.Name)
top.addChild(i)
- vm.tree.addTopLevelItem(top)
+ vm.viewtree.addTopLevelItem(top)
# add pages
pages = self.getPages()
@@ -286,7 +290,7 @@ class BIM_Views:
i.setIcon(0, p.ViewObject.Icon)
i.setToolTip(0, p.Name)
top.addChild(i)
- vm.tree.addTopLevelItem(top)
+ vm.viewtree.addTopLevelItem(top)
# set TreeVinew Item selected if obj is selected
objSelected = FreeCADGui.Selection.getSelection()
@@ -306,6 +310,7 @@ class BIM_Views:
# expand
vm.tree.expandAll()
+ vm.viewtree.expandAll()
def select(self, item, column=None):
"selects a doc object corresponding to an item"
@@ -445,11 +450,16 @@ class BIM_Views:
def getViews(self):
"""Returns a list of 2D views"""
+ import Draft
views = []
for p in self.getPages():
for v in p.Views:
if getattr(v, "Source", None):
views.append(v.Source)
+ bps = [o for o in FreeCAD.ActiveDocument.Objects if Draft.getType(o) == "BuildingPart"]
+ for v in [o for o in bps if isView(o)]:
+ if v not in views:
+ views.append(v)
return views
def getPages(self):
@@ -475,6 +485,8 @@ def findWidget():
def show(item, column=None):
"item has been double-clicked"
+ import Draft
+
obj = None
vm = findWidget()
if isinstance(item, str) or (
@@ -495,6 +507,7 @@ def show(item, column=None):
if obj:
FreeCADGui.Selection.clearSelection()
FreeCADGui.Selection.addSelection(obj)
+ vparam = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View")
if obj.isDerivedFrom("TechDraw::DrawPage"):
# case 1: the object is a TD page. We switch to it simply
@@ -519,10 +532,35 @@ def show(item, column=None):
FreeCADGui.ActiveDocument.ActiveView.viewTop()
FreeCADGui.Selection.clearSelection()
FreeCADGui.Selection.addSelection(obj)
+ if PARAMS.GetBool("BimViewsSwitchBackground", False):
+ vparam.SetBool("Simple", True)
+ vparam.SetBool("Gradient", False)
+ vparam.SetBool("RadialGradient", False)
else:
# case 3: This is maybe a BuildingPart. Place the WP on it
FreeCADGui.runCommand("Draft_SelectPlane")
+ if PARAMS.GetBool("BimViewsSwitchBackground", False):
+ vparam.SetBool("Simple", False)
+ vparam.SetBool("Gradient", False)
+ vparam.SetBool("RadialGradient", True)
+ if Draft.getType(obj) == "BuildingPart":
+ if obj.IfcType == "Building Storey":
+ # hide all other storeys
+ obj.ViewObject.Visibility = True
+ bldgs = [o for o in obj.InList if Draft.getType(o) == "BuildingPart" and o.IfcType == "Building"]
+ if len(bldgs) == 1:
+ bldg = bldgs[0]
+ storeys = [o for o in bldg.OutList if Draft.getType(o) == "BuildingPart" and o.IfcType == "Building Storey"]
+ for storey in storeys:
+ if storey != obj:
+ storey.ViewObject.Visibility = False
+ elif obj.IfcType == "Building":
+ # show all storeys
+ storeys = [o for o in obj.OutList if Draft.getType(o) == "BuildingPart" and o.IfcType == "Building Storey"]
+ for storey in storeys:
+ storey.ViewObject.Visibility = True
+
if vm:
# store the last double-clicked item for the BIM WPView command
if isinstance(item, str) or (
@@ -543,6 +581,12 @@ def isView(obj):
return True
if getattr(obj,"DrawingView",False):
return True
+ if getattr(obj, "IfcType", None) == "Annotation":
+ if getattr(obj, "ObjectType", "").upper() == "DRAWING":
+ return True
+ if getattr(obj, "Class", None) == "IfcAnnotation":
+ if getattr(obj, "ObjectType", "").upper() == "DRAWING":
+ return True
return False