mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 10:43:46 +00:00
Added option for wall_from_to_points not round the length and angle.
This function was hard coded to round length angle, now it has an option. I assume it was originally built like this because it was supposed to work only with Grease Pencil.
This commit is contained in:
@@ -700,7 +700,7 @@ class DumbWallGenerator:
|
|||||||
for stroke in layer.active_frame.strokes:
|
for stroke in layer.active_frame.strokes:
|
||||||
if len(stroke.points) == 1:
|
if len(stroke.points) == 1:
|
||||||
continue
|
continue
|
||||||
data = self.create_wall_from_2_points((stroke.points[0].co, stroke.points[-1].co))
|
data = self.create_wall_from_2_points((stroke.points[0].co, stroke.points[-1].co), round=True)
|
||||||
if data:
|
if data:
|
||||||
strokes.append(data)
|
strokes.append(data)
|
||||||
objs.append(data["obj"])
|
objs.append(data["obj"])
|
||||||
@@ -725,19 +725,21 @@ 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):
|
def create_wall_from_2_points(self, coords, round=False):
|
||||||
direction = coords[1] - coords[0]
|
direction = coords[1] - coords[0]
|
||||||
length = direction.length
|
length = direction.length
|
||||||
if length < 0.1:
|
if length < 0.1:
|
||||||
return
|
return
|
||||||
data = {"coords": coords}
|
data = {"coords": coords}
|
||||||
|
|
||||||
# Round to nearest 50mm (yes, metric for now)
|
self.length = length
|
||||||
self.length = 0.05 * round(length / 0.05)
|
|
||||||
self.rotation = math.atan2(direction[1], direction[0])
|
self.rotation = math.atan2(direction[1], direction[0])
|
||||||
# Round to nearest 5 degrees
|
if round:
|
||||||
nearest_degree = (math.pi / 180) * 5
|
# Round to nearest 50mm (yes, metric for now)
|
||||||
self.rotation = nearest_degree * round(self.rotation / nearest_degree)
|
self.length = 0.05 * round(length / 0.05)
|
||||||
|
# Round to nearest 5 degrees
|
||||||
|
nearest_degree = (math.pi / 180) * 5
|
||||||
|
self.rotation = nearest_degree * round(self.rotation / nearest_degree)
|
||||||
self.location = coords[0]
|
self.location = coords[0]
|
||||||
data["obj"] = self.create_wall()
|
data["obj"] = self.create_wall()
|
||||||
return data
|
return data
|
||||||
|
|||||||
Reference in New Issue
Block a user