mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 17:57:02 +00:00
Fix issues with updating groups
This commit is contained in:
@@ -46,9 +46,14 @@ class LoadGroups(bpy.types.Operator):
|
|||||||
new.ifc_definition_id = ifc_definition_id
|
new.ifc_definition_id = ifc_definition_id
|
||||||
new.name = group["Name"]
|
new.name = group["Name"]
|
||||||
new.selection_query = group["Description"].split("*selector*")[1] if group["Description"] else ""
|
new.selection_query = group["Description"].split("*selector*")[1] if group["Description"] else ""
|
||||||
new.has_children = True if len(group["IsGroupedBy"]) != 0 else False
|
|
||||||
new.tree_depth = 0
|
new.tree_depth = 0
|
||||||
|
|
||||||
|
if group["IsGroupedBy"]:
|
||||||
|
# assumes 1:1 cardinality, will need to be updated to reflect IFC4 changes
|
||||||
|
# where the cardinality is 0:? - vulevukusej
|
||||||
|
sub_groups = [g for g in group["IsGroupedBy"][0].RelatedObjects if g.is_a("IfcGroup")]
|
||||||
|
new.has_children = True if len(sub_groups) != 0 else False
|
||||||
|
|
||||||
if self.is_refresh:
|
if self.is_refresh:
|
||||||
self.recursively_load_sub_groups(ifc_definition_id, new)
|
self.recursively_load_sub_groups(ifc_definition_id, new)
|
||||||
|
|
||||||
@@ -65,6 +70,7 @@ class LoadGroups(bpy.types.Operator):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
parent.is_expanded = True
|
parent.is_expanded = True
|
||||||
|
parent.has_children = True
|
||||||
for group in sub_groups:
|
for group in sub_groups:
|
||||||
new = self.props.groups.add()
|
new = self.props.groups.add()
|
||||||
new.ifc_definition_id = group
|
new.ifc_definition_id = group
|
||||||
@@ -144,6 +150,7 @@ class AddGroupToGroup(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
bpy.ops.bim.load_groups(is_refresh=True)
|
bpy.ops.bim.load_groups(is_refresh=True)
|
||||||
|
bpy.ops.bim.disable_group_editing_ui()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -323,8 +330,9 @@ class UpdateGroup(bpy.types.Operator):
|
|||||||
"group.update_group_products",
|
"group.update_group_products",
|
||||||
self.file,
|
self.file,
|
||||||
**{
|
**{
|
||||||
"products": new_products,
|
|
||||||
"group": group,
|
"group": group,
|
||||||
|
"products": new_products,
|
||||||
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class Group(PropertyGroup):
|
|||||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||||
selection_query: StringProperty(name="Selection Query")
|
selection_query: StringProperty(name="Selection Query")
|
||||||
is_expanded: BoolProperty(name="Is Expanded", default=False)
|
is_expanded: BoolProperty(name="Is Expanded", default=False)
|
||||||
has_children: BoolProperty(name="Has Children")
|
has_children: BoolProperty(name="Has Children", default=False)
|
||||||
tree_depth: IntProperty(name="Tree Depth")
|
tree_depth: IntProperty(name="Tree Depth")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import ifcopenshell
|
||||||
|
import ifcopenshell.api
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
@@ -23,11 +26,27 @@ class Usecase:
|
|||||||
self.settings = {
|
self.settings = {
|
||||||
"group": None,
|
"group": None,
|
||||||
"products": None,
|
"products": None,
|
||||||
}
|
}
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
self.settings[key] = value
|
self.settings[key] = value
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
rel = self.settings["group"].IsGroupedBy[0]
|
if not self.settings["group"].IsGroupedBy:
|
||||||
rel.RelatedObjects = self.settings["products"]
|
return self.file.create_entity(
|
||||||
|
"IfcRelAssignsToGroup",
|
||||||
|
**{
|
||||||
|
"GlobalId": ifcopenshell.guid.new(),
|
||||||
|
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||||
|
"RelatedObjects": self.settings["products"],
|
||||||
|
"RelatingGroup": self.settings["group"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# assumes 1:1 cardinality, will need to be updated to reflect IFC4 changes
|
||||||
|
# where the cardinality is 0:? - vulevukusej
|
||||||
|
rel = self.settings["group"].IsGroupedBy[0]
|
||||||
|
existing_sub_groups = [g for g in rel.RelatedObjects if g.is_a("IfcGroup")]
|
||||||
|
|
||||||
|
rel.RelatedObjects = self.settings["products"]
|
||||||
|
for g in existing_sub_groups:
|
||||||
|
rel.RelatedObjects.add(g)
|
||||||
|
|||||||
Reference in New Issue
Block a user