|
23 | 23 |
|
24 | 24 | from typing import TYPE_CHECKING |
25 | 25 |
|
| 26 | +from ansys.api.discovery.v1.commands.file_pb2 import ( |
| 27 | + ImportOptionDefinition as GRPCImportOptionDefinition, |
| 28 | +) |
26 | 29 | from ansys.api.discovery.v1.commonenums_pb2 import ( |
27 | 30 | BackendType as GRPCBackendType, |
28 | 31 | FileFormat as GRPCFileFormat, |
|
42 | 45 | ) |
43 | 46 | from ansys.api.discovery.v1.design.designmessages_pb2 import ( |
44 | 47 | CurveGeometry as GRPCCurveGeometry, |
| 48 | + DatumPointEntity as GRPCDesignPoint, |
45 | 49 | DrivingDimensionEntity as GRPCDrivingDimension, |
46 | 50 | EdgeTessellation as GRPCEdgeTessellation, |
47 | 51 | EnhancedRepairToolMessage as GRPCEnhancedRepairToolResponse, |
|
90 | 94 | from ansys.geometry.core.math.point import Point2D, Point3D |
91 | 95 | from ansys.geometry.core.math.vector import UnitVector3D |
92 | 96 | from ansys.geometry.core.misc.measurements import Measurement |
93 | | - from ansys.geometry.core.misc.options import TessellationOptions |
| 97 | + from ansys.geometry.core.misc.options import ImportOptionsDefinitions, TessellationOptions |
94 | 98 | from ansys.geometry.core.parameters.parameter import ( |
95 | 99 | Parameter, |
96 | 100 | ParameterUpdateStatus, |
@@ -237,6 +241,24 @@ def from_point2d_to_grpc_point(plane: "Plane", point2d: "Point2D") -> GRPCPoint: |
237 | 241 | ) |
238 | 242 |
|
239 | 243 |
|
| 244 | +def from_point3d_to_grpc_design_point(point: "Point3D") -> GRPCDesignPoint: |
| 245 | + """Convert a ``Point3D`` class to a design point gRPC message. |
| 246 | +
|
| 247 | + Parameters |
| 248 | + ---------- |
| 249 | + point : Point3D |
| 250 | + Source point data. |
| 251 | +
|
| 252 | + Returns |
| 253 | + ------- |
| 254 | + GRPCDesignPoint |
| 255 | + Geometry service gRPC design point message. The unit is meters. |
| 256 | + """ |
| 257 | + return GRPCDesignPoint( |
| 258 | + position=from_point3d_to_grpc_point(point), |
| 259 | + ) |
| 260 | + |
| 261 | + |
240 | 262 | def from_unit_vector_to_grpc_direction(unit_vector: "UnitVector3D") -> GRPCDirection: |
241 | 263 | """Convert a ``UnitVector3D`` class to a unit vector gRPC message. |
242 | 264 |
|
@@ -376,9 +398,9 @@ def from_grpc_frame_to_frame(frame: GRPCFrame) -> "Frame": |
376 | 398 | return Frame( |
377 | 399 | Point3D( |
378 | 400 | input=[ |
379 | | - frame.origin.x, |
380 | | - frame.origin.y, |
381 | | - frame.origin.z, |
| 401 | + frame.origin.x.value_in_geometry_units, |
| 402 | + frame.origin.y.value_in_geometry_units, |
| 403 | + frame.origin.z.value_in_geometry_units, |
382 | 404 | ], |
383 | 405 | unit=DEFAULT_UNITS.SERVER_LENGTH, |
384 | 406 | ), |
@@ -1271,6 +1293,45 @@ def from_grpc_update_status_to_parameter_update_status( |
1271 | 1293 | return status_mapping.get(update_status, ParameterUpdateStatus.UNKNOWN) |
1272 | 1294 |
|
1273 | 1295 |
|
| 1296 | +def from_design_file_format_to_grpc_file_export_format( |
| 1297 | + design_file_format: "DesignFileFormat", |
| 1298 | +) -> GRPCFileFormat: |
| 1299 | + """Convert from a DesignFileFormat object to a gRPC FileExportFormat one. |
| 1300 | +
|
| 1301 | + Parameters |
| 1302 | + ---------- |
| 1303 | + design_file_format : DesignFileFormat |
| 1304 | + The file format desired |
| 1305 | +
|
| 1306 | + Returns |
| 1307 | + ------- |
| 1308 | + GRPCFileExportFormat |
| 1309 | + Converted gRPC File format |
| 1310 | + """ |
| 1311 | + from ansys.geometry.core.designer.design import DesignFileFormat |
| 1312 | + |
| 1313 | + if design_file_format == DesignFileFormat.SCDOCX: |
| 1314 | + return GRPCFileFormat.FILEFORMAT_SCDOCX |
| 1315 | + elif design_file_format == DesignFileFormat.PARASOLID_TEXT: |
| 1316 | + return GRPCFileFormat.FILEFORMAT_PARASOLID_TEXT |
| 1317 | + elif design_file_format == DesignFileFormat.PARASOLID_BIN: |
| 1318 | + return GRPCFileFormat.FILEFORMAT_PARASOLID_BINARY |
| 1319 | + elif design_file_format == DesignFileFormat.FMD: |
| 1320 | + return GRPCFileFormat.FILEFORMAT_FMD |
| 1321 | + elif design_file_format == DesignFileFormat.STEP: |
| 1322 | + return GRPCFileFormat.FILEFORMAT_STEP |
| 1323 | + elif design_file_format == DesignFileFormat.IGES: |
| 1324 | + return GRPCFileFormat.FILEFORMAT_IGES |
| 1325 | + elif design_file_format == DesignFileFormat.PMDB: |
| 1326 | + return GRPCFileFormat.FILEFORMAT_PMDB |
| 1327 | + elif design_file_format == DesignFileFormat.STRIDE: |
| 1328 | + return GRPCFileFormat.FILEFORMAT_STRIDE |
| 1329 | + elif design_file_format == DesignFileFormat.DISCO: |
| 1330 | + return GRPCFileFormat.FILEFORMAT_DISCO |
| 1331 | + else: |
| 1332 | + return None |
| 1333 | + |
| 1334 | + |
1274 | 1335 | def from_material_to_grpc_material( |
1275 | 1336 | material: "Material", |
1276 | 1337 | ) -> GRPCMaterial: |
@@ -1447,6 +1508,28 @@ def from_parameter_to_grpc_quantity(value: float) -> GRPCQuantity: |
1447 | 1508 | return GRPCQuantity(value_in_geometry_units=value) |
1448 | 1509 |
|
1449 | 1510 |
|
| 1511 | +def from_import_options_definitions_to_grpc_import_options_definition( |
| 1512 | + import_options_definitions: "ImportOptionsDefinitions", |
| 1513 | +) -> GRPCImportOptionDefinition: |
| 1514 | + """Convert an ``ImportOptionsDefinitions`` to import options definition gRPC message. |
| 1515 | +
|
| 1516 | + Parameters |
| 1517 | + ---------- |
| 1518 | + import_options_definitions : ImportOptionsDefinitions |
| 1519 | + Definition of the import options. |
| 1520 | +
|
| 1521 | + Returns |
| 1522 | + ------- |
| 1523 | + GRPCImportOptionDefinition |
| 1524 | + Geometry service gRPC import options definition message. |
| 1525 | + """ |
| 1526 | + definitions = {} |
| 1527 | + for key, definition in import_options_definitions.to_dict().items(): |
| 1528 | + definitions[key] = GRPCImportOptionDefinition(string_option=str(definition)) |
| 1529 | + |
| 1530 | + return definitions |
| 1531 | + |
| 1532 | + |
1450 | 1533 | def _nurbs_curves_compatibility(backend_version: "semver.Version", grpc_geometries: GRPCGeometries): |
1451 | 1534 | """Check if the backend version is compatible with NURBS curves in sketches. |
1452 | 1535 |
|
@@ -1514,45 +1597,6 @@ def from_enclosure_options_to_grpc_enclosure_options( |
1514 | 1597 | ) |
1515 | 1598 |
|
1516 | 1599 |
|
1517 | | -def from_design_file_format_to_grpc_file_format( |
1518 | | - design_file_format: "DesignFileFormat", |
1519 | | -) -> GRPCFileFormat: |
1520 | | - """Convert from a ``DesignFileFormat`` object to a gRPC file format. |
1521 | | -
|
1522 | | - Parameters |
1523 | | - ---------- |
1524 | | - design_file_format : DesignFileFormat |
1525 | | - The file format desired |
1526 | | -
|
1527 | | - Returns |
1528 | | - ------- |
1529 | | - GRPCFileFormat |
1530 | | - Converted gRPC FileFormat. |
1531 | | - """ |
1532 | | - from ansys.geometry.core.designer.design import DesignFileFormat |
1533 | | - |
1534 | | - if design_file_format == DesignFileFormat.SCDOCX: |
1535 | | - return GRPCFileFormat.FILEFORMAT_SCDOCX |
1536 | | - elif design_file_format == DesignFileFormat.PARASOLID_TEXT: |
1537 | | - return GRPCFileFormat.FILEFORMAT_PARASOLID_TEXT |
1538 | | - elif design_file_format == DesignFileFormat.PARASOLID_BIN: |
1539 | | - return GRPCFileFormat.FILEFORMAT_PARASOLID_BINARY |
1540 | | - elif design_file_format == DesignFileFormat.FMD: |
1541 | | - return GRPCFileFormat.FILEFORMAT_FMD |
1542 | | - elif design_file_format == DesignFileFormat.STEP: |
1543 | | - return GRPCFileFormat.FILEFORMAT_STEP |
1544 | | - elif design_file_format == DesignFileFormat.IGES: |
1545 | | - return GRPCFileFormat.FILEFORMAT_IGES |
1546 | | - elif design_file_format == DesignFileFormat.PMDB: |
1547 | | - return GRPCFileFormat.FILEFORMAT_PMDB |
1548 | | - elif design_file_format == DesignFileFormat.STRIDE: |
1549 | | - return GRPCFileFormat.FILEFORMAT_STRIDE |
1550 | | - elif design_file_format == DesignFileFormat.DISCO: |
1551 | | - return GRPCFileFormat.FILEFORMAT_DISCO |
1552 | | - else: |
1553 | | - return None |
1554 | | - |
1555 | | - |
1556 | 1600 | def serialize_tracked_command_response(response: GRPCTrackedCommandResponse) -> dict: |
1557 | 1601 | """Serialize a TrackedCommandResponse object into a dictionary. |
1558 | 1602 |
|
|
0 commit comments