Run black

This commit is contained in:
Thomas Krijnen
2025-10-25 15:20:36 +02:00
parent e82ca0e932
commit aed70c8a02
7 changed files with 44 additions and 38 deletions
@@ -1284,8 +1284,7 @@ class CreateDrawing(bpy.types.Operator):
value = ifcopenshell.util.selector.get_element_value(element, key)
if value:
classes.append(
tool.Drawing.canonicalise_class_name(key) + "-" +
tool.Drawing.canonicalise_class_name(str(value))
tool.Drawing.canonicalise_class_name(key) + "-" + tool.Drawing.canonicalise_class_name(str(value))
)
# ─── Target View ───────────────────────────────────────────
@@ -1295,7 +1294,6 @@ class CreateDrawing(bpy.types.Operator):
return classes
def is_manifold(self, obj) -> bool:
result = self.is_manifold_cache.get(obj.data.name, None)
if result is not None:
@@ -1360,7 +1358,13 @@ class CreateDrawing(bpy.types.Operator):
join_criteria = join_criteria.split(",")
else:
# Drawing convention states that same objects classes with the same material are merged when cut.
join_criteria = ["class", "material.Name", "/Pset_.*Common/.Status", "EPset_Status.Status", "EPset_Status.UserDefinedStatus"]
join_criteria = [
"class",
"material.Name",
"/Pset_.*Common/.Status",
"EPset_Status.Status",
"EPset_Status.UserDefinedStatus",
]
group = root.find("{http://www.w3.org/2000/svg}g")
joined_paths = {}
@@ -2349,18 +2353,19 @@ class ActivateDrawingBase(tool.Ifc.Operator):
camera_element = tool.Ifc.get_entity(camera)
is_reflected = False
if camera_element:
is_reflected = ifcopenshell.util.element.get_pset(camera_element, "EPset_Drawing", "TargetView") == "REFLECTED_PLAN_VIEW"
is_reflected = (
ifcopenshell.util.element.get_pset(camera_element, "EPset_Drawing", "TargetView")
== "REFLECTED_PLAN_VIEW"
)
if is_reflected and camera.scale != (-1, -1, -1):
camera.scale = (-1, -1, -1)
if camera_props.update_representation(camera.matrix_world):
bpy.ops.bim.update_representation(obj=camera.name, ifc_representation_class="")
# Restore the scale after update if needed
if is_reflected:
camera.scale = (-1, -1, -1)
return {"FINISHED"}
@@ -3776,6 +3781,6 @@ class ExcludeAnnotation(bpy.types.Operator, tool.Ifc.Operator):
return
for obj in tool.Blender.get_selected_objects(include_active=False):
if (element := tool.Ifc.get_entity(obj)) and tool.Drawing.is_auto_annotation(element):
if (referenced_element := tool.Drawing.get_annotation_element(element)):
if referenced_element := tool.Drawing.get_annotation_element(element):
tool.Drawing.exclude_annotation_from_drawing(referenced_element, drawing)
core.sync_references(tool.Ifc, tool.Collector, tool.Drawing, drawing=drawing)
+1 -3
View File
@@ -499,9 +499,7 @@ class BIMCameraProperties(PropertyGroup):
update=get_update_layer_callback("linework_mode", "LineworkMode"),
)
generate_material_layers: bpy.props.BoolProperty(
name="Generate Material Layers",
description="Generate material layer linework in drawings",
default=True
name="Generate Material Layers", description="Generate material layer linework in drawings", default=True
)
fill_mode: EnumProperty(
items=[
@@ -302,7 +302,7 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
related_objects = bpy.context.selected_objects
created_objects = []
for related_object in related_objects:
obj = core.add_annotation(
tool.Ifc,
@@ -317,15 +317,14 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
)
tool.Drawing.setup_annotation_object(obj, object_type, related_object, props.tag_rotation_mode)
created_objects.append(obj)
# Select the created annotation objects
bpy.ops.object.select_all(action='DESELECT')
bpy.ops.object.select_all(action="DESELECT")
for obj in created_objects:
obj.select_set(True)
if created_objects:
bpy.context.view_layer.objects.active = created_objects[-1]
def hotkey_S_A(self):
if bpy.ops.bim.add_annotation.poll():
bpy.ops.bim.add_annotation()
+4 -6
View File
@@ -503,7 +503,7 @@ class BIMStairProperties(PropertyGroup):
stair_kwargs = tool.Model.convert_data_to_project_units(stair_kwargs, self.non_si_units_props)
return stair_kwargs
def get_props_kwargs_for_ifc_export(self, convert_to_project_units=False, stair_type=None):
"""Get props including custom_tread_lock for saving to IFC"""
stair_kwargs = self.get_props_kwargs(convert_to_project_units, stair_type)
@@ -513,17 +513,15 @@ class BIMStairProperties(PropertyGroup):
def set_props_kwargs_from_ifc_data(self, kwargs):
kwargs = tool.Model.convert_data_to_si_units(kwargs, self.non_si_units_props)
# Determine lock state based on whether custom treads match tread_run
# If custom_tread_lock wasn't saved (old files), infer it from the data
if "custom_tread_lock" not in kwargs:
custom_treads = kwargs.get("custom_first_last_tread_run", (0.0, 0.0))
tread_run = kwargs.get("tread_run", 0.3)
# Lock is off if either custom tread differs from tread_run and is not 0
kwargs["custom_tread_lock"] = not any(
ct != 0.0 and ct != tread_run for ct in custom_treads
)
kwargs["custom_tread_lock"] = not any(ct != 0.0 and ct != tread_run for ct in custom_treads)
for prop_name in kwargs:
setattr(self, prop_name, kwargs[prop_name])
+7 -5
View File
@@ -305,21 +305,23 @@ class BIM_PT_stair(bpy.types.Panel):
# Skip custom_tread_lock as it's handled with custom_first_last_tread_run
if prop_name == "custom_tread_lock":
continue
prop_value = getattr(props, prop_name)
# Special handling for custom_first_last_tread_run
if prop_name == "custom_first_last_tread_run":
# Draw the lock toggle
row_lock = self.layout.row(align=True)
lock_text = "Lock First/Last Treads" if not props.custom_tread_lock else "Unlock First/Last Treads"
lock_text = (
"Lock First/Last Treads" if not props.custom_tread_lock else "Unlock First/Last Treads"
)
row_lock.prop(
props,
"custom_tread_lock",
text=lock_text,
icon="LOCKED" if props.custom_tread_lock else "UNLOCKED",
)
# Only show the custom values input if unlocked
if not props.custom_tread_lock:
prop_readable_name = props.bl_rna.properties[prop_name].name
@@ -331,7 +333,7 @@ class BIM_PT_stair(bpy.types.Panel):
self.layout.prop(props, prop_name, text="")
else:
self.layout.prop(props, prop_name)
if prop_name == "height": # Weak but we just want to insert this inside props drawing
row_length = self.layout.row(align=True)
row_length.prop(props, "total_length_target")
@@ -523,8 +523,12 @@ class BIMWorkScheduleProperties(PropertyGroup):
active_task_input_index: IntProperty(name="Active Task Input Index")
task_outputs: CollectionProperty(name="Task Outputs", type=TaskProduct)
active_task_output_index: IntProperty(name="Active Task Output Index")
show_nested_outputs: BoolProperty(name="Show Nested Task Elements", default=False, update=update_active_task_outputs)
show_nested_resources: BoolProperty(name="Show Nested Task Elements", default=False, update=update_active_task_resources)
show_nested_outputs: BoolProperty(
name="Show Nested Task Elements", default=False, update=update_active_task_outputs
)
show_nested_resources: BoolProperty(
name="Show Nested Task Elements", default=False, update=update_active_task_resources
)
show_nested_inputs: BoolProperty(name="Show Nested Task Elements", default=False, update=update_active_task_inputs)
product_input_tasks: CollectionProperty(name="Product Task Inputs", type=TaskProduct)
product_output_tasks: CollectionProperty(name="Product Task Outputs", type=TaskProduct)
+10 -10
View File
@@ -1439,16 +1439,16 @@ class Model(bonsai.core.tool.Model):
if current_tread_run is not None:
tread_offset = default_tread_offset.copy()
tread_offset.x = current_tread_run
# Handle zero-width treads
if current_tread_run == 0:
# For zero width, just return vertical offset with no horizontal tread
return tread_offset, ()
tread_verts = deepcopy(default_tread_verts)
tread_verts[-1].x = current_tread_run
return tread_offset, tread_verts
return default_tread_offset, default_tread_verts
# treads
@@ -1456,13 +1456,13 @@ class Model(bonsai.core.tool.Model):
for i in range(number_of_risers):
last_vert_i = len(vertices) - 1
tread_offset, tread_verts = get_tread_data(i)
# Skip adding vertices/edges for zero-width treads
if tread_verts:
current_tread_verts = [v + current_offset for v in tread_verts]
edges.extend(default_tread_edges + last_vert_i)
vertices.extend(current_tread_verts)
current_offset += tread_offset
if stair_type == "WOOD/STEEL":
@@ -1487,14 +1487,14 @@ class Model(bonsai.core.tool.Model):
if current_tread_run is not None:
tread_offset = default_tread_offset.copy()
tread_offset.x = current_tread_run + nosing_tread_gap
# Handle zero-width treads
if current_tread_run == 0:
return tread_offset, ()
tread_verts = get_tread_verts(size=V_(current_tread_run + nosing_overlap, tread_depth))
return tread_offset, tread_verts
return default_tread_offset, default_tread_verts
# each tread is a separate shape
@@ -1502,7 +1502,7 @@ class Model(bonsai.core.tool.Model):
tread_index = 0
for i in range(number_of_risers):
tread_offset, tread_verts = get_tread_data(i)
# Skip adding vertices/edges for zero-width treads
if tread_verts:
cur_trade_shape = [v + cur_offset + nosing_overlap_offset for v in tread_verts]
@@ -1517,7 +1517,7 @@ class Model(bonsai.core.tool.Model):
)
edges.extend(verts_to_add)
tread_index += 1
cur_offset += tread_offset
elif stair_type == "GENERIC":