-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcad_manager.py
More file actions
94 lines (78 loc) · 3.09 KB
/
cad_manager.py
File metadata and controls
94 lines (78 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# SPDX-FileCopyrightText: 2025 Autodesk, Inc.
# SPDX-License-Identifier: Apache-2.0
"""
Usage:
CADManager Class API Wrapper
"""
from .ent_list import EntList
from .vector import Vector
from .logger import process_log, LogMessage
from .helper import check_type, check_and_coerce_optional
from .com_proxy import safe_com
class CADManager:
"""
Wrapper for CADManager class of Moldflow Synergy.
"""
def __init__(self, _cad_manager):
"""
Initialize the CADManager with a CADManager instance from COM.
Args:
_cad_manager: The CADManager instance.
"""
process_log(__name__, LogMessage.CLASS_INIT, locals(), name="CADManager")
self.cad_manager = safe_com(_cad_manager)
def create_entity_list(self) -> EntList:
"""
Creates an empty EntList object
When using this function, it will first ask for result invalidation.
If you want to select entities without checking result, use StudyDoc.create_entity_list().
Returns:
EntList: The new entity list.
"""
result = self.cad_manager.CreateEntityList
if result is None:
return None
return EntList(result)
def modify_cad_surfaces_by_normal(
self, faces: EntList | None, transit_faces: EntList | None, distance: float
) -> bool:
"""
Modify CAD faces by a given distance
Args:
faces (EntList | None): EntList object containing the faces to be modified
transit_faces (EntList | None): EntList object containing the transit faces
to be preserved
distance (float): distance along input faces' normal direction
Returns:
bool: True if operation is successful; False otherwise
"""
process_log(
__name__, LogMessage.FUNCTION_CALL, locals(), name="modify_cad_surfaces_by_normal"
)
check_type(distance, (float, int))
return self.cad_manager.ModifyCADSurfacesByNormal(
check_and_coerce_optional(faces, EntList),
check_and_coerce_optional(transit_faces, EntList),
distance,
)
def modify_cad_surfaces_by_vector(
self, faces: EntList | None, transit_faces: EntList | None, vector: Vector | None
) -> bool:
"""
Modify CAD faces by a given vector
Args:
faces (EntList | None): EntList object containing the faces to be modified
transit_faces (EntList | None): EntList object containing the transit
faces to be preserved
vector (Vector | None): Vector object that specifies the direction
Returns:
bool: True if operation is successful; False otherwise
"""
process_log(
__name__, LogMessage.FUNCTION_CALL, locals(), name="modify_cad_surfaces_by_vector"
)
return self.cad_manager.ModifyCADSurfacesByVector(
check_and_coerce_optional(faces, EntList),
check_and_coerce_optional(transit_faces, EntList),
check_and_coerce_optional(vector, Vector),
)