This commit is contained in:
Andrej730
2025-03-12 16:12:21 +05:00
parent a941eb3f90
commit dfd30fbcaa
7 changed files with 32 additions and 22 deletions
@@ -502,7 +502,13 @@ class BaseDecorator:
precision = drawing_pset_data.get("ImperialPrecision", None)
decimal_places = drawing_pset_data.get("DecimalPlaces", None)
return format_distance(value, precision=precision, decimal_places=decimal_places, suppress_zero_inches=True, custom_unit=custom_unit)
return format_distance(
value,
precision=precision,
decimal_places=decimal_places,
suppress_zero_inches=True,
custom_unit=custom_unit,
)
def draw_asterisk(self, context: bpy.types.Context, pos: Vector, rotation: float = 0.0, scale: float = 1.0) -> None:
"""`pos` is a world space position\n
+10 -10
View File
@@ -164,15 +164,15 @@ def format_distance(
# Custom Unit Settings
if custom_unit:
unit_mapping = {
"Feet and Inches - Fractional": ("IMPERIAL", "FEET", True),
"Feet - Decimal": ("IMPERIAL", "FEET", False),
"Inches - Fractional": ("IMPERIAL", "INCHES", True),
"Inches - Decimal": ("IMPERIAL", "INCHES", False),
"Meters": ("METRIC", "METERS", False),
"Decimeters": ("METRIC", "DECIMETERS", False),
"Centimeters": ("METRIC", "CENTIMETERS", False),
"Millimeters": ("METRIC", "MILLIMETERS", False),
}
"Feet and Inches - Fractional": ("IMPERIAL", "FEET", True),
"Feet - Decimal": ("IMPERIAL", "FEET", False),
"Inches - Fractional": ("IMPERIAL", "INCHES", True),
"Inches - Decimal": ("IMPERIAL", "INCHES", False),
"Meters": ("METRIC", "METERS", False),
"Decimeters": ("METRIC", "DECIMETERS", False),
"Centimeters": ("METRIC", "CENTIMETERS", False),
"Millimeters": ("METRIC", "MILLIMETERS", False),
}
if custom_unit in unit_mapping:
unit_system, unit_length, unit_fraction = unit_mapping[custom_unit]
@@ -204,7 +204,7 @@ def format_distance(
# Separate ft and inches
# Unless Inches are the specified Length Unit or unit_fraction is False
if (unit_length == "FEET" and not unit_fraction):
if unit_length == "FEET" and not unit_fraction:
feet = round(decInches / inPerFoot, 3) # keep decimal
decInches = 0
elif unit_length != "INCHES":
@@ -1128,7 +1128,12 @@ class SvgWriter:
def get_text():
radius = (points[-1].co - points[-2].co).length
radius = helper.format_distance(radius, precision=self.precision, decimal_places=self.decimal_places, custom_unit=dimension_data["custom_unit"])
radius = helper.format_distance(
radius,
precision=self.precision,
decimal_places=self.decimal_places,
custom_unit=dimension_data["custom_unit"],
)
text = f"R{radius}"
return text
@@ -1256,7 +1261,7 @@ class SvgWriter:
text_prefix=dimension_data["text_prefix"],
text_suffix=dimension_data["text_suffix"],
fill_bg=dimension_data["fill_bg"],
custom_unit=dimension_data["custom_unit"]
custom_unit=dimension_data["custom_unit"],
)
def draw_dimension_annotations(self, obj):
@@ -809,7 +809,9 @@ class PolylineOperator:
if len(polyline_points) > 2:
first_point = polyline_points[0]
last_point = polyline_points[-1]
if not (first_point.x == last_point.x and first_point.y == last_point.y and first_point.z == last_point.z):
if not (
first_point.x == last_point.x and first_point.y == last_point.y and first_point.z == last_point.z
):
self.input_ui.set_value("X", first_point.x)
self.input_ui.set_value("Y", first_point.y)
if self.input_ui.get_number_value("Z") is not None:
+1 -3
View File
@@ -64,9 +64,7 @@ class Debug(bonsai.core.tool.Debug):
pass
@classmethod
def debug_bmesh(
cls, bm: bpy.types.BMesh, name: str = "Debug"
) -> bpy.types.Object:
def debug_bmesh(cls, bm: bpy.types.BMesh, name: str = "Debug") -> bpy.types.Object:
mesh = bpy.data.meshes.new("Debug")
bm.to_mesh(mesh)
obj = bpy.data.objects.new(name, mesh)
+1 -2
View File
@@ -130,7 +130,6 @@ class Polyline(bonsai.core.tool.Polyline):
else:
default_container_elevation = 0
mouse_point = context.scene.BIMPolylineProperties.snap_mouse_point[0]
if last_point_data:
@@ -273,7 +272,7 @@ class Polyline(bonsai.core.tool.Polyline):
else:
polyline_points = []
last_point = Vector((0, 0, 0))
if tool.Ifc.get():
default_container_elevation = tool.Ifc.get_object(tool.Root.get_default_container()).location.z
else:
+3 -3
View File
@@ -377,9 +377,9 @@ class Snap(bonsai.core.tool.Snap):
for obj, bbox_2d in objs_2d_bbox:
if obj.type in {"MESH", "EMPTY", "CURVE"} and bbox_2d:
if tool.Raycast.intersect_mouse_2d_bounding_box(mouse_pos, bbox_2d, offset):
if obj.visible_in_viewport_get(
context.space_data
) or obj.library: # Check for local view and local collections for this viewport and object
if (
obj.visible_in_viewport_get(context.space_data) or obj.library
): # Check for local view and local collections for this viewport and object
objs_to_raycast.append(obj)
# Polyline