From 63c9b176e21250beb284961490d39637b53da7a2 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Fri, 21 Nov 2025 11:12:33 +0100 Subject: [PATCH] BIM: fix handling of BIM_Sketch view properties (#25339) * BIM: fix handling of BIM_Sketch view properties The handling of the sketch view properties was not correct: * AutoColor was not set to `False`. * PointSize was missing. * PointColor was not set to the DefaultShapeVertexColor preference. * Grid values were never applied. Sketches do not have a GridSnap property and gridSize is not the correct Draft preference. * Sketch grid snap is a global setting that affects all sketches, the code should not change that setting IMO. * Remove trailing white space --- src/Mod/BIM/bimcommands/BimSketch.py | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Mod/BIM/bimcommands/BimSketch.py b/src/Mod/BIM/bimcommands/BimSketch.py index 101a81d400..e3c4129815 100644 --- a/src/Mod/BIM/bimcommands/BimSketch.py +++ b/src/Mod/BIM/bimcommands/BimSketch.py @@ -48,25 +48,25 @@ class BIM_Sketch: def Activated(self): import WorkingPlane from draftutils import params + from draftutils import utils + from FreeCAD import Units - issnap = False - if hasattr(FreeCAD, "DraftWorkingPlane"): - FreeCAD.DraftWorkingPlane.setup() - if hasattr(FreeCADGui, "Snapper"): - FreeCADGui.Snapper.setGrid() - issnap = FreeCADGui.Snapper.isEnabled("Grid") + wp = WorkingPlane.get_working_plane() # also updates the grid sk = FreeCAD.ActiveDocument.addObject("Sketcher::SketchObject", "Sketch") - if issnap and hasattr(sk.ViewObject, "GridSnap"): - s = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetInt( - "gridSize", 100 - ) - sk.ViewObject.GridSize = s - sk.ViewObject.GridSnap = True + sk.Placement = wp.get_placement() 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") - sk.Placement = WorkingPlane.get_working_plane().get_placement() + sk.ViewObject.PointSize = params.get_param_view("DefaultShapePointSize") + sk.ViewObject.AutoColor = False + sk.ViewObject.LineColor = params.get_param_view("DefaultShapeLineColor") + sk.ViewObject.PointColor = params.get_param_view("DefaultShapeVertexColor") + sk.ViewObject.ShapeAppearance = [utils.get_view_material()] + + if getattr(FreeCADGui, "Snapper", None) and FreeCADGui.Snapper.grid.Visible: + sk.ViewObject.GridSize = Units.Quantity(params.get_param("gridSpacing")) + sk.ViewObject.ShowGrid = True + FreeCADGui.ActiveDocument.setEdit(sk.Name) FreeCADGui.activateWorkbench("SketcherWorkbench")