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
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user