Skip to content

Commit ff07f5a

Browse files
wip importing beams in NS
1 parent d18ad88 commit ff07f5a

File tree

3 files changed

+51
-12
lines changed

3 files changed

+51
-12
lines changed

src/ansys/geometry/core/designer/beam.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
from enum import Enum
2525
from typing import TYPE_CHECKING
2626

27+
from beartype import beartype as check_input_types
28+
2729
from ansys.geometry.core.materials.material import Material
2830
from ansys.geometry.core.math.frame import Frame
2931
from ansys.geometry.core.math.point import Point3D
@@ -185,19 +187,15 @@ class BeamCrossSectionInfo:
185187
The section profile in the XY plane.
186188
"""
187189

190+
@check_input_types
188191
def __init__(
189192
self,
190193
section_anchor: SectionAnchorType,
191194
section_angle: float,
192195
section_frame: Frame,
193-
section_profile: BeamProfile,
196+
section_profile: list[list[TrimmedCurve]] | None,
194197
):
195198
"""Initialize ``BeamCrossSectionInfo`` class."""
196-
check_type(section_anchor, SectionAnchorType)
197-
check_type(section_angle, float)
198-
check_type(section_frame, Frame)
199-
check_type(section_profile, BeamProfile)
200-
201199
self._section_anchor = section_anchor
202200
self._section_angle = section_angle
203201
self._section_frame = section_frame

src/ansys/geometry/core/designer/component.py

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
from ansys.api.geometry.v0.models_pb2 import Direction, Line, TrimmedCurveList
5959
from ansys.geometry.core.connection.client import GrpcClient
6060
from ansys.geometry.core.connection.conversions import (
61+
grpc_curve_to_curve,
62+
grpc_frame_to_frame,
6163
grpc_material_to_material,
6264
grpc_matrix_to_matrix,
6365
grpc_point_to_point3d,
@@ -68,7 +70,13 @@
6870
trimmed_surface_to_grpc_trimmed_surface,
6971
unit_vector_to_grpc_direction,
7072
)
71-
from ansys.geometry.core.designer.beam import Beam, BeamProfile
73+
from ansys.geometry.core.designer.beam import (
74+
Beam,
75+
BeamCrossSectionInfo,
76+
BeamProfile,
77+
BeamProperties,
78+
SectionAnchorType,
79+
)
7280
from ansys.geometry.core.designer.body import Body, CollisionType, MasterBody
7381
from ansys.geometry.core.designer.coordinate_system import CoordinateSystem
7482
from ansys.geometry.core.designer.designpoint import DesignPoint
@@ -88,7 +96,7 @@
8896
from ansys.geometry.core.misc.measurements import DEFAULT_UNITS, Angle, Distance
8997
from ansys.geometry.core.shapes.curves.circle import Circle
9098
from ansys.geometry.core.shapes.curves.trimmed_curve import TrimmedCurve
91-
from ansys.geometry.core.shapes.parameterization import Interval
99+
from ansys.geometry.core.shapes.parameterization import Interval, ParamUV
92100
from ansys.geometry.core.shapes.surfaces import TrimmedSurface
93101
from ansys.geometry.core.sketch.arc import Arc
94102
from ansys.geometry.core.sketch.sketch import Sketch
@@ -1238,6 +1246,31 @@ def __create_beams(
12381246

12391247
beams = []
12401248
for beam in response.created_beams:
1249+
print(beam.cross_section.section_profile)
1250+
cross_section = BeamCrossSectionInfo(
1251+
SectionAnchorType(beam.cross_section.section_anchor),
1252+
beam.cross_section.section_angle,
1253+
grpc_frame_to_frame(beam.cross_section.section_frame),
1254+
[
1255+
[TrimmedCurve(
1256+
grpc_curve_to_curve(curve.geometry),
1257+
grpc_point_to_point3d(curve.start),
1258+
grpc_point_to_point3d(curve.end),
1259+
Interval(curve.interval_start, curve.interval_end),
1260+
curve.length) for curve in curve_list]
1261+
for curve_list in beam.cross_section.section_profile],
1262+
)
1263+
properties = BeamProperties(
1264+
beam.properties.area,
1265+
ParamUV(beam.properties.centroid_x, beam.properties.centroid_y),
1266+
beam.properties.warping_constant,
1267+
beam.properties.ixx,
1268+
beam.properties.ixy,
1269+
beam.properties.iyy,
1270+
ParamUV(beam.properties.shear_center_x, beam.properties.shear_center_y),
1271+
beam.properties.torsional_constant,
1272+
)
1273+
12411274
beams.append(
12421275
Beam(
12431276
beam.id.id,
@@ -1250,10 +1283,8 @@ def __create_beams(
12501283
beam.is_reversed,
12511284
beam.is_rigid,
12521285
grpc_material_to_material(beam.material),
1253-
None,
1254-
None,
1255-
# grpc_cross_section_to_cross_section(beam.cross_section),
1256-
# grpc_beam_properties_to_beam_properties(beam.properties),
1286+
cross_section,
1287+
properties,
12571288
beam.shape,
12581289
beam.type,
12591290
)

src/ansys/geometry/core/designer/design.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,7 @@ def __read_existing_design(self) -> None:
11471147
faces = get_faces_from_ids(self, [face.id for face in result.faces])
11481148
edges = get_edges_from_ids(self, [edge.id for edge in result.edges])
11491149
beams = get_beams_from_ids(self, [beam.id for beam in result.beams])
1150+
print(result.beams)
11501151

11511152
design_points = []
11521153
for dp in result.design_points:
@@ -1166,6 +1167,15 @@ def __read_existing_design(self) -> None:
11661167
)
11671168
self._named_selections[new_ns.name] = new_ns
11681169

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+
11691179
# Create CoordinateSystems
11701180
num_created_coord_systems = 0
11711181
for component_id, coordinate_systems in response.component_coord_systems.items():

0 commit comments

Comments
 (0)