This commit is contained in:
Andrej730
2024-10-14 12:23:20 +05:00
parent 9ccbd332cf
commit 5ffef568f7
10 changed files with 33 additions and 24 deletions
@@ -590,7 +590,9 @@ class PolylineDecorator:
return
center = sum(polyline_verts, Vector()) / len(polyline_verts) # Center between all polyline points
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)
value = polyline_data.area
text = f"area: {value}"
@@ -304,7 +304,9 @@ class PolylineOperator:
def handle_snap_selection(self, context, event):
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)
PolylineDecorator.update(event, self.tool_state, self.input_ui, self.snapping_points[0])
tool.Blender.update_viewport()
@@ -355,7 +357,9 @@ class PolylineOperator:
if self.snapping_points[0][1] in {"Plane", "Axis"}:
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:
tool.Polyline.calculate_x_y_and_z(context, self.input_ui, self.tool_state)
tool.Blender.update_viewport()
@@ -404,7 +404,7 @@ class CreateObjectUI:
op = row.operator(
"bim.add_default_type",
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"]
@@ -483,9 +483,7 @@ class CreateObjectUI:
row = box.row(align=True)
if AuthoringData.data["type_thumbnail"] and ui_context == "TOOL_HEADER":
row.template_icon(icon_value=AuthoringData.data["type_thumbnail"])
row.operator(
"bim.launch_type_manager", text=AuthoringData.data["relating_type_name"], emboss=False
)
row.operator("bim.launch_type_manager", text=AuthoringData.data["relating_type_name"], emboss=False)
else:
row.operator(
"bim.launch_type_manager",
@@ -42,7 +42,7 @@ class LoadProfiles(bpy.types.Operator):
for profile in tool.Ifc.get().by_type("IfcProfileDef"):
if filter_material_profiles:
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:
continue
if not profile.ProfileName:
+1 -3
View File
@@ -70,12 +70,10 @@ class BIMProfileProperties(PropertyGroup):
name="Filter Material Profiles",
default=False,
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():
from PIL import Image, ImageDraw
+1 -1
View File
@@ -83,7 +83,7 @@ class BIM_PT_profiles(Panel):
self.props,
"active_profile_index",
)
row = self.layout.row()
row.prop(self.props, "is_filtering_material_profiles", text="Filter Material Profiles")
@@ -367,7 +367,9 @@ class MeasureDecorator:
return
center = sum(polyline_verts, Vector()) / len(polyline_verts) # Center between all polyline points
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)
value = polyline_data.area
text = f"area: {value}"
+2 -2
View File
@@ -1471,7 +1471,7 @@ class Geometry(bonsai.core.tool.Geometry):
if not (obj := item_obj.obj):
continue
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):
continue
has_changed = True
@@ -1529,7 +1529,7 @@ class Geometry(bonsai.core.tool.Geometry):
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
# Positional is optional only for SweptAreaSolid.
if position or not is_swept_area:
+10 -4
View File
@@ -174,7 +174,7 @@ class Polyline(bonsai.core.tool.Polyline):
orientation_angle = 0
if input_ui:
if should_round:
angle = 5 * round(angle/5)
angle = 5 * round(angle / 5)
factor = tool.Snap.get_increment_snap_value(context)
distance = factor * round(distance / factor)
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")
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
return
@@ -528,7 +528,14 @@ class Polyline(bonsai.core.tool.Polyline):
if bpy.context.scene.unit_settings.length_unit == "MILLIMETERS":
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
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)
polyline_data.total_length = total_length
@classmethod
def close_polyline(cls):
polyline_data = bpy.context.scene.BIMPolylineProperties.insertion_polyline
+4 -5
View File
@@ -197,7 +197,7 @@ class Snap(bonsai.core.tool.Snap):
# Get axis that are closer than the stick factor threshold
elegible_axis = []
for axis in snap_axis:
if not axis:
continue
@@ -211,7 +211,6 @@ class Snap(bonsai.core.tool.Snap):
if is_on_rot_axis:
elegible_axis.append((abs(proximity), axis))
# Get the elegible axis with the lowest proximity
if elegible_axis:
proximity, axis = sorted(elegible_axis)[0]
@@ -267,7 +266,7 @@ class Snap(bonsai.core.tool.Snap):
(offset, -offset),
)
# TODO Snap like Blender snap increment. Enable this when we have a proper snap settings.
# TODO Snap like Blender snap increment. Enable this when we have a proper snap settings.
# Still need adjustments to improve the feel
def round_vector_with_increment(intersection, relative_point):
for i in range(len(intersection)):
@@ -507,11 +506,11 @@ class Snap(bonsai.core.tool.Snap):
@classmethod
def modify_snapping_point_selection(cls, snapping_points, lock_axis=False):
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"}]
axis_snap = [point for point in snapping_points if point[1] in {"Axis", "Mix"}]
shifted_list = axis_snap[1:] + axis_snap[:1]
shifted_list.extend(non_axis_snap)
cls.update_snapping_point(shifted_list[0][0], shifted_list[0][1])
return shifted_list