mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 06:00:51 +00:00
Bends - replace faceset with simple extrusion
This commit is contained in:
@@ -111,7 +111,7 @@ class Usecase:
|
|||||||
support_disk_circle = builder.circle(radius=support_disk_radius)
|
support_disk_circle = builder.circle(radius=support_disk_radius)
|
||||||
|
|
||||||
angle = V(0, 1).angle_signed(ortho_dir.xy)
|
angle = V(0, 1).angle_signed(ortho_dir.xy)
|
||||||
y_extrusion_kwargs = builder.rotate_extrusion_kwargs_by_z(builder.extrude_by_y_kwargs(), angle)
|
y_extrusion_kwargs = builder.rotate_extrusion_kwargs_by_z(builder.extrude_kwargs("Y"), angle)
|
||||||
support_disk = builder.extrude(
|
support_disk = builder.extrude(
|
||||||
support_disk_circle, support_disk_depth, position=support_points[-1], **y_extrusion_kwargs
|
support_disk_circle, support_disk_depth, position=support_points[-1], **y_extrusion_kwargs
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -624,17 +624,36 @@ class ShapeBuilder:
|
|||||||
return ifcopenshell.util.element.copy_deep(self.file, element)
|
return ifcopenshell.util.element.copy_deep(self.file, element)
|
||||||
|
|
||||||
# UTILITIES
|
# UTILITIES
|
||||||
def extrude_by_y_kwargs(self):
|
def extrude_kwargs(self, axis):
|
||||||
"""Shortcut to get kwargs for `ShapeBuilder.extrude` to extrude by Y axis.
|
"""Shortcut to get kwargs for `ShapeBuilder.extrude` to extrude by some axis.
|
||||||
|
|
||||||
It assumes you have 2D profile in XZ plane and trying to extrude it by Y axis.
|
It assumes you have 2D profile in:
|
||||||
|
XZ plane for Y axis extrusion, \n
|
||||||
|
YZ plane for X axis extrusion, \n
|
||||||
|
XY plane for Z axis extrusion, \n
|
||||||
|
|
||||||
Extruding by Y using other kwargs might break ValidExtrusionDirection."""
|
Extruding by X/Y using other kwargs might break ValidExtrusionDirection."""
|
||||||
return {
|
|
||||||
"position_x_axis": Vector((1, 0, 0)),
|
axis = axis.upper()
|
||||||
"position_z_axis": Vector((0, -1, 0)),
|
|
||||||
"extrusion_vector": Vector((0, 0, -1)),
|
if axis == "Y":
|
||||||
}
|
return {
|
||||||
|
"position_x_axis": Vector((1, 0, 0)),
|
||||||
|
"position_z_axis": Vector((0, -1, 0)),
|
||||||
|
"extrusion_vector": Vector((0, 0, -1)),
|
||||||
|
}
|
||||||
|
elif axis == "X":
|
||||||
|
return {
|
||||||
|
"position_x_axis": Vector((0, 1, 0)),
|
||||||
|
"position_z_axis": Vector((1, 0, 0)),
|
||||||
|
"extrusion_vector": Vector((0, 0, 1)),
|
||||||
|
}
|
||||||
|
elif axis == "Z":
|
||||||
|
return {
|
||||||
|
"position_x_axis": Vector((1, 0, 0)),
|
||||||
|
"position_z_axis": Vector((0, 0, 1)),
|
||||||
|
"extrusion_vector": Vector((0, 0, 1)),
|
||||||
|
}
|
||||||
|
|
||||||
def rotate_extrusion_kwargs_by_z(self, kwargs, angle, counter_clockwise=False):
|
def rotate_extrusion_kwargs_by_z(self, kwargs, angle, counter_clockwise=False):
|
||||||
"""shortcut to rotate extrusion kwargs by z axis
|
"""shortcut to rotate extrusion kwargs by z axis
|
||||||
@@ -1370,20 +1389,18 @@ class ShapeBuilder:
|
|||||||
|
|
||||||
points = inner_points + outer_points[::-1]
|
points = inner_points + outer_points[::-1]
|
||||||
points = [p + O for p in points]
|
points = [p + O for p in points]
|
||||||
offset = V(0, 0, 0)
|
|
||||||
|
|
||||||
if is_circular_profile:
|
if is_circular_profile:
|
||||||
bend_path = self.polyline(points, closed=False, arc_points=[1])
|
bend_path = self.polyline(points, closed=False, arc_points=[1])
|
||||||
bend = self.create_swept_disk_solid(bend_path, profile_dim[lateral_axis])
|
bend = self.create_swept_disk_solid(bend_path, profile_dim[lateral_axis])
|
||||||
else:
|
else:
|
||||||
|
main_axes = lambda v: getattr(v, "xy"[lateral_axis] + "z")
|
||||||
|
offset = V(0, 0, 0)
|
||||||
offset[non_lateral_axis] = -profile_dim[non_lateral_axis]
|
offset[non_lateral_axis] = -profile_dim[non_lateral_axis]
|
||||||
extrusion_vector = V(0, 0, 0)
|
extrusion_kwargs = self.extrude_kwargs("XY"[non_lateral_axis])
|
||||||
extrusion_vector[non_lateral_axis] = 1
|
profile_curve = self.polyline([main_axes(p) for p in points], closed=True)
|
||||||
bend = self.extrude_face_set(
|
bend = self.extrude(
|
||||||
points,
|
self.profile(profile_curve), profile_dim[non_lateral_axis] * 2, position=offset, **extrusion_kwargs
|
||||||
magnitude=profile_dim[non_lateral_axis] * 2,
|
|
||||||
offset=offset,
|
|
||||||
extrusion_vector=extrusion_vector,
|
|
||||||
)
|
)
|
||||||
return bend
|
return bend
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user