-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
help wantedExtra attention is neededExtra attention is needed
Description
Hi There,
I am trying to create a MEP Rectangle around an existing rectangular beam. My problem is that create_rectangular_mep is using the points to define a polyline axis, not to define a coordinate system like create_rectangular_panel_points. So if my beam is not aligned to with world Z, the beam and MEP are misaligned.
260209_MEP-rect_around_beam.zip
Attached code and test file.
import cadwork
import element_controller as ec
import geometry_controller as gc
import attribute_controller as ac
# MEP cross-section (adjust to your needs)
MEP_WIDTH = 500.0 # width of the rectangular duct
MEP_DEPTH = 300.0 # depth of the rectangular duct
def create_rectangular_mep_from_beam(beam_id: int, mep_width: float, mep_depth: float) -> int | None:
"""
Create a rectangular MEP along the beam's coordinate system.
Parameters:
beam_id: Element ID of the rectangular beam.
mep_width: Width of the rectangular MEP cross-section.
mep_depth: Depth of the rectangular MEP cross-section.
Returns:
Element ID of the created MEP, or None if the element is not a rectangular beam.
"""
element_type = ac.get_element_type(beam_id)
if not element_type.is_rectangular_beam():
return None
p1 = gc.get_p1(beam_id)
p2 = gc.get_p2(beam_id)
p3 = gc.get_p3(beam_id)
axis_points = [p1, p2]
# with `axis_points = [p1, p2, p3]`, the third point is used to create a polyline axis
return ec.create_rectangular_mep(mep_width, mep_depth, axis_points)
#return ec.create_rectangular_panel_points(mep_width, mep_depth, p1, p2, p3)
def main() -> None:
element_ids = ec.get_active_identifiable_element_ids()
if not element_ids:
print("No elements selected. Select one or more rectangular beams.")
return
for element_id in element_ids:
mep_id = create_rectangular_mep_from_beam(element_id, MEP_WIDTH, MEP_DEPTH)
if __name__ == "__main__":
main()Any workaround ? Thanks !
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed