|
7 | 7 |
|
8 | 8 | import tempfile
|
9 | 9 | import time
|
10 |
| - |
11 | 10 | import pyaedt
|
| 11 | +import os |
12 | 12 |
|
13 | 13 | # Define constants
|
14 | 14 |
|
|
47 | 47 | cs1.props["OriginY"] = 10
|
48 | 48 | cs1.props["OriginZ"] = 10
|
49 | 49 |
|
50 |
| -# Pointing vectors can be changed |
| 50 | +# The orientation of the coordinate system can be modified by |
| 51 | +# updating the direction vectors for the coordinate system. |
51 | 52 |
|
52 | 53 | ypoint = [0, -1, 0]
|
53 | 54 | cs1.props["YAxisXvec"] = ypoint[0]
|
|
62 | 63 |
|
63 | 64 | # ## Change coordinate system mode
|
64 | 65 | #
|
65 |
| -# Use the ``change_cs_mode`` method to change the mode. Options are ``0`` |
66 |
| -# for axis/position, ``1`` for Euler angle ZXZ, and ``2`` for Euler angle ZYZ. |
| 66 | +# Use the ``change_cs_mode`` method to change the mode. Options are |
| 67 | +# - ``0`` for axis/position |
| 68 | +# - ``1`` for Euler angle ZXZ |
| 69 | +# - ``2`` for Euler angle ZYZ. |
| 70 | +# |
67 | 71 | # Here ``1`` sets Euler angle ZXZ as the mode.
|
68 | 72 |
|
69 | 73 | cs1.change_cs_mode(1)
|
70 | 74 |
|
71 |
| -# In the new mode, these properties can be edited |
| 75 | +# The following lines use the ZXZ Euler angle definition to rotate the coordinate system. |
72 | 76 |
|
73 | 77 | cs1.props["Phi"] = "10deg"
|
74 | 78 | cs1.props["Theta"] = "22deg"
|
|
80 | 84 |
|
81 | 85 | cs1.delete()
|
82 | 86 |
|
83 |
| -# ## Create coordinate system by defining axes |
| 87 | +# ## Define a new coordinate system |
84 | 88 | #
|
85 |
| -# Create a coordinate system by defining the axes. During creation, you can |
86 |
| -# specify all coordinate system properties. |
| 89 | +# Create a coordinate system by defining the axes. You can |
| 90 | +# specify all coordinate system properties as shown here. |
87 | 91 |
|
88 | 92 | cs2 = hfss.modeler.create_coordinate_system(
|
89 | 93 | name="CS2",
|
|
93 | 97 | y_pointing=[0, -1, 0],
|
94 | 98 | )
|
95 | 99 |
|
96 |
| -# ## Create coordinate system by defining Euler angles |
97 |
| -# |
98 |
| -# Create a coordinate system by defining Euler angles. |
| 100 | +# A new coordinate system can also be created based on the Euler angle convention. |
99 | 101 |
|
100 | 102 | cs3 = hfss.modeler.create_coordinate_system(
|
101 | 103 | name="CS3", origin=[2, 2, 2], mode="zyz", phi=10, theta=20, psi=30
|
102 | 104 | )
|
103 | 105 |
|
104 |
| -# ## Create coordinate system by defining view |
| 106 | +# Create a coordinate system that is defined by standard views in the modeler. The options are |
| 107 | +# - ``"iso"`` |
| 108 | +# - ``"XY"`` |
| 109 | +# - ``"XZ"`` |
| 110 | +# - ``"XY"``. |
105 | 111 | #
|
106 |
| -# Create a coordinate system by defining the view. Options are ``"iso"``, |
107 |
| -# ``"XY"``, ``"XZ"``, and ``"XY"``. Here ``"iso"`` is specified. |
108 |
| -# The axes are set automatically. |
| 112 | +# Here ``"iso"`` is specified. The axes are set automatically. |
109 | 113 |
|
110 | 114 | cs4 = hfss.modeler.create_coordinate_system(
|
111 | 115 | name="CS4", origin=[1, 0, 0], reference_cs="CS3", mode="view", view="iso"
|
|
121 | 125 | name="CS5", mode="axisrotation", u=[1, 0, 0], theta=123
|
122 | 126 | )
|
123 | 127 |
|
124 |
| -# ## Create face coordinate system |
125 |
| -# |
126 | 128 | # Face coordinate systems are bound to an object face.
|
127 | 129 | # First create a box and then define the face coordinate system on one of its
|
128 | 130 | # faces. To create the reference face for the face coordinate system, you must
|
|
134 | 136 | face=face, origin=face.edges[0], axis_position=face.edges[1], name="FCS1"
|
135 | 137 | )
|
136 | 138 |
|
137 |
| -# ## Create face coordinate system centered on face |
138 |
| -# |
139 | 139 | # Create a face coordinate system centered on the face with the X axis pointing
|
140 | 140 | # to the edge vertex.
|
141 | 141 |
|
142 | 142 | fcs2 = hfss.modeler.create_face_coordinate_system(
|
143 | 143 | face=face, origin=face, axis_position=face.edges[0].vertices[0], name="FCS2"
|
144 | 144 | )
|
145 | 145 |
|
146 |
| -# ## Swap X and Y axes of face coordinate system |
147 |
| -# |
148 | 146 | # Swap the X axis and Y axis of the face coordinate system. The X axis is the
|
149 | 147 | # pointing ``axis_position`` by default. You can optionally select the Y axis.
|
150 | 148 |
|
|
158 | 156 | fcs3.props["WhichAxis"] = "X"
|
159 | 157 |
|
160 | 158 |
|
161 |
| -# ## Apply a rotation around the Z axis |
| 159 | +# ### Rotate the coordinate system |
162 | 160 | #
|
163 | 161 | # Apply a rotation around the Z axis. The Z axis of a face coordinate system
|
164 | 162 | # is always orthogonal to the face. A rotation can be applied at definition.
|
|
172 | 170 |
|
173 | 171 | fcs4.props["ZRotationAngle"] = "3deg"
|
174 | 172 |
|
| 173 | +# ### Offset the coordinate system |
| 174 | +# |
175 | 175 | # Apply an offset to the X axis and Y axis of a face coordinate system.
|
176 | 176 | # The offset is in respect to the face coordinate system itself.
|
177 | 177 |
|
|
184 | 184 | fcs5.props["XOffset"] = "0.2mm"
|
185 | 185 | fcs5.props["YOffset"] = "0.1mm"
|
186 | 186 |
|
187 |
| -# ## Create another coordinate system relative to face coordinate system |
| 187 | +# ### Dependent coordinate systems |
188 | 188 | #
|
189 | 189 | # The use of dependent coordinate systems can simplify model creation. The following
|
190 | 190 | # cell demonstrates how to create a coordinate system whose reference is the face coordinate system.
|
|
197 | 197 | name="CS_FCS", origin=[0, 0, 0], reference_cs=fcs6.name, mode="view", view="iso"
|
198 | 198 | )
|
199 | 199 |
|
200 |
| -# ## Create object coordinate systems |
| 200 | +# ### Object coordinate systems |
201 | 201 | #
|
202 | 202 | # A coordinate system can also be defined relative to elements
|
203 | 203 | # belonging to an object. For example, the coordinate system can be
|
204 | 204 | # connected to an object face.
|
205 | 205 |
|
206 | 206 | obj_cs = hfss.modeler.create_object_coordinate_system(
|
207 |
| - obj=box, |
| 207 | + assignment=box, |
208 | 208 | origin=box.faces[0],
|
209 | 209 | x_axis=box.edges[0],
|
210 | 210 | y_axis=[0, 0, 0],
|
|
215 | 215 | # Create an object coordinate system whose origin is linked to the edge of an object.
|
216 | 216 |
|
217 | 217 | obj_cs_1 = hfss.modeler.create_object_coordinate_system(
|
218 |
| - obj=box.name, |
| 218 | + assignment=box.name, |
219 | 219 | origin=box.edges[0],
|
220 | 220 | x_axis=[1, 0, 0],
|
221 | 221 | y_axis=[0, 1, 0],
|
|
226 | 226 | # Create object coordinate system with origin specified on a point within an object.
|
227 | 227 |
|
228 | 228 | obj_cs_2 = hfss.modeler.create_object_coordinate_system(
|
229 |
| - obj=box.name, |
| 229 | + assignment=box.name, |
230 | 230 | origin=[0, 0.8, 0],
|
231 | 231 | x_axis=[1, 0, 0],
|
232 | 232 | y_axis=[0, 1, 0],
|
|
247 | 247 | obj_cs_3.props["MoveToEnd"] = False
|
248 | 248 | obj_cs_3.update()
|
249 | 249 |
|
250 |
| -# ## Get all coordinate systems |
| 250 | +# ### Get all coordinate systems |
| 251 | +# |
| 252 | +# All coordinate systems can easily be retrieved and subsequently manipulated. |
251 | 253 |
|
252 | 254 | css = hfss.modeler.coordinate_systems
|
253 | 255 | names = [i.name for i in css]
|
|
0 commit comments