This commit is contained in:
Bruno Perdigão
2024-09-24 11:40:47 -03:00
parent 209c0fef57
commit c4232e7407
2 changed files with 4 additions and 6 deletions
+3 -3
View File
@@ -569,16 +569,16 @@ class DumbWallGenerator:
bpy.context.scene.grease_pencil.layers.remove(layer) bpy.context.scene.grease_pencil.layers.remove(layer)
return objs return objs
def create_wall_from_2_points(self, coords, round=False): def create_wall_from_2_points(self, coords, should_round=False):
direction = coords[1] - coords[0] direction = coords[1] - coords[0]
length = direction.length length = direction.length
if length < 0.1: if round(length, 4) < 0.1:
return return
data = {"coords": coords} data = {"coords": coords}
self.length = length self.length = length
self.rotation = math.atan2(direction[1], direction[0]) self.rotation = math.atan2(direction[1], direction[0])
if round: if should_round:
# Round to nearest 50mm (yes, metric for now) # Round to nearest 50mm (yes, metric for now)
self.length = 0.05 * round(length / 0.05) self.length = 0.05 * round(length / 0.05)
# Round to nearest 5 degrees # Round to nearest 5 degrees
+1 -3
View File
@@ -140,13 +140,11 @@ class Snap(bonsai.core.tool.Snap):
for point in polyline_data[1:]: # The first can be repeated to form a wall loop for point in polyline_data[1:]: # The first can be repeated to form a wall loop
if (x, y, z) == (point.x, point.y, point.z): if (x, y, z) == (point.x, point.y, point.z):
return "Cannot create two points at the same location" return "Cannot create two points at the same location"
print(type(snap_vertex))
print(type(polyline_data[-1]))
# Avoids creating segments smaller then 0.1. This is a limitation from create_wall_from_2_points # Avoids creating segments smaller then 0.1. This is a limitation from create_wall_from_2_points
length = ( length = (
Vector((x, y, z)) - Vector((polyline_data[-1].x, polyline_data[-1].y, polyline_data[-1].z)) Vector((x, y, z)) - Vector((polyline_data[-1].x, polyline_data[-1].y, polyline_data[-1].z))
).length ).length
if length < 0.1: if round(length, 4) < 0.1:
return "Cannot create a segment smaller then 10cm" return "Cannot create a segment smaller then 10cm"
polyline_point = bpy.context.scene.BIMPolylineProperties.polyline_point.add() polyline_point = bpy.context.scene.BIMPolylineProperties.polyline_point.add()