mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
Improve mesh IFC Representation User Experience (#1710)
* Must be in object mode to update representation This may prevent random CTDs due to invalidated data * Use self.file instead of re-fetching from IfcStore * Keep ifc parameters expanded when updating representation * Clear previous ifc parameters when re-fetching
This commit is contained in:
@@ -159,7 +159,7 @@ class AddRepresentation(bpy.types.Operator):
|
||||
mesh.name = "{}/{}".format(context_id, result.id())
|
||||
mesh.BIMMeshProperties.ifc_definition_id = int(result.id())
|
||||
obj.data = mesh
|
||||
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
|
||||
Data.load(self.file, obj.BIMObjectProperties.ifc_definition_id)
|
||||
|
||||
if product.is_a("IfcTypeProduct"):
|
||||
if self.file.schema == "IFC2X3":
|
||||
@@ -168,7 +168,7 @@ class AddRepresentation(bpy.types.Operator):
|
||||
types = product.Types
|
||||
if types:
|
||||
for element in types[0].RelatedObjects:
|
||||
Data.load(IfcStore.get_file(), element.id())
|
||||
Data.load(self.file, element.id())
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ class SwitchRepresentation(bpy.types.Operator):
|
||||
|
||||
if self.disable_opening_subtractions and self.context_of_items.ContextIdentifier == "Body":
|
||||
if self.oprops.ifc_definition_id not in VoidData.products:
|
||||
VoidData.load(IfcStore.get_file(), self.oprops.ifc_definition_id)
|
||||
VoidData.load(self.file, self.oprops.ifc_definition_id)
|
||||
for opening_id in VoidData.products[self.oprops.ifc_definition_id]:
|
||||
opening = IfcStore.get_element(opening_id)
|
||||
if not opening:
|
||||
@@ -291,7 +291,7 @@ class RemoveRepresentation(bpy.types.Operator):
|
||||
"geometry.unassign_representation", self.file, **{"product": product, "representation": representation}
|
||||
)
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, **{"representation": representation})
|
||||
Data.load(IfcStore.get_file(), product.id())
|
||||
Data.load(self.file, product.id())
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -302,6 +302,10 @@ class UpdateRepresentation(bpy.types.Operator):
|
||||
obj: bpy.props.StringProperty()
|
||||
ifc_representation_class: bpy.props.StringProperty()
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.active_object.mode == "OBJECT"
|
||||
|
||||
def execute(self, context):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
@@ -381,7 +385,9 @@ class UpdateRepresentation(bpy.types.Operator):
|
||||
obj.data.BIMMeshProperties.ifc_definition_id = int(new_representation.id())
|
||||
obj.data.name = f"{old_representation.ContextOfItems.id()}/{new_representation.id()}"
|
||||
bpy.ops.bim.remove_representation(representation_id=old_representation.id(), obj=obj.name)
|
||||
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
|
||||
Data.load(self.file, obj.BIMObjectProperties.ifc_definition_id)
|
||||
if obj.data.BIMMeshProperties.ifc_parameters:
|
||||
bpy.ops.bim.get_representation_ifc_parameters()
|
||||
|
||||
|
||||
class UpdateParametricRepresentation(bpy.types.Operator):
|
||||
@@ -390,15 +396,22 @@ class UpdateParametricRepresentation(bpy.types.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
index: bpy.props.IntProperty()
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.active_object.mode == "OBJECT"
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
obj = context.active_object
|
||||
props = obj.data.BIMMeshProperties
|
||||
parameter = props.ifc_parameters[self.index]
|
||||
element = IfcStore.get_file().by_id(parameter.step_id)[parameter.index] = parameter.value
|
||||
self.file.by_id(parameter.step_id)[parameter.index] = parameter.value
|
||||
show_representation_parameters = bool(props.ifc_parameters)
|
||||
bpy.ops.bim.switch_representation(
|
||||
ifc_definition_id=props.ifc_definition_id, should_reload=True, should_switch_all_meshes=True
|
||||
)
|
||||
if show_representation_parameters:
|
||||
bpy.ops.bim.get_representation_ifc_parameters()
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -411,7 +424,8 @@ class GetRepresentationIfcParameters(bpy.types.Operator):
|
||||
self.file = IfcStore.get_file()
|
||||
obj = context.active_object
|
||||
props = obj.data.BIMMeshProperties
|
||||
elements = IfcStore.get_file().traverse(IfcStore.get_file().by_id(props.ifc_definition_id))
|
||||
elements = self.file.traverse(self.file.by_id(props.ifc_definition_id))
|
||||
props.ifc_parameters.clear()
|
||||
for element in elements:
|
||||
if element.is_a("IfcRepresentationItem") or element.is_a("IfcParameterizedProfileDef"):
|
||||
for i in range(0, len(element)):
|
||||
|
||||
Reference in New Issue
Block a user