2525from pathlib import Path
2626from typing import Union
2727
28+ from ansys .geometry .core .shapes .curves .trimmed_curve import TrimmedCurve
29+ from ansys .geometry .core .shapes .parameterization import Interval , ParamUV
2830from beartype import beartype as check_input_types
2931from google .protobuf .empty_pb2 import Empty
3032import numpy as np
5759from ansys .api .geometry .v0 .parts_pb2_grpc import PartsStub
5860from ansys .geometry .core .connection .backend import BackendType
5961from ansys .geometry .core .connection .conversions import (
62+ grpc_curve_to_curve ,
6063 grpc_frame_to_frame ,
64+ grpc_material_to_material ,
6165 grpc_matrix_to_matrix ,
6266 grpc_point_to_point3d ,
6367 plane_to_grpc_plane ,
6468 point3d_to_grpc_point ,
6569)
66- from ansys .geometry .core .designer .beam import Beam , BeamCircularProfile , BeamProfile
70+ from ansys .geometry .core .designer .beam import Beam , BeamCircularProfile , BeamCrossSectionInfo , BeamProfile , BeamProperties , SectionAnchorType
6771from ansys .geometry .core .designer .body import Body , MasterBody , MidSurfaceOffsetType
6872from ansys .geometry .core .designer .component import Component , SharedTopologyType
6973from ansys .geometry .core .designer .coordinate_system import CoordinateSystem
@@ -1138,6 +1142,53 @@ def __read_existing_design(self) -> None:
11381142 m = Material (material .name , density , properties )
11391143 self .materials .append (m )
11401144
1145+ # Create Beams
1146+ for beam in response .beams :
1147+ cross_section = BeamCrossSectionInfo (
1148+ SectionAnchorType (beam .cross_section .section_anchor ),
1149+ beam .cross_section .section_angle ,
1150+ grpc_frame_to_frame (beam .cross_section .section_frame ),
1151+ [
1152+ [TrimmedCurve (
1153+ grpc_curve_to_curve (curve .curve ),
1154+ grpc_point_to_point3d (curve .start ),
1155+ grpc_point_to_point3d (curve .end ),
1156+ Interval (curve .interval_start , curve .interval_end ),
1157+ curve .length ) for curve in curve_list .curves ]
1158+ for curve_list in beam .cross_section .section_profile ],
1159+ )
1160+ properties = BeamProperties (
1161+ beam .properties .area ,
1162+ ParamUV (beam .properties .centroid_x , beam .properties .centroid_y ),
1163+ beam .properties .warping_constant ,
1164+ beam .properties .ixx ,
1165+ beam .properties .ixy ,
1166+ beam .properties .iyy ,
1167+ ParamUV (beam .properties .shear_center_x , beam .properties .shear_center_y ),
1168+ beam .properties .torsional_constant ,
1169+ )
1170+
1171+ new_beam = Beam (
1172+ beam .id .id ,
1173+ grpc_point_to_point3d (beam .shape .start ),
1174+ grpc_point_to_point3d (beam .shape .end ),
1175+ None ,
1176+ # TODO: Beams need BeamProfiles imported from existing design
1177+ # https://github.com/ansys/pyansys-geometry/issues/1825
1178+ self ,
1179+ beam .name ,
1180+ beam .is_deleted ,
1181+ beam .is_reversed ,
1182+ beam .is_rigid ,
1183+ grpc_material_to_material (beam .material ),
1184+ cross_section ,
1185+ properties ,
1186+ beam .shape ,
1187+ beam .type ,
1188+ )
1189+
1190+ self ._beams .append (new_beam )
1191+
11411192 # Create NamedSelections
11421193 for ns in response .named_selections :
11431194 result = self ._named_selections_stub .Get (EntityIdentifier (id = ns .id ))
@@ -1146,8 +1197,7 @@ def __read_existing_design(self) -> None:
11461197 bodies = get_bodies_from_ids (self , [body .id for body in result .bodies ])
11471198 faces = get_faces_from_ids (self , [face .id for face in result .faces ])
11481199 edges = get_edges_from_ids (self , [edge .id for edge in result .edges ])
1149- beams = get_beams_from_ids (self , [beam .id for beam in result .beams ])
1150- print (result .beams )
1200+ beams = get_beams_from_ids (self , [beam .id .id for beam in result .beams ])
11511201
11521202 design_points = []
11531203 for dp in result .design_points :
@@ -1167,15 +1217,6 @@ def __read_existing_design(self) -> None:
11671217 )
11681218 self ._named_selections [new_ns .name ] = new_ns
11691219
1170- # Create Beams
1171- # for beam in response.beams:
1172- # new_beam = Beam(
1173- # beam.id,
1174-
1175- # )
1176-
1177- # self._beams.append(new_beam)
1178-
11791220 # Create CoordinateSystems
11801221 num_created_coord_systems = 0
11811222 for component_id , coordinate_systems in response .component_coord_systems .items ():
0 commit comments