mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 22:16:41 +00:00
black .
This commit is contained in:
@@ -590,7 +590,9 @@ class PolylineDecorator:
|
|||||||
return
|
return
|
||||||
center = sum(polyline_verts, Vector()) / len(polyline_verts) # Center between all polyline points
|
center = sum(polyline_verts, Vector()) / len(polyline_verts) # Center between all polyline points
|
||||||
if polyline_verts[0] == polyline_verts[-1]:
|
if polyline_verts[0] == polyline_verts[-1]:
|
||||||
center = sum(polyline_verts[:-1], Vector()) / len(polyline_verts[:-1]) # Doesn't use the last point if is a closed polyline
|
center = sum(polyline_verts[:-1], Vector()) / len(
|
||||||
|
polyline_verts[:-1]
|
||||||
|
) # Doesn't use the last point if is a closed polyline
|
||||||
area_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, center)
|
area_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, center)
|
||||||
value = polyline_data.area
|
value = polyline_data.area
|
||||||
text = f"area: {value}"
|
text = f"area: {value}"
|
||||||
|
|||||||
@@ -304,7 +304,9 @@ class PolylineOperator:
|
|||||||
|
|
||||||
def handle_snap_selection(self, context, event):
|
def handle_snap_selection(self, context, event):
|
||||||
if event.value == "PRESS" and event.type == "M":
|
if event.value == "PRESS" and event.type == "M":
|
||||||
self.snapping_points = tool.Snap.modify_snapping_point_selection(self.snapping_points, lock_axis = self.tool_state.lock_axis)
|
self.snapping_points = tool.Snap.modify_snapping_point_selection(
|
||||||
|
self.snapping_points, lock_axis=self.tool_state.lock_axis
|
||||||
|
)
|
||||||
tool.Polyline.calculate_distance_and_angle(context, self.input_ui, self.tool_state)
|
tool.Polyline.calculate_distance_and_angle(context, self.input_ui, self.tool_state)
|
||||||
PolylineDecorator.update(event, self.tool_state, self.input_ui, self.snapping_points[0])
|
PolylineDecorator.update(event, self.tool_state, self.input_ui, self.snapping_points[0])
|
||||||
tool.Blender.update_viewport()
|
tool.Blender.update_viewport()
|
||||||
@@ -355,7 +357,9 @@ class PolylineOperator:
|
|||||||
if self.snapping_points[0][1] in {"Plane", "Axis"}:
|
if self.snapping_points[0][1] in {"Plane", "Axis"}:
|
||||||
should_round = True
|
should_round = True
|
||||||
|
|
||||||
tool.Polyline.calculate_distance_and_angle(context, self.input_ui, self.tool_state, should_round=should_round)
|
tool.Polyline.calculate_distance_and_angle(
|
||||||
|
context, self.input_ui, self.tool_state, should_round=should_round
|
||||||
|
)
|
||||||
if should_round:
|
if should_round:
|
||||||
tool.Polyline.calculate_x_y_and_z(context, self.input_ui, self.tool_state)
|
tool.Polyline.calculate_x_y_and_z(context, self.input_ui, self.tool_state)
|
||||||
tool.Blender.update_viewport()
|
tool.Blender.update_viewport()
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ class CreateObjectUI:
|
|||||||
op = row.operator(
|
op = row.operator(
|
||||||
"bim.add_default_type",
|
"bim.add_default_type",
|
||||||
icon_value=custom_icon_previews["QUICK_DEFAULT"].icon_id,
|
icon_value=custom_icon_previews["QUICK_DEFAULT"].icon_id,
|
||||||
text=f"Quick Create {AuthoringData.data['ifc_element_type']}"
|
text=f"Quick Create {AuthoringData.data['ifc_element_type']}",
|
||||||
)
|
)
|
||||||
op.ifc_element_type = AuthoringData.data["ifc_element_type"]
|
op.ifc_element_type = AuthoringData.data["ifc_element_type"]
|
||||||
|
|
||||||
@@ -483,9 +483,7 @@ class CreateObjectUI:
|
|||||||
row = box.row(align=True)
|
row = box.row(align=True)
|
||||||
if AuthoringData.data["type_thumbnail"] and ui_context == "TOOL_HEADER":
|
if AuthoringData.data["type_thumbnail"] and ui_context == "TOOL_HEADER":
|
||||||
row.template_icon(icon_value=AuthoringData.data["type_thumbnail"])
|
row.template_icon(icon_value=AuthoringData.data["type_thumbnail"])
|
||||||
row.operator(
|
row.operator("bim.launch_type_manager", text=AuthoringData.data["relating_type_name"], emboss=False)
|
||||||
"bim.launch_type_manager", text=AuthoringData.data["relating_type_name"], emboss=False
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
row.operator(
|
row.operator(
|
||||||
"bim.launch_type_manager",
|
"bim.launch_type_manager",
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class LoadProfiles(bpy.types.Operator):
|
|||||||
for profile in tool.Ifc.get().by_type("IfcProfileDef"):
|
for profile in tool.Ifc.get().by_type("IfcProfileDef"):
|
||||||
if filter_material_profiles:
|
if filter_material_profiles:
|
||||||
inverse_references = tool.Ifc.get().get_inverse(profile)
|
inverse_references = tool.Ifc.get().get_inverse(profile)
|
||||||
related_material_profiles = [ref for ref in inverse_references if ref.is_a('IfcMaterialProfile')]
|
related_material_profiles = [ref for ref in inverse_references if ref.is_a("IfcMaterialProfile")]
|
||||||
if not related_material_profiles:
|
if not related_material_profiles:
|
||||||
continue
|
continue
|
||||||
if not profile.ProfileName:
|
if not profile.ProfileName:
|
||||||
|
|||||||
@@ -70,12 +70,10 @@ class BIMProfileProperties(PropertyGroup):
|
|||||||
name="Filter Material Profiles",
|
name="Filter Material Profiles",
|
||||||
default=False,
|
default=False,
|
||||||
description="Check to only show IfcProfileDefs attached to IfcMaterialProfiles",
|
description="Check to only show IfcProfileDefs attached to IfcMaterialProfiles",
|
||||||
update=lambda self, context: bpy.ops.bim.load_profiles()
|
update=lambda self, context: bpy.ops.bim.load_profiles(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def generate_thumbnail_for_active_profile():
|
def generate_thumbnail_for_active_profile():
|
||||||
from PIL import Image, ImageDraw
|
from PIL import Image, ImageDraw
|
||||||
|
|
||||||
|
|||||||
@@ -367,7 +367,9 @@ class MeasureDecorator:
|
|||||||
return
|
return
|
||||||
center = sum(polyline_verts, Vector()) / len(polyline_verts) # Center between all polyline points
|
center = sum(polyline_verts, Vector()) / len(polyline_verts) # Center between all polyline points
|
||||||
if polyline_verts[0] == polyline_verts[-1]:
|
if polyline_verts[0] == polyline_verts[-1]:
|
||||||
center = sum(polyline_verts[:-1], Vector()) / len(polyline_verts[:-1]) # Doesn't use the last point if is a closed polyline
|
center = sum(polyline_verts[:-1], Vector()) / len(
|
||||||
|
polyline_verts[:-1]
|
||||||
|
) # Doesn't use the last point if is a closed polyline
|
||||||
area_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, center)
|
area_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, center)
|
||||||
value = polyline_data.area
|
value = polyline_data.area
|
||||||
text = f"area: {value}"
|
text = f"area: {value}"
|
||||||
|
|||||||
@@ -1471,7 +1471,7 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
if not (obj := item_obj.obj):
|
if not (obj := item_obj.obj):
|
||||||
continue
|
continue
|
||||||
item = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
|
item = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
|
||||||
if (is_swept_area := item.is_a("IfcSweptAreaSolid")):
|
if is_swept_area := item.is_a("IfcSweptAreaSolid"):
|
||||||
if not tool.Ifc.is_moved(obj):
|
if not tool.Ifc.is_moved(obj):
|
||||||
continue
|
continue
|
||||||
has_changed = True
|
has_changed = True
|
||||||
@@ -1529,7 +1529,7 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
|
|
||||||
obj.matrix_world = rep_obj.matrix_world.copy()
|
obj.matrix_world = rep_obj.matrix_world.copy()
|
||||||
|
|
||||||
if (is_swept_area := item.is_a("IfcSweptAreaSolid")):
|
if is_swept_area := item.is_a("IfcSweptAreaSolid"):
|
||||||
position = item.Position
|
position = item.Position
|
||||||
# Positional is optional only for SweptAreaSolid.
|
# Positional is optional only for SweptAreaSolid.
|
||||||
if position or not is_swept_area:
|
if position or not is_swept_area:
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ class Polyline(bonsai.core.tool.Polyline):
|
|||||||
orientation_angle = 0
|
orientation_angle = 0
|
||||||
if input_ui:
|
if input_ui:
|
||||||
if should_round:
|
if should_round:
|
||||||
angle = 5 * round(angle/5)
|
angle = 5 * round(angle / 5)
|
||||||
factor = tool.Snap.get_increment_snap_value(context)
|
factor = tool.Snap.get_increment_snap_value(context)
|
||||||
distance = factor * round(distance / factor)
|
distance = factor * round(distance / factor)
|
||||||
input_ui.set_value("X", snap_vector.x)
|
input_ui.set_value("X", snap_vector.x)
|
||||||
@@ -234,7 +234,7 @@ class Polyline(bonsai.core.tool.Polyline):
|
|||||||
|
|
||||||
area = input_ui.get_number_value("AREA")
|
area = input_ui.get_number_value("AREA")
|
||||||
if area:
|
if area:
|
||||||
area = tool.Polyline.format_input_ui_units(area, is_area = True)
|
area = tool.Polyline.format_input_ui_units(area, is_area=True)
|
||||||
polyline_data.area = area
|
polyline_data.area = area
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -528,7 +528,14 @@ class Polyline(bonsai.core.tool.Polyline):
|
|||||||
if bpy.context.scene.unit_settings.length_unit == "MILLIMETERS":
|
if bpy.context.scene.unit_settings.length_unit == "MILLIMETERS":
|
||||||
factor = 1000
|
factor = 1000
|
||||||
|
|
||||||
return format_distance(value * factor, precision=precision, hide_units=False, isArea=is_area, suppress_zero_inches=True, in_unit_length=True)
|
return format_distance(
|
||||||
|
value * factor,
|
||||||
|
precision=precision,
|
||||||
|
hide_units=False,
|
||||||
|
isArea=is_area,
|
||||||
|
suppress_zero_inches=True,
|
||||||
|
in_unit_length=True,
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def insert_polyline_point(cls, input_ui, tool_state=None):
|
def insert_polyline_point(cls, input_ui, tool_state=None):
|
||||||
@@ -588,7 +595,6 @@ class Polyline(bonsai.core.tool.Polyline):
|
|||||||
total_length = tool.Polyline.format_input_ui_units(total_length)
|
total_length = tool.Polyline.format_input_ui_units(total_length)
|
||||||
polyline_data.total_length = total_length
|
polyline_data.total_length = total_length
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def close_polyline(cls):
|
def close_polyline(cls):
|
||||||
polyline_data = bpy.context.scene.BIMPolylineProperties.insertion_polyline
|
polyline_data = bpy.context.scene.BIMPolylineProperties.insertion_polyline
|
||||||
|
|||||||
@@ -211,7 +211,6 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
if is_on_rot_axis:
|
if is_on_rot_axis:
|
||||||
elegible_axis.append((abs(proximity), axis))
|
elegible_axis.append((abs(proximity), axis))
|
||||||
|
|
||||||
|
|
||||||
# Get the elegible axis with the lowest proximity
|
# Get the elegible axis with the lowest proximity
|
||||||
if elegible_axis:
|
if elegible_axis:
|
||||||
proximity, axis = sorted(elegible_axis)[0]
|
proximity, axis = sorted(elegible_axis)[0]
|
||||||
@@ -507,7 +506,7 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def modify_snapping_point_selection(cls, snapping_points, lock_axis=False):
|
def modify_snapping_point_selection(cls, snapping_points, lock_axis=False):
|
||||||
shifted_list = snapping_points[1:] + snapping_points[:1]
|
shifted_list = snapping_points[1:] + snapping_points[:1]
|
||||||
if lock_axis: # Will only cycle through mix or axis
|
if lock_axis: # Will only cycle through mix or axis
|
||||||
non_axis_snap = [point for point in snapping_points if point[1] not in {"Axis", "Mix"}]
|
non_axis_snap = [point for point in snapping_points if point[1] not in {"Axis", "Mix"}]
|
||||||
axis_snap = [point for point in snapping_points if point[1] in {"Axis", "Mix"}]
|
axis_snap = [point for point in snapping_points if point[1] in {"Axis", "Mix"}]
|
||||||
shifted_list = axis_snap[1:] + axis_snap[:1]
|
shifted_list = axis_snap[1:] + axis_snap[:1]
|
||||||
|
|||||||
Reference in New Issue
Block a user