ansys / pysherlock

Pythonic interface to Sherlock
https://sherlock.docs.pyansys.com
MIT License
7 stars 0 forks source link

layer.py add_modeling_region() shapes Rectangular, Circular, and Slot centerX and centerY defined incorrectly #402

Closed aklara-ansys closed 4 days ago

aklara-ansys commented 2 weeks ago

πŸ” Before submitting the issue

🐞 Description of the bug

sherlock.layer.add_modeling_region(my_project, modeling_regions) Traceback (most recent call last): File "", line 1, in File "C:\Users\aklara\AppData\Local\Programs\Python\Python310\lib\site-packages\ansys\sherlock\core\layer.py", line 1093, in add_modeling_region rectangular_shape.centerX = shape.centerX AttributeError: 'RectangularShape' object has no attribute 'centerX'. Did you mean: 'center_x'?

Using layer_types.py, the PolygonalShape, SlotShape, or CircularShape are defined using center_x and center_y but you can see that in layer.py line 1093 you can see it expects centerX and centerY so you get an error defining these shapes. Screenshot 2024-10-03 143733

πŸ“ Steps to reproduce

Try using add_modeling_region to add any PolygonalShape, SlotShape, or CircularShape modeling regions. Here is the code used to reproduce the issue:

sherlock = launch_sherlock()

my_project = "PySherlock_Tutorial_Add_Potting" my_cca = "Main Board"

try: sherlock.project.delete_project(my_project) except: print("The specified project does not exist. Proceed normally.")

sherlock.project.import_odb_archive( "C:\WB_INSTALL\v251\sherlock\tutorial\ODB++ Tutorial.tgz", True, True, True, True, project=my_project, cca_name=my_cca )

Dimensions in mm.

U9_x = 0.0 # X-Coordinate in mm. U9_y = 19.05 # Y-Coordinate in mm. U9_package_length = 27.0 #Package Length in mm. U9_package_width = 27.0 #Package Width in mm. tolerance = 2.0 # Dimension Tolerance in mm.

x_min = U9_x - (U9_package_width/2) - tolerance x_max = U9_x + (U9_package_width/2) + tolerance y_min = U9_y - (U9_package_length/2) - tolerance y_max = U9_y + (U9_package_length/2) + tolerance

polygonal_shape = PolygonalShape(points=[(0, 0),(0, 6.35),(9.77, 0)], rotation=87.8) rectangular_shape = RectangularShape(length=U9_package_length, width=U9_package_width, center_x=U9_x, center_y=U9_y, rotation=0.0) slot_shape = SlotShape(length=5.0, width=5.0,node_count=6,center_x=U9_x, center_y=U9_y, rotation=0.0) circular_shape = CircularShape(diameter=5.0,node_count=4,center_x=0.0,center_y=0.0, rotation=30.0) # #

Add Modeling Region

#

modeling_regions = [ { "cca_name": my_cca, "region_id": "Region001", "region_units": "mm", "model_mode": "Enabled", "shape": rectangular_shape, "pcb_model_props": { "export_model_type": "Sherlock", "elem_order": "First_Order", "max_mesh_size": 0.5, "max_mesh_size_units": "mm", "quads_preferred": True }, "trace_model_props": { "trace_model_type": "Enabled", "elem_order": "Second_Order", "trace_mesh_size": 0.3, "trace_mesh_size_units": "mm" } } ]

sherlock.layer.add_modeling_region(my_project, modeling_regions)

πŸ’» Which operating system are you using?

Windows

πŸ“€ Which ANSYS version are you using?

INFO: Version 2025 R1 (25.1b20241002), build 20241002.1

🐍 Which Python version are you using?

3.10

πŸ“¦ Installed packages

annotated-types==0.7.0
ansys-api-sherlock==0.1.31
ansys-sherlock-core==0.7.1
bleach==6.1.0
bokeh==3.3.4
Brotli==1.1.0
build==1.2.1
cachetools==5.3.2
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
clr-loader==0.2.6
colorama==0.4.6
comtypes==1.3.1
contourpy==1.2.0
cycler==0.12.1
dill==0.3.8
exceptiongroup==1.2.2
fonttools==4.48.1
gitdb==4.0.11
GitPython==3.1.43
google-api-python-client==2.118.0
google-auth==2.27.0
google-auth-httplib2==0.2.0
googleapis-common-protos==1.62.0
grpcio==1.66.1
grpcio-tools==1.65.1
httplib2==0.22.0
idna==3.6
importlib-metadata==7.0.1
inflate64==1.0.0
iniconfig==2.0.0
Jinja2==3.1.3
keyboard==0.13.5
kiwisolver==1.4.5
linkify-it-py==2.0.3
Markdown==3.5.2
markdown-it-py==3.0.0
MarkupSafe==2.1.5
matplotlib==3.8.2
mdit-py-plugins==0.4.0
mdurl==0.1.2
multivolumefile==0.2.3
numpy==1.25.0
numpy-stl==3.1.1
packaging==23.2
pandas==2.1.4
panel==1.3.8
param==2.0.2
pillow==10.2.0
platformdirs==4.2.0
plotly==5.18.0
pluggy==1.5.0
proto-plus==1.23.0
protobuf==3.20.3
psutil==5.9.7
py7zr==0.20.8
pyasn1==0.5.1
pyasn1-modules==0.3.0
PyAutoIt==0.6.5
pybcj==1.0.2
pycparser==2.21
pycryptodomex==3.19.1
pydantic==2.7.3
pydantic_core==2.18.4
pyparsing==3.1.1
pyppmd==1.1.0
pyproject_hooks==1.1.0
pytest==8.3.3
python-dateutil==2.8.2
python-utils==3.8.2
pythonnet==3.0.4
pytz==2023.3.post1
pyviz_comms==3.0.1
pywin32==306
pywinauto==0.6.8
PyYAML==6.0.1
pyzstd==0.15.9
requests==2.31.0
rsa==4.9
scipy==1.12.0
selenium==3.141.0
six==1.16.0
smmap==5.0.1
tenacity==8.2.3
texttable==1.7.0
tomli==2.0.1
tornado==6.4
tqdm==4.66.2
typing_extensions==4.10.0
tzdata==2023.4
uc-micro-py==1.0.3
uritemplate==4.1.1
urllib3==1.26.16
vtk==9.3.0
webencodings==0.5.1
xyzservices==2023.10.1
zipp==3.17.0
ansjmoody commented 5 days ago

For slot and circular shapes, the code was using nodeCount instead of node_count. Modified Layer.add_modeling_region() to use node_count, center_x, and center_y.