mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Minor refactor
This commit is contained in:
@@ -688,23 +688,10 @@ class DumbWallGenerator:
|
||||
for stroke in layer.active_frame.strokes:
|
||||
if len(stroke.points) == 1:
|
||||
continue
|
||||
coords = (stroke.points[0].co, stroke.points[-1].co)
|
||||
direction = coords[1] - coords[0]
|
||||
length = direction.length
|
||||
if length < 0.1:
|
||||
continue
|
||||
data = {"coords": coords}
|
||||
|
||||
# Round to nearest 50mm (yes, metric for now)
|
||||
self.length = 0.05 * round(length / 0.05)
|
||||
self.rotation = math.atan2(direction[1], direction[0])
|
||||
# Round to nearest 5 degrees
|
||||
nearest_degree = (math.pi / 180) * 5
|
||||
self.rotation = nearest_degree * round(self.rotation / nearest_degree)
|
||||
self.location = coords[0]
|
||||
data["obj"] = self.create_wall()
|
||||
strokes.append(data)
|
||||
objs.append(data["obj"])
|
||||
data = self.create_wall_from_2_points((stroke.points[0].co, stroke.points[-1].co))
|
||||
if data:
|
||||
strokes.append(data)
|
||||
objs.append(data["obj"])
|
||||
|
||||
if len(objs) < 2:
|
||||
return objs
|
||||
@@ -726,6 +713,23 @@ class DumbWallGenerator:
|
||||
bpy.context.scene.grease_pencil.layers.remove(layer)
|
||||
return objs
|
||||
|
||||
def create_wall_from_2_points(self, coords):
|
||||
direction = coords[1] - coords[0]
|
||||
length = direction.length
|
||||
if length < 0.1:
|
||||
return
|
||||
data = {"coords": coords}
|
||||
|
||||
# Round to nearest 50mm (yes, metric for now)
|
||||
self.length = 0.05 * round(length / 0.05)
|
||||
self.rotation = math.atan2(direction[1], direction[0])
|
||||
# Round to nearest 5 degrees
|
||||
nearest_degree = (math.pi / 180) * 5
|
||||
self.rotation = nearest_degree * round(self.rotation / nearest_degree)
|
||||
self.location = coords[0]
|
||||
data["obj"] = self.create_wall()
|
||||
return data
|
||||
|
||||
def has_end_near_stroke(self, stroke, stroke2):
|
||||
point, distance = mathutils.geometry.intersect_point_line(stroke["coords"][0], *stroke2["coords"])
|
||||
if distance > 0 and distance < 1 and self.is_near(point, stroke["coords"][0]):
|
||||
|
||||
Reference in New Issue
Block a user