Skip to content

Commit

Permalink
BIM: misc tool adjustments
Browse files Browse the repository at this point in the history
- Level offest can now be negative
- Auto wall grouping is now off by default
- Shape2DView (BIM version) now sets InPlace to False
- The Axis tool starts with only one axis by default
- Sketches initiated with the BIM Sketch command take Draft colors
- Snapping WP shortcuts were changed to avoid conflicts
  • Loading branch information
yorikvanhavre committed May 3, 2024
1 parent 7908dff commit 0013e27
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Mod/BIM/Arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

# make functions

def makeAxis(num=5,size=1000,name=None):
def makeAxis(num=1,size=1000,name=None):

'''makeAxis([num],[size],[name]): makes an Axis set
based on the given number of axes and interval distances'''
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/BIM/ArchBuildingPart.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def setProperties(self,obj):
obj.addProperty("App::PropertyBool","HeightPropagate","Children",QT_TRANSLATE_NOOP("App::Property","If true, the height value propagates to contained objects if the height of those objects is set to 0"))
obj.HeightPropagate = True
if not "LevelOffset" in pl:
obj.addProperty("App::PropertyLength","LevelOffset","BuildingPart",QT_TRANSLATE_NOOP("App::Property","The level of the (0,0,0) point of this level"))
obj.addProperty("App::PropertyDistance","LevelOffset","BuildingPart",QT_TRANSLATE_NOOP("App::Property","The level of the (0,0,0) point of this level"))
if not "Area" in pl:
obj.addProperty("App::PropertyArea","Area", "BuildingPart",QT_TRANSLATE_NOOP("App::Property","The computed floor area of this floor"))
if not "Description" in pl:
Expand Down
106 changes: 85 additions & 21 deletions src/Mod/BIM/Resources/ui/preferences-arch.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>446</width>
<height>811</height>
<width>519</width>
<height>954</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -26,7 +26,7 @@
<string>Auto-join walls</string>
</property>
<property name="checked">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>autoJoinWalls</cstring>
Expand Down Expand Up @@ -106,10 +106,10 @@
<item row="5" column="0" colspan="3">
<widget class="Gui::PrefCheckBox" name="checkBox_MoveWithHost">
<property name="toolTip">
<string>By default, new objects will have their "Move with host" property set to False, which means they won't move when their host object is moved.</string>
<string>By default, new objects will have their &quot;Move with host&quot; property set to False, which means they won't move when their host object is moved.</string>
</property>
<property name="text">
<string>Set "Move with host" property to True by default</string>
<string>Set &quot;Move with host&quot; property to True by default</string>
</property>
<property name="checked">
<bool>false</bool>
Expand All @@ -125,7 +125,7 @@
<item row="6" column="0" colspan="3">
<widget class="Gui::PrefCheckBox" name="checkBox_MoveBase">
<property name="text">
<string>Set "Move base" property to True by default</string>
<string>Set &quot;Move base&quot; property to True by default</string>
</property>
<property name="checked">
<bool>false</bool>
Expand Down Expand Up @@ -172,6 +172,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="8" column="0">
Expand Down Expand Up @@ -330,10 +336,10 @@
<number>4</number>
</property>
<property name="singleStep">
<double>0.0001</double>
<double>0.000100000000000</double>
</property>
<property name="value">
<double>0.001</double>
<double>0.001000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>ConversionTolerance</cstring>
Expand All @@ -348,6 +354,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>
</layout>
Expand Down Expand Up @@ -388,7 +400,7 @@
<string>Specifies how many times the viewed line thickness must be applied to cut lines</string>
</property>
<property name="value">
<double>2.0</double>
<double>2.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>CutLineThickness</cstring>
Expand All @@ -403,6 +415,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="2" column="0">
Expand All @@ -415,7 +433,7 @@
<item row="2" column="1">
<widget class="Gui::PrefDoubleSpinBox" name="spinBox_SymbolLineThickness">
<property name="value">
<double>0.6</double>
<double>0.600000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>SymbolLineThickness</cstring>
Expand Down Expand Up @@ -471,14 +489,14 @@ a Footprint display mode</string>
<property name="decimals">
<number>4</number>
</property>
<property name="singleStep">
<double>0.001</double>
</property>
<property name="maximum">
<double>9999.989999999999782</double>
</property>
<property name="singleStep">
<double>0.001000000000000</double>
</property>
<property name="value">
<double>0.01</double>
<double>0.010000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>patternScale</cstring>
Expand Down Expand Up @@ -523,7 +541,7 @@ a Footprint display mode</string>
<item row="1" column="0" colspan="2">
<widget class="Gui::PrefCheckBox" name="checkBox_BimServerBrowser">
<property name="toolTip">
<string>If this is selected, the "Open BimServer in browser"
<string>If this is selected, the &quot;Open BimServer in browser&quot;
button will open the Bim Server interface in an external browser
instead of the FreeCAD web workbench</string>
</property>
Expand Down Expand Up @@ -574,6 +592,12 @@ instead of the FreeCAD web workbench</string>
<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>
Expand All @@ -582,13 +606,13 @@ instead of the FreeCAD web workbench</string>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<class>Gui::PrefSpinBox</class>
<extends>QSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefLineEdit</class>
<extends>QLineEdit</extends>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
Expand All @@ -597,8 +621,8 @@ instead of the FreeCAD web workbench</string>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefSpinBox</class>
<extends>QSpinBox</extends>
<class>Gui::PrefLineEdit</class>
<extends>QLineEdit</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
Expand All @@ -614,24 +638,64 @@ instead of the FreeCAD web workbench</string>
<signal>toggled(bool)</signal>
<receiver>checkBox_ConversionFlat</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBox_ConversionFast</sender>
<signal>toggled(bool)</signal>
<receiver>checkBox_ConversionCut</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBox_ConversionFast</sender>
<signal>toggled(bool)</signal>
<receiver>label_ConversionTolerance</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBox_ConversionFast</sender>
<signal>toggled(bool)</signal>
<receiver>spinBox_ConversionTolerance</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>
46 changes: 46 additions & 0 deletions src/Mod/BIM/bimcommands/BimShape2DView.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from draftguitools import gui_shape2dview

QT_TRANSLATE_NOOP = FreeCAD.Qt.QT_TRANSLATE_NOOP
translate = FreeCAD.Qt.translate


class BIM_Shape2DView(gui_shape2dview.Shape2DView):
Expand All @@ -40,5 +41,50 @@ def GetResources(self):
d["MenuText"] = QT_TRANSLATE_NOOP("BIM_Shape2DView", "Shape-based view")
return d

def proceed(self):
"""Proceed with the command if one object was selected."""
# difference from Draft: it sets InPlace to False
import DraftVecUtils
if self.call is not None:
self.end_callbacks(self.call)
faces = []
objs = []
view = FreeCADGui.ActiveDocument.ActiveView
vec = view.getViewDirection().negative()
sel = FreeCADGui.Selection.getSelectionEx()
for s in sel:
objs.append(s.Object)
for e in s.SubElementNames:
if "Face" in e:
faces.append(int(e[4:]) - 1)
# print(objs, faces)
commitlist = []
FreeCADGui.addModule("Draft")
if len(objs) == 1 and faces:
_cmd = "Draft.make_shape2dview"
_cmd += "("
_cmd += "FreeCAD.ActiveDocument." + objs[0].Name + ", "
_cmd += DraftVecUtils.toString(vec) + ", "
_cmd += "facenumbers=" + str(faces)
_cmd += ")"
commitlist.append("sv = " + _cmd)
commitlist.append("sv.InPlace = False")
else:
n = 0
for o in objs:
_cmd = "Draft.make_shape2dview"
_cmd += "("
_cmd += "FreeCAD.ActiveDocument." + o.Name + ", "
_cmd += DraftVecUtils.toString(vec)
_cmd += ")"
commitlist.append("sv" + str(n) + " = " + _cmd)
commitlist.append("sv" + str(n) + ".InPlace = False")
n += 1
if commitlist:
commitlist.append("FreeCAD.ActiveDocument.recompute()")
self.commit(translate("draft", "Create 2D view"),
commitlist)
self.finish()


FreeCADGui.addCommand("BIM_Shape2DView", BIM_Shape2DView())
4 changes: 4 additions & 0 deletions src/Mod/BIM/bimcommands/BimSketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def IsActive(self):
return False

def Activated(self):
from draftutils import params
issnap = False
if hasattr(FreeCAD, "DraftWorkingPlane"):
FreeCAD.DraftWorkingPlane.setup()
Expand All @@ -64,6 +65,9 @@ def Activated(self):
sk.ViewObject.GridSize = s
sk.ViewObject.GridSnap = True
sk.MapMode = "Deactivated"
sk.ViewObject.LineColor = params.get_param_view("DefaultShapeLineColor")
sk.ViewObject.PointColor = params.get_param_view("DefaultShapeLineColor")
sk.ViewObject.LineWidth = params.get_param_view("DefaultShapeLineWidth")
p = FreeCAD.DraftWorkingPlane.getPlacement()
p.Base = FreeCAD.DraftWorkingPlane.position
sk.Placement = p
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/BIM/bimcommands/BimWPCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def GetResources(self):
"ToolTip": QT_TRANSLATE_NOOP(
"BIM_SetWPFront", "Set the working plane to Front"
),
"Accel": "Ctrl+Shift+1",
"Accel": "W,P,1",
}

def Activated(self):
Expand All @@ -55,7 +55,7 @@ def GetResources(self):
"ToolTip": QT_TRANSLATE_NOOP(
"BIM_SetWPSide", "Set the working plane to Side"
),
"Accel": "Ctrl+Shift+3",
"Accel": "W,P,3",
}

def Activated(self):
Expand All @@ -71,7 +71,7 @@ def GetResources(self):
"ToolTip": QT_TRANSLATE_NOOP(
"BIM_SetWPTop", "Set the working plane to Top"
),
"Accel": "Ctrl+Shift+2",
"Accel": "W,P,2",
}

def Activated(self):
Expand Down

0 comments on commit 0013e27

Please sign in to comment.