From bf55cdaecde47b2ea9c4c11159b6a259ba0687b0 Mon Sep 17 00:00:00 2001 From: Furgo <148809153+furgo16@users.noreply.github.com> Date: Thu, 20 Mar 2025 11:47:03 +0100 Subject: [PATCH] BIM: move add/removeSpace boundaries implementation to Arch module (#20222) * BIM: move add/removeSpaceBoundaries definitions to the Arch module * BIM: make add/removeSpaceBoundaries implementation consistent * BIM: update and expand docstrings --- src/Mod/BIM/Arch.py | 58 +++++++++++++++++++++++++++++++++++++++- src/Mod/BIM/ArchSpace.py | 35 ++++++++---------------- 2 files changed, 68 insertions(+), 25 deletions(-) diff --git a/src/Mod/BIM/Arch.py b/src/Mod/BIM/Arch.py index b5de643061..0ccc7ab635 100644 --- a/src/Mod/BIM/Arch.py +++ b/src/Mod/BIM/Arch.py @@ -50,7 +50,6 @@ from ArchWindowPresets import * # TODO: migrate this one from ArchStructure import * -from ArchSpace import * # make functions @@ -856,6 +855,63 @@ def makeSpace(objects=None,baseobj=None,name=None): space.Proxy.addSubobjects(space, boundaries) return space +def addSpaceBoundaries(space,subobjects): + """Adds the given subobjects as defining boundaries of the given space. + + Parameters + ---------- + space : ArchSpace._Space + Arch space object to add the boundaries to. + subobjects : List() or App::PropertyLinkSubList + List of boundaries to add to the space. + + Notes + ----- + The subobjects parameter can be passed using either of these different formats: + 1. List of selection objects, as provided by ``Gui.Selection.getSelectionEx()``. This + requires the GUI to be active. The `SubObjects` property of each selection object in the + list defines the boundaries to add to the space. + :: + subobjects = [, ...] + 2. A list of tuples that can be assigned to an ``App::PropertyLinkSubList`` property. Each + tuple contains a document object and a nested tuple of subobjects that define the boundaries + to add. + :: + subobjects = [(obj1, ("Face1")), (obj2, ("Face1")), ...] + subobjects = [(obj, ("Face1", "Face2", "Face3", "Face4"))] + """ + import Draft + if Draft.getType(space) == "Space": + space.Proxy.addSubobjects(space,subobjects) + +def removeSpaceBoundaries(space,subobjects): + """Remove the given subobjects as defining boundaries of the given space. + + Parameters + ---------- + space : ArchSpace._Space + Arch space object to remove the boundaries from. + subobjects : List() or App::PropertyLinkSubList + List of boundaries to remove from the space. + + Notes + ----- + The subobjects parameter can be passed using either of these different formats: + 1. List of selection objects, as provided by ``Gui.Selection.getSelectionEx()``. This + requires the GUI to be active. The `SubObjects` property of each selection object in the + list defines the boundaries to remove from the space. + :: + subobjects = [, ...] + 2. A list of tuples that can be assigned to an ``App::PropertyLinkSubList`` property. Each + tuple contains a document object and a nested tuple of subobjects that define the boundaries + to remove. + :: + subobjects = [(obj1, ("Face1")), (obj2, ("Face1")), ...] + subobjects = [(obj, ("Face1", "Face2", "Face3", "Face4"))] + """ + import Draft + if Draft.getType(space) == "Space": + space.Proxy.removeSubobjects(space,subobjects) def makeStairs(baseobj=None,length=None,width=None,height=None,steps=None,name=None): diff --git a/src/Mod/BIM/ArchSpace.py b/src/Mod/BIM/ArchSpace.py index 941267091d..7c6f74a608 100644 --- a/src/Mod/BIM/ArchSpace.py +++ b/src/Mod/BIM/ArchSpace.py @@ -180,30 +180,6 @@ else: # building, ie. a room. - -def addSpaceBoundaries(space,subobjects): - - """addSpaceBoundaries(space,subobjects): adds the given subobjects to the given space""" - - import Draft - if Draft.getType(space) == "Space": - space.Proxy.addSubobjects(space,subobjects) - -def removeSpaceBoundaries(space,objects): - - """removeSpaceBoundaries(space,objects): removes the given objects from the given spaces boundaries""" - - import Draft - if Draft.getType(space) == "Space": - bounds = space.Boundaries - for o in objects: - for b in bounds: - if o.Name == b[0].Name: - bounds.remove(b) - break - space.Boundaries = bounds - - class _Space(ArchComponent.Component): "A space object" @@ -307,6 +283,17 @@ class _Space(ArchComponent.Component): objs.append((o.Object,el)) obj.Boundaries = objs + def removeSubobjects(self,obj,subobjects): + + "removes subobjects to this space" + bounds = obj.Boundaries + for o in subobjects: + for b in bounds: + if o.Name == b[0].Name: + bounds.remove(b) + break + obj.Boundaries = bounds + def addObject(self,obj,child): "Adds an object to this Space"