mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Use Blender's angle snap setting in wall.py and profile.py
Replace hardcoded 5-degree angle snapping with Blender's snap_angle_increment setting in create_wall_from_2_points() and create_profile_from_2_points(). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Bruno Perdigão
parent
067e04b564
commit
740fcf7768
@@ -17,7 +17,7 @@
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
from math import atan2, degrees, pi
|
||||
from math import atan2, degrees, pi, radians
|
||||
from typing import Any, Literal, Optional, Union
|
||||
|
||||
import bmesh
|
||||
@@ -195,8 +195,8 @@ class DumbProfileGenerator:
|
||||
if should_round:
|
||||
# Round to nearest 50mm (yes, metric for now)
|
||||
self.length = 0.05 * round(length / 0.05)
|
||||
# Round to nearest 5 degrees
|
||||
nearest_degree = (pi / 180) * 5
|
||||
angle_snap = tool.Snap.get_angle_snap_value(bpy.context)
|
||||
nearest_degree = radians(angle_snap)
|
||||
self.rotation = nearest_degree * round(self.rotation / nearest_degree)
|
||||
self.location = coords[0]
|
||||
data["obj"] = self.create_profile()
|
||||
|
||||
@@ -916,8 +916,8 @@ class DumbWallGenerator:
|
||||
if should_round:
|
||||
# Round to nearest 50mm (yes, metric for now)
|
||||
self.length = 0.05 * round(length / 0.05)
|
||||
# Round to nearest 5 degrees
|
||||
nearest_degree = (math.pi / 180) * 5
|
||||
angle_snap = tool.Snap.get_angle_snap_value(bpy.context)
|
||||
nearest_degree = math.radians(angle_snap)
|
||||
self.rotation = nearest_degree * round(self.rotation / nearest_degree)
|
||||
self.location = coords[0]
|
||||
data["obj"] = self.create_wall()
|
||||
|
||||
@@ -118,10 +118,14 @@ class Snap(bonsai.core.tool.Snap):
|
||||
def get_angle_snap_value(cls, context: bpy.types.Context) -> float:
|
||||
"""Get the angle snap increment from Blender's tool settings.
|
||||
|
||||
Uses snap_angle_increment_3d (Blender 5.0+) or snap_angle_increment (Blender 4.x).
|
||||
|
||||
:param context: Blender context
|
||||
:return: Angle snap increment in degrees
|
||||
"""
|
||||
return context.scene.tool_settings.snap_angle_increment
|
||||
if bpy.app.version >= (5, 0, 0):
|
||||
return math.degrees(context.scene.tool_settings.snap_angle_increment_3d)
|
||||
return math.degrees(context.scene.tool_settings.snap_angle_increment)
|
||||
|
||||
@classmethod
|
||||
def get_snap_points_on_raycasted_face(cls, context, event, obj, face_index):
|
||||
|
||||
Reference in New Issue
Block a user