Cleanup : Use clear instead of while...remove loop

This commit is contained in:
Gorgious
2021-08-17 14:41:15 +02:00
parent 88669701b2
commit 4614bde8d7
24 changed files with 79 additions and 150 deletions
@@ -40,8 +40,7 @@ class EnableEditingAttributes(bpy.types.Operator):
obj = bpy.data.materials.get(self.obj)
oprops = obj.BIMObjectProperties
props = obj.BIMAttributeProperties
while len(props.attributes) > 0:
props.attributes.remove(0)
props.attributes.clear()
for attribute in Data.products[oprops.ifc_definition_id]:
new = props.attributes.add()
if attribute["type"] == "entity" or (attribute["type"] == "list" and attribute["list_type"] == "entity"):
@@ -166,8 +166,7 @@ class LoadBcfComments(bpy.types.Operator):
bcfxml = bcfstore.BcfStore.get_bcfxml()
bcfxml.get_comments(self.topic_guid)
blender_topic = context.scene.BCFProperties.topics.get(self.topic_guid)
while len(blender_topic.comments) > 0:
blender_topic.comments.remove(0)
blender_topic.comments.clear()
for comment in bcfxml.topics[self.topic_guid].comments.values():
new = blender_topic.comments.add()
data_map = {
@@ -770,8 +769,7 @@ class ActivateBcfViewpoint(bpy.types.Operator):
if viewpoint.snapshot:
obj.data.show_background_images = True
while len(obj.data.background_images) > 0:
obj.data.background_images.remove(obj.data.background_images[0])
obj.data.background_images.clear()
background = obj.data.background_images.new()
background.image = bpy.data.images.load(
os.path.join(bcfxml.filepath, topic.guid, viewpoint.snapshot)
@@ -459,8 +459,7 @@ class SetBlenderClashSetA(bpy.types.Operator):
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
while len(context.scene.BIMClashProperties.blender_clash_set_a) > 0:
context.scene.BIMClashProperties.blender_clash_set_a.remove(0)
context.scene.BIMClashProperties.blender_clash_set_a.clear()
for obj in context.selected_objects:
new = context.scene.BIMClashProperties.blender_clash_set_a.add()
new.name = obj.name
@@ -473,8 +472,7 @@ class SetBlenderClashSetB(bpy.types.Operator):
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
while len(context.scene.BIMClashProperties.blender_clash_set_b) > 0:
context.scene.BIMClashProperties.blender_clash_set_b.remove(0)
context.scene.BIMClashProperties.blender_clash_set_b.clear()
for obj in context.selected_objects:
new = context.scene.BIMClashProperties.blender_clash_set_b.add()
new.name = obj.name
@@ -69,8 +69,7 @@ class EnableEditingClassification(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMClassificationProperties
while len(props.classification_attributes) > 0:
props.classification_attributes.remove(0)
props.classification_attributes.clear()
classification_data = Data.classifications[self.classification]
for attribute in IfcStore.get_schema().declaration_by_name("IfcClassification").all_attributes():
new = props.classification_attributes.add()
@@ -154,8 +153,7 @@ class EnableEditingClassificationReference(bpy.types.Operator):
def execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
props = obj.BIMClassificationReferenceProperties
while len(props.reference_attributes) > 0:
props.reference_attributes.remove(0)
props.reference_attributes.clear()
reference_data = Data.references[self.reference]
for attribute in IfcStore.get_schema().declaration_by_name("IfcClassificationReference").all_attributes():
if attribute.name() == "ReferencedSource":
@@ -56,8 +56,7 @@ def updateClassification(self, context):
def getReferences(self, context, parent_id=None):
props = context.scene.BIMClassificationProperties
while len(props.available_library_references) > 0:
props.available_library_references.remove(0)
props.available_library_references.clear()
for reference in Data.library_file.by_id(parent_id).HasReferences:
new = props.available_library_references.add()
new.identification = reference.Identification or ""
@@ -33,8 +33,7 @@ class LoadObjectives(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMConstraintProperties
while len(props.constraints) > 0:
props.constraints.remove(0)
props.constraints.clear()
for constraint_id, constraint in Data.objectives.items():
new = props.constraints.add()
new.name = constraint["Name"] or "Unnamed"
@@ -63,8 +62,7 @@ class EnableEditingConstraint(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMConstraintProperties
while len(props.constraint_attributes) > 0:
props.constraint_attributes.remove(0)
props.constraint_attributes.clear()
if props.is_editing == "IfcObjective":
data = Data.objectives[self.constraint]
@@ -94,8 +94,7 @@ class EnableEditingCostSchedule(bpy.types.Operator):
def execute(self, context):
self.props = context.scene.BIMCostProperties
self.props.active_cost_schedule_id = self.cost_schedule
while len(self.props.cost_schedule_attributes) > 0:
self.props.cost_schedule_attributes.remove(0)
self.props.cost_schedule_attributes.clear()
self.enable_editing_cost_schedule()
self.props.is_editing = "COST_SCHEDULE"
return {"FINISHED"}
@@ -276,8 +275,7 @@ class EnableEditingCostItem(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMCostProperties
while len(props.cost_item_attributes) > 0:
props.cost_item_attributes.remove(0)
props.cost_item_attributes.clear()
data = Data.cost_items[self.cost_item]
blenderbim.bim.helper.import_attributes("IfcCostItem", props.cost_item_attributes, data)
@@ -538,8 +536,7 @@ class EnableEditingCostItemQuantity(bpy.types.Operator):
def execute(self, context):
self.props = context.scene.BIMCostProperties
while len(self.props.quantity_attributes) > 0:
self.props.quantity_attributes.remove(0)
self.props.quantity_attributes.clear()
self.props.active_cost_item_quantity_id = self.physical_quantity
data = Data.physical_quantities[self.physical_quantity]
blenderbim.bim.helper.import_attributes(data["type"], self.props.quantity_attributes, data)
@@ -635,8 +632,7 @@ class EnableEditingCostItemValue(bpy.types.Operator):
def execute(self, context):
self.props = context.scene.BIMCostProperties
while len(self.props.cost_value_attributes) > 0:
self.props.cost_value_attributes.remove(0)
self.props.cost_value_attributes.clear()
self.props.active_cost_item_value_id = self.cost_value
data = Data.cost_values[self.cost_value]
@@ -868,12 +864,9 @@ class LoadCostItemQuantities(bpy.types.Operator):
def execute(self, context):
self.props = context.scene.BIMCostProperties
self.file = IfcStore.get_file()
while len(self.props.cost_item_products) > 0:
self.props.cost_item_products.remove(0)
while len(self.props.cost_item_processes) > 0:
self.props.cost_item_processes.remove(0)
while len(self.props.cost_item_resources) > 0:
self.props.cost_item_resources.remove(0)
self.props.cost_item_products.clear()
self.props.cost_item_processes.clear()
self.props.cost_item_resources.clear()
ifc_definition_id = self.props.cost_items[self.props.active_cost_item_index].ifc_definition_id
for control_id, quantity_ids in Data.cost_items[ifc_definition_id]["Controls"].items():
related_object = self.file.by_id(control_id)
@@ -900,13 +893,10 @@ class LoadCostItemTypes(bpy.types.Operator):
def execute(self, context):
self.props = context.scene.BIMCostProperties
self.file = IfcStore.get_file()
while len(self.props.cost_item_type_products) > 0:
self.props.cost_item_type_products.remove(0)
self.props.cost_item_type_products.clear()
# TODO implement process and resource types
# while len(self.props.cost_item_processes) > 0:
# self.props.cost_item_processes.remove(0)
# while len(self.props.cost_item_resources) > 0:
# self.props.cost_item_resources.remove(0)
# self.props.cost_item_processes.clear()
# self.props.cost_item_resources.clear()
ifc_definition_id = self.props.cost_items[self.props.active_cost_item_index].ifc_definition_id
for control_id, quantity_ids in Data.cost_items[ifc_definition_id]["Controls"].items():
related_object = self.file.by_id(control_id)
@@ -197,18 +197,16 @@ class InspectFromStepId(bpy.types.Operator):
def execute(self, context):
self.file = IfcStore.get_file()
context.scene.BIMDebugProperties.active_step_id = self.step_id
debug_props = context.scene.BIMDebugProperties
debug_props.active_step_id = self.step_id
crumb = context.scene.BIMDebugProperties.step_id_breadcrumb.add()
crumb.name = str(self.step_id)
element = self.file.by_id(self.step_id)
while len(context.scene.BIMDebugProperties.attributes) > 0:
context.scene.BIMDebugProperties.attributes.remove(0)
while len(context.scene.BIMDebugProperties.inverse_attributes) > 0:
context.scene.BIMDebugProperties.inverse_attributes.remove(0)
while len(context.scene.BIMDebugProperties.inverse_references) > 0:
context.scene.BIMDebugProperties.inverse_references.remove(0)
debug_props.attributes.clear()
debug_props.inverse_attributes.clear()
debug_props.inverse_references.clear()
for key, value in element.get_info().items():
self.add_attribute(context.scene.BIMDebugProperties.attributes, key, value)
self.add_attribute(debug_props.attributes, key, value)
for key in dir(element):
if (
not key[0].isalpha()
@@ -217,9 +215,9 @@ class InspectFromStepId(bpy.types.Operator):
or not getattr(element, key)
):
continue
self.add_attribute(context.scene.BIMDebugProperties.inverse_attributes, key, getattr(element, key))
self.add_attribute(debug_props.inverse_attributes, key, getattr(element, key))
for inverse in self.file.get_inverse(element):
new = context.scene.BIMDebugProperties.inverse_references.add()
new = debug_props.inverse_references.add()
new.string_value = str(inverse)
new.int_value = inverse.id()
return {"FINISHED"}
@@ -33,8 +33,7 @@ class LoadInformation(bpy.types.Operator):
def execute(self, context):
self.file = IfcStore.get_file()
props = context.scene.BIMDocumentProperties
while len(props.documents) > 0:
props.documents.remove(0)
props.documents.clear()
for information_id, information in Data.information.items():
new = props.documents.add()
new.name = information["Name"] or "Unnamed"
@@ -56,8 +55,7 @@ class LoadDocumentReferences(bpy.types.Operator):
def execute(self, context):
self.file = IfcStore.get_file()
props = context.scene.BIMDocumentProperties
while len(props.documents) > 0:
props.documents.remove(0)
props.documents.clear()
for reference_id, reference in Data.references.items():
new = props.documents.add()
new.name = reference["Name"] or "Unnamed"
@@ -90,8 +88,7 @@ class EnableEditingDocument(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMDocumentProperties
while len(props.document_attributes) > 0:
props.document_attributes.remove(0)
props.document_attributes.clear()
if props.is_editing == "information":
data = Data.information[self.document]
@@ -819,8 +819,7 @@ class PropagateTextData(bpy.types.Operator):
obj.data.align_y = source.data.align_y
obj.data.BIMTextProperties.font_size = source.data.BIMTextProperties.font_size
obj.data.BIMTextProperties.symbol = source.data.BIMTextProperties.symbol
while len(obj.data.BIMTextProperties.variables) > 0:
obj.data.BIMTextProperties.variables.remove(0)
obj.data.BIMTextProperties.variables.clear()
for variable in source.data.BIMTextProperties.variables:
new_variable = obj.data.BIMTextProperties.variables.add()
new_variable.name = variable.name
@@ -1144,13 +1143,13 @@ class RefreshDrawingList(bpy.types.Operator):
bl_label = "Refresh Drawing List"
def execute(self, context):
while len(bpy.context.scene.DocProperties.drawings) > 0:
bpy.context.scene.DocProperties.drawings.remove(0)
for obj in bpy.context.scene.objects:
doc_props = context.scene.DocProperties.drawings
doc_props.drawings.clear()
for obj in context.scene.objects:
if not isinstance(obj.data, bpy.types.Camera):
continue
if "IfcAnnotation/" in obj.name:
new = bpy.context.scene.DocProperties.drawings.add()
new = doc_props.drawings.add()
new.name = "/".join(obj.name.split("/")[1:])
new.camera = obj
return {"FINISHED"}
@@ -38,8 +38,7 @@ class EnableEditingGeoreferencing(bpy.types.Operator):
self.file = IfcStore.get_file()
props = context.scene.BIMGeoreferenceProperties
while len(props.projected_crs) > 0:
props.projected_crs.remove(0)
props.projected_crs.clear()
for attribute in IfcStore.get_schema().declaration_by_name("IfcProjectedCRS").all_attributes():
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
@@ -69,8 +68,7 @@ class EnableEditingGeoreferencing(bpy.types.Operator):
elif props.map_unit_type == "IfcConversionBasedUnit":
props.map_unit_imperial = Data.projected_crs["MapUnit"]["Name"]
while len(props.map_conversion) > 0:
props.map_conversion.remove(0)
props.map_conversion.clear()
for attribute in IfcStore.get_schema().declaration_by_name("IfcMapConversion").all_attributes():
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
@@ -31,8 +31,7 @@ class LoadGroups(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMGroupProperties
while len(props.groups) > 0:
props.groups.remove(0)
props.groups.clear()
for ifc_definition_id, group in Data.groups.items():
new = props.groups.add()
new.ifc_definition_id = ifc_definition_id
@@ -119,8 +118,7 @@ class EnableEditingGroup(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMGroupProperties
while len(props.group_attributes) > 0:
props.group_attributes.remove(0)
props.group_attributes.clear()
data = Data.groups[self.group]
@@ -33,8 +33,7 @@ class LoadLayers(bpy.types.Operator):
def execute(self, context):
self.file = IfcStore.get_file()
props = context.scene.BIMLayerProperties
while len(props.layers) > 0:
props.layers.remove(0)
props.layers.clear()
for layer_id, layer in Data.layers.items():
new = props.layers.add()
new.name = layer["Name"] or "Unnamed"
@@ -62,8 +61,7 @@ class EnableEditingLayer(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMLayerProperties
while len(props.layer_attributes) > 0:
props.layer_attributes.remove(0)
props.layer_attributes.clear()
data = Data.layers[self.layer]
@@ -420,16 +420,14 @@ class EnableEditingAssignedMaterial(bpy.types.Operator):
else:
material_set_data = {}
while len(props.material_set_usage_attributes) > 0:
props.material_set_usage_attributes.remove(0)
props.material_set_usage_attributes.clear()
if "Usage" in product_data["type"]:
blenderbim.bim.helper.import_attributes(
product_data["type"], props.material_set_usage_attributes, material_set_usage, self.import_attributes
)
while len(props.material_set_attributes) > 0:
props.material_set_attributes.remove(0)
props.material_set_attributes.clear()
for attribute in IfcStore.get_schema().declaration_by_name(material_set_class).all_attributes():
if "<string>" not in str(attribute.type_of_attribute):
@@ -584,8 +582,7 @@ class EnableEditingMaterialSetItem(bpy.types.Operator):
return {"FINISHED"}
def load_set_item_attributes(self, material_set_item, material_set_item_data):
while len(self.props.material_set_item_attributes) > 0:
self.props.material_set_item_attributes.remove(0)
self.props.material_set_item_attributes.clear()
for attribute in IfcStore.get_schema().declaration_by_name(material_set_item.is_a()).all_attributes():
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
@@ -606,8 +603,7 @@ class EnableEditingMaterialSetItem(bpy.types.Operator):
new.bool_value = False if new.is_null else material_set_item_data[attribute.name()]
def load_profile_attributes(self, material_set_item, material_set_item_data):
while len(self.props.material_set_item_profile_attributes) > 0:
self.props.material_set_item_profile_attributes.remove(0)
self.props.material_set_item_profile_attributes.clear()
if not material_set_item_data["Profile"]:
return
@@ -31,8 +31,7 @@ class LoadProfiles(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMProfileProperties
while len(props.profiles) > 0:
props.profiles.remove(0)
props.profiles.clear()
for ifc_definition_id, profile in Data.profiles.items():
new = props.profiles.add()
@@ -80,8 +79,7 @@ class EnableEditingProfile(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMProfileProperties
while len(props.profile_attributes) > 0:
props.profile_attributes.remove(0)
props.profile_attributes.clear()
data = Data.profiles[self.profile]
@@ -182,11 +182,8 @@ class RefreshLibrary(bpy.types.Operator):
def execute(self, context):
self.props = context.scene.BIMProjectProperties
while len(self.props.library_elements) > 0:
self.props.library_elements.remove(0)
while len(self.props.library_breadcrumb) > 0:
self.props.library_breadcrumb.remove(0)
self.props.library_elements.clear()
self.props.library_breadcrumb.clear()
self.props.active_library_element = ""
@@ -212,8 +209,7 @@ class ChangeLibraryElement(bpy.types.Operator):
crumb.name = self.element_name
elements = IfcStore.library_file.by_type(self.element_name)
[ifc_classes.add(e.is_a()) for e in elements]
while len(self.props.library_elements) > 0:
self.props.library_elements.remove(0)
self.props.library_elements.clear()
if len(ifc_classes) == 1 and list(ifc_classes)[0] == self.element_name:
for element in elements:
new = self.props.library_elements.add()
@@ -90,8 +90,7 @@ class EnablePsetEditing(bpy.types.Operator):
def execute(self, context):
self.props = get_pset_props(context, self.obj, self.obj_type)
while len(self.props.properties) > 0:
self.props.properties.remove(0)
self.props.properties.clear()
data = Data.psets if self.pset_id in Data.psets else Data.qtos
pset_data = data[self.pset_id]
@@ -37,8 +37,7 @@ class LoadResources(bpy.types.Operator):
def execute(self, context):
self.props = context.scene.BIMResourceProperties
self.tprops = context.scene.BIMResourceTreeProperties
while len(self.tprops.resources) > 0:
self.tprops.resources.remove(0)
self.tprops.resources.clear()
self.contracted_resources = json.loads(self.props.contracted_resources)
for resource_id, data in Data.resources.items():
@@ -72,8 +71,7 @@ class EnableEditingResource(bpy.types.Operator):
def execute(self, context):
self.props = context.scene.BIMResourceProperties
self.props.active_resource_id = self.resource
while len(self.props.resource_attributes) > 0:
self.props.resource_attributes.remove(0)
self.props.resource_attributes.clear()
self.props.editing_resource_type = "ATTRIBUTES"
self.enable_editing_resource()
return {"FINISHED"}
@@ -299,8 +297,7 @@ class EnableEditingResourceTime(bpy.types.Operator):
props = context.scene.BIMResourceProperties
self.file = IfcStore.get_file()
resource_time_id = Data.resources[self.resource]["Usage"] or self.add_resource_time().id()
while len(props.resource_time_attributes) > 0:
props.resource_time_attributes.remove(0)
props.resource_time_attributes.clear()
data = Data.resource_times[resource_time_id]
@@ -114,8 +114,7 @@ class EnableEditingWorkPlan(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMWorkPlanProperties
while len(props.work_plan_attributes) > 0:
props.work_plan_attributes.remove(0)
props.work_plan_attributes.clear()
data = Data.work_plans[self.work_plan]
@@ -279,8 +278,7 @@ class EnableEditingWorkSchedule(bpy.types.Operator):
def execute(self, context):
self.props = context.scene.BIMWorkScheduleProperties
self.props.active_work_schedule_id = self.work_schedule
while len(self.props.work_schedule_attributes) > 0:
self.props.work_schedule_attributes.remove(0)
self.props.work_schedule_attributes.clear()
self.enable_editing_work_schedule()
self.props.editing_type = "WORK_SCHEDULE"
return {"FINISHED"}
@@ -308,8 +306,7 @@ class EnableEditingTasks(bpy.types.Operator):
self.props = context.scene.BIMWorkScheduleProperties
self.tprops = context.scene.BIMTaskTreeProperties
self.props.active_work_schedule_id = self.work_schedule
while len(self.tprops.tasks) > 0:
self.tprops.tasks.remove(0)
self.tprops.tasks.clear()
self.contracted_tasks = json.loads(self.props.contracted_tasks)
self.sort_keys = {
@@ -542,8 +539,7 @@ class EnableEditingTaskTime(bpy.types.Operator):
task_time_id = Data.tasks[self.task]["TaskTime"] or self.add_task_time().id()
while len(props.task_time_attributes) > 0:
props.task_time_attributes.remove(0)
props.task_time_attributes.clear()
data = Data.task_times[task_time_id]
@@ -616,9 +612,7 @@ class EnableEditingTask(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMWorkScheduleProperties
while len(props.task_attributes) > 0:
props.task_attributes.remove(0)
props.task_attributes.clear()
data = Data.tasks[self.task]
blenderbim.bim.helper.import_attributes("IfcTask", props.task_attributes, data)
@@ -1043,8 +1037,7 @@ class EnableEditingWorkCalendar(bpy.types.Operator):
def execute(self, context):
self.props = context.scene.BIMWorkCalendarProperties
while len(self.props.work_calendar_attributes) > 0:
self.props.work_calendar_attributes.remove(0)
self.props.work_calendar_attributes.clear()
data = Data.work_calendars[self.work_calendar]
@@ -1150,8 +1143,7 @@ class EnableEditingWorkTime(bpy.types.Operator):
def execute(self, context):
self.props = context.scene.BIMWorkCalendarProperties
while len(self.props.work_time_attributes) > 0:
self.props.work_time_attributes.remove(0)
self.props.work_time_attributes.clear()
data = Data.work_times[self.work_time]
@@ -1488,8 +1480,7 @@ class EnableEditingSequenceAttributes(bpy.types.Operator):
self.props = context.scene.BIMWorkScheduleProperties
self.props.active_sequence_id = self.sequence
self.props.editing_sequence_type = "ATTRIBUTES"
while len(self.props.sequence_attributes) > 0:
self.props.sequence_attributes.remove(0)
self.props.sequence_attributes.clear()
self.enable_editing_sequence_attributes()
return {"FINISHED"}
@@ -1509,8 +1500,7 @@ class EnableEditingSequenceTimeLag(bpy.types.Operator):
self.props = context.scene.BIMWorkScheduleProperties
self.props.active_sequence_id = self.sequence
self.props.editing_sequence_type = "TIME_LAG"
while len(self.props.time_lag_attributes) > 0:
self.props.time_lag_attributes.remove(0)
self.props.time_lag_attributes.clear()
self.enable_editing_attributes()
return {"FINISHED"}
@@ -38,8 +38,7 @@ def getSpatialContainers(self, context, parent_id=None):
Data.load(IfcStore.get_file())
self.file = IfcStore.get_file()
props = context.scene.BIMSpatialProperties
while len(props.spatial_elements) > 0:
props.spatial_elements.remove(0)
props.spatial_elements.clear()
if parent_id:
props.active_decomposes_id = parent_id
@@ -153,8 +153,7 @@ class EnableEditingStructuralBoundaryCondition(bpy.types.Operator):
def execute(self, context):
obj = context.active_object
props = obj.BIMStructuralProperties
while len(props.boundary_condition_attributes) > 0:
props.boundary_condition_attributes.remove(0)
props.boundary_condition_attributes.clear()
data = Data.boundary_conditions[self.boundary_condition]
@@ -240,8 +239,7 @@ class LoadStructuralAnalysisModels(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMStructuralProperties
while len(props.structural_analysis_models) > 0:
props.structural_analysis_models.remove(0)
props.structural_analysis_models.clear()
for ifc_definition_id, structural_analysis_model in Data.structural_analysis_models.items():
new = props.structural_analysis_models.add()
new.ifc_definition_id = ifc_definition_id
@@ -343,8 +341,7 @@ class EnableEditingStructuralAnalysisModel(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMStructuralProperties
while len(props.structural_analysis_model_attributes) > 0:
props.structural_analysis_model_attributes.remove(0)
props.structural_analysis_model_attributes.clear()
data = Data.structural_analysis_models[self.structural_analysis_model]
@@ -697,8 +694,7 @@ class EnableEditingStructuralLoadCase(bpy.types.Operator):
self.props = context.scene.BIMStructuralProperties
self.props.active_load_case_id = self.load_case
self.props.load_case_editing_type = "ATTRIBUTES"
while len(self.props.load_case_attributes) > 0:
self.props.load_case_attributes.remove(0)
self.props.load_case_attributes.clear()
data = Data.load_cases[self.load_case]
blenderbim.bim.helper.import_attributes(
"IfcStructuralLoadCase", self.props.load_case_attributes, data, self.import_attributes
@@ -784,8 +780,7 @@ class EnableEditingStructuralLoadGroupActivities(bpy.types.Operator):
return {"FINISHED"}
def load_structural_activities(self):
while len(self.props.load_group_activities) > 0:
self.props.load_group_activities.remove(0)
self.props.load_group_activities.clear()
for activity_id in Data.load_groups[self.load_group]["IsGroupedBy"]:
activity = Data.structural_activities[activity_id]
new = self.props.load_group_activities.add()
@@ -856,8 +851,7 @@ class LoadStructuralLoads(bpy.types.Operator):
def execute(self, context):
self.file = IfcStore.get_file()
props = context.scene.BIMStructuralProperties
while len(props.structural_loads) > 0:
props.structural_loads.remove(0)
props.structural_loads.clear()
if props.filtered_structural_loads:
names = [structural_load["Name"] or "Unnamed" for _, structural_load in Data.structural_loads.items()]
for ifc_definition_id, structural_load in Data.structural_loads.items():
@@ -919,8 +913,7 @@ class EnableEditingStructuralLoad(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMStructuralProperties
while len(props.structural_load_attributes) > 0:
props.structural_load_attributes.remove(0)
props.structural_load_attributes.clear()
data = Data.structural_loads[self.structural_load]
blenderbim.bim.helper.import_attributes(data["type"], props.structural_load_attributes, data)
@@ -1002,8 +995,7 @@ class LoadBoundaryConditions(bpy.types.Operator):
def execute(self, context):
self.file = IfcStore.get_file()
props = context.scene.BIMStructuralProperties
while len(props.boundary_conditions) > 0:
props.boundary_conditions.remove(0)
props.boundary_conditions.clear()
if props.filtered_boundary_conditions:
names = [
boundary_condition["Name"] or "Unnamed" for _, boundary_condition in Data.boundary_conditions.items()
@@ -1082,8 +1074,7 @@ class EnableEditingBoundaryCondition(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMStructuralProperties
while len(props.boundary_condition_attributes) > 0:
props.boundary_condition_attributes.remove(0)
props.boundary_condition_attributes.clear()
data = Data.boundary_conditions[self.boundary_condition]
# blenderbim.bim.helper.import_attributes(data["type"], props.boundary_condition_attributes, data)
@@ -129,8 +129,7 @@ class EnableEditingStyle(bpy.types.Operator):
def execute(self, context):
material = bpy.data.materials.get(self.material) if self.material else context.active_object.active_material
props = material.BIMStyleProperties
while len(props.attributes) > 0:
props.attributes.remove(0)
props.attributes.clear()
data = Data.styles[material.BIMMaterialProperties.ifc_style_id]
blenderbim.bim.helper.import_attributes("IfcSurfaceStyle", props.attributes, data)
@@ -31,8 +31,7 @@ class LoadSystems(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMSystemProperties
while len(props.systems) > 0:
props.systems.remove(0)
props.systems.clear()
for ifc_definition_id, system in Data.systems.items():
new = props.systems.add()
new.ifc_definition_id = ifc_definition_id
@@ -119,8 +118,7 @@ class EnableEditingSystem(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMSystemProperties
while len(props.system_attributes) > 0:
props.system_attributes.remove(0)
props.system_attributes.clear()
data = Data.systems[self.system]
@@ -98,8 +98,7 @@ class LoadUnits(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMUnitProperties
while len(props.units) > 0:
props.units.remove(0)
props.units.clear()
for ifc_definition_id, unit in Data.units.items():
name = unit.get("Name", "")
@@ -233,8 +232,7 @@ class EnableEditingUnit(bpy.types.Operator):
def execute(self, context):
props = context.scene.BIMUnitProperties
while len(props.unit_attributes) > 0:
props.unit_attributes.remove(0)
props.unit_attributes.clear()
data = Data.units[self.unit]
blenderbim.bim.helper.import_attributes(data["type"], props.unit_attributes, data, self.import_attributes)
props.active_unit_id = self.unit