BIM: BimViews upgrade

This commit is contained in:
Yorik van Havre
2024-08-09 10:37:49 +02:00
committed by Yorik van Havre
parent 438c6d730f
commit fbd7d201d5
18 changed files with 1043 additions and 150 deletions

View File

@@ -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

View File

@@ -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):

View File

@@ -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

View File

@@ -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 = [

View File

@@ -81,6 +81,7 @@
<file>icons/Arch_ToggleSubs.svg</file>
<file>icons/Arch_Truss.svg</file>
<file>icons/Arch_Truss_Tree.svg</file>
<file>icons/Arch_View_Cut.svg</file>
<file>icons/Arch_Wall.svg</file>
<file>icons/Arch_Wall_Clone.svg</file>
<file>icons/Arch_Wall_Tree.svg</file>
@@ -89,6 +90,7 @@
<file>icons/Arch_Window_Clone.svg</file>
<file>icons/Arch_Window_Tree.svg</file>
<file>icons/BIMWorkbench.svg</file>
<file>icons/BIM_ArchView.svg</file>
<file>icons/BIM_Background.svg</file>
<file>icons/BIM_Beam.svg</file>
<file>icons/BIM_Box.svg</file>
@@ -108,6 +110,7 @@
<file>icons/BIM_IfcProperties.svg</file>
<file>icons/BIM_IfcQuantities.svg</file>
<file>icons/BIM_ImagePlane.svg</file>
<file>icons/BIM_InsertView.svg</file>
<file>icons/BIM_Layers.svg</file>
<file>icons/BIM_Leader.svg</file>
<file>icons/BIM_Levels.svg</file>
@@ -115,6 +118,7 @@
<file>icons/BIM_Material.svg</file>
<file>icons/BIM_MoveView.svg</file>
<file>icons/BIM_Nudge.svg</file>
<file>icons/BIM_PageDefault.svg</file>
<file>icons/BIM_Phases.svg</file>
<file>icons/BIM_Preflight.svg</file>
<file>icons/BIM_Project.svg</file>
@@ -142,8 +146,6 @@
<file>icons/Tree_Part.svg</file>
<file>icons/banner.png</file>
<file>icons/preferences-bim.svg</file>
<file>icons/techdraw-ArchView.svg</file>
<file>icons/techdraw-PageDefault.svg</file>
<file>icons/warning.svg</file>
<file>icons/IFC/IfcBeam.svg</file>
<file>icons/IFC/IfcBuilding.svg</file>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
width="64"
height="64"
id="svg4024"
sodipodi:docname="BIM_InsertView.svg"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview
id="namedview19"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="false"
inkscape:zoom="9.269728"
inkscape:cx="36.948226"
inkscape:cy="31.176751"
inkscape:window-width="1920"
inkscape:window-height="1011"
inkscape:window-x="0"
inkscape:window-y="32"
inkscape:window-maximized="1"
inkscape:current-layer="svg4024" />
<defs
id="defs4026">
<linearGradient
xlink:href="#linearGradient3775-1"
id="linearGradient3781-9"
x1="10"
y1="39.999996"
x2="53"
y2="25.999996"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-48)" />
<linearGradient
id="linearGradient3775-1">
<stop
style="stop-color:#d3d7cf;stop-opacity:1;"
offset="0"
id="stop3777-2" />
<stop
style="stop-color:#ffffff;stop-opacity:1"
offset="1"
id="stop3779-7" />
</linearGradient>
</defs>
<metadata
id="metadata4029">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:relation>https://www.freecad.org/wiki/index.php?title=Artwork</dc:relation>
<dc:publisher>
<cc:Agent>
<dc:title>FreeCAD</dc:title>
</cc:Agent>
</dc:publisher>
<dc:rights>
<cc:Agent>
<dc:title>FreeCAD LGPL2+</dc:title>
</cc:Agent>
</dc:rights>
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<g
id="layer4"
style="display:inline"
transform="translate(0,16)">
<rect
style="fill:#d3d7cf;fill-opacity:1;stroke:#2e3436;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect2987"
width="45.999996"
height="58.000004"
x="-38.999996"
y="3"
transform="rotate(-90)" />
<rect
style="fill:url(#linearGradient3781-9);fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect2987-1"
width="41.999996"
height="54.000004"
x="-36.999996"
y="5"
transform="rotate(-90)" />
<rect
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#555753;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
id="rect3894"
width="50"
height="38"
x="7"
y="-3" />
<rect
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#555753;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
id="rect4664"
width="23.999994"
height="12.000004"
x="33"
y="23" />
<path
style="fill:none;stroke:#555753;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 37,27 h 15.398794 v 0"
id="path4666" />
<path
style="fill:none;stroke:#555753;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 37,31 h 15.642526 v 0"
id="path4666-7" />
</g>
<rect
style="fill:#89ccff;stroke:#0310ff;stroke-width:4;stroke-linejoin:round;stroke-dasharray:8, 4;stroke-dashoffset:0;stroke-opacity:1;stop-color:#000000;fill-opacity:1"
id="rect354"
width="33.723022"
height="16.97567"
x="14.798182"
y="17.402468"
rx="0.42579147" />
</svg>

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>485</height>
<width>322</width>
<height>502</height>
</rect>
</property>
<property name="windowTitle">
@@ -70,6 +70,16 @@
</property>
</column>
</widget>
<widget class="QTreeWidget" name="viewtree">
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>2D Views</string>
</property>
</column>
</widget>
</widget>
</item>
</layout>

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>522</width>
<height>851</height>
<height>892</height>
</rect>
</property>
<property name="windowTitle">
@@ -49,6 +49,12 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
@@ -302,6 +308,13 @@
<string>Other</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="0">
<widget class="QLabel" name="label_RebarOffset">
<property name="text">
<string>Rebar offset</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="Gui::PrefCheckBox" name="checkBox_WallSketches">
<property name="text">
@@ -318,6 +331,32 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_StairsLength">
<property name="text">
<string>Stair length</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="Gui::PrefUnitSpinBox" name="spinBox_StairsWidth">
<property name="unit" stdset="0">
<string>mm</string>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="rawValue" stdset="0">
<double>1000.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>StairsWidth</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_PipeDiameter">
<property name="text">
@@ -331,10 +370,10 @@
<string>mm</string>
</property>
<property name="minimum">
<number>0.0</number>
<double>0.000000000000000</double>
</property>
<property name="rawValue" stdset="0">
<double>50.0</double>
<double>50.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>PipeDiameter</cstring>
@@ -344,20 +383,6 @@
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_RebarDiameter">
<property name="text">
<string>Rebar diameter</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::PrefUnitSpinBox" name="spinBox_RebarDiameter">
<property name="minimumSize">
@@ -370,10 +395,10 @@
<string>mm</string>
</property>
<property name="minimum">
<number>0.0</number>
<double>0.000000000000000</double>
</property>
<property name="rawValue" stdset="0">
<double>6.0</double>
<double>6.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>RebarDiameter</cstring>
@@ -383,23 +408,16 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_RebarOffset">
<property name="text">
<string>Rebar offset</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::PrefUnitSpinBox" name="spinBox_RebarOffset">
<property name="unit" stdset="0">
<string>mm</string>
</property>
<property name="minimum">
<number>0.0</number>
<double>0.000000000000000</double>
</property>
<property name="rawValue" stdset="0">
<double>30.0</double>
<double>30.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>RebarOffset</cstring>
@@ -409,91 +427,6 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_StairsLength">
<property name="text">
<string>Stair length</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="Gui::PrefUnitSpinBox" name="spinBox_StairsLength">
<property name="unit" stdset="0">
<string>mm</string>
</property>
<property name="minimum">
<number>0.0</number>
</property>
<property name="rawValue" stdset="0">
<double>4500.0</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>StairsLength</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_StairsWidth">
<property name="text">
<string>Stair width</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="Gui::PrefUnitSpinBox" name="spinBox_StairsWidth">
<property name="unit" stdset="0">
<string>mm</string>
</property>
<property name="minimum">
<number>0.0</number>
</property>
<property name="rawValue" stdset="0">
<double>1000.0</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>StairsWidth</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_StairsHeight">
<property name="text">
<string>Stair height</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="Gui::PrefUnitSpinBox" name="spinBox_StairsHeight">
<property name="unit" stdset="0">
<string>mm</string>
</property>
<property name="minimum">
<number>0.0</number>
</property>
<property name="rawValue" stdset="0">
<double>3000.0</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>StairsHeight</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_StairsSteps">
<property name="text">
<string>Number of stair steps</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="Gui::PrefSpinBox" name="spinBox_StairsSteps">
<property name="value">
@@ -507,6 +440,101 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_StairsSteps">
<property name="text">
<string>Number of stair steps</string>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_RebarDiameter">
<property name="text">
<string>Rebar diameter</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_StairsHeight">
<property name="text">
<string>Stair height</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="Gui::PrefUnitSpinBox" name="spinBox_StairsHeight">
<property name="unit" stdset="0">
<string>mm</string>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="rawValue" stdset="0">
<double>3000.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>StairsHeight</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="Gui::PrefUnitSpinBox" name="spinBox_StairsLength">
<property name="unit" stdset="0">
<string>mm</string>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="rawValue" stdset="0">
<double>4500.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>StairsLength</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_StairsWidth">
<property name="text">
<string>Stair width</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="Gui::PrefCheckBox" name="checkBox">
<property name="toolTip">
<string>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</string>
</property>
<property name="text">
<string>Switch backgrounds</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>BimViewsSwitchBackground</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/BIM</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -515,6 +543,12 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
@@ -522,6 +556,26 @@
<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
<customwidget>
<class>Gui::ColorButton</class>
<extends>QPushButton</extends>
<header>Gui/Widgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefSpinBox</class>
<extends>QSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefColorButton</class>
<extends>Gui::ColorButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
@@ -532,31 +586,11 @@
<extends>QComboBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefSpinBox</class>
<extends>QSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefUnitSpinBox</class>
<extends>Gui::QuantitySpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::ColorButton</class>
<extends>QPushButton</extends>
<header>Gui/Widgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefColorButton</class>
<extends>Gui::ColorButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -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

View File

@@ -0,0 +1,83 @@
# ***************************************************************************
# * *
# * Copyright (c) 2024 Yorik van Havre <yorik@uncreated.net> *
# * *
# * 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())

View File

@@ -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")}

View File

@@ -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())

View File

@@ -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):

View File

@@ -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):

View File

@@ -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