Skip to content

Bug located in Graphics.SectionPlanes.CreateSectionPlane(coord_sys) #1497

@saideogekar

Description

@saideogekar

🔍 Before submitting the issue

  • I have searched among the existing issues
  • I am using a Python virtual environment

🐞 Description of the bug

The following code to create a Section Plane and activate it works in Scripting window of Mechanical, but not via PyMechanical (I am using VS Code). I have tried both ways to create section plane (1. using only coordinate system as the input 2. using coordinate system and plane orientation as inputs)

# Create Section Plane along the X-Z Plane Using a Specified Coordinate System
# Note: if you want the flip the visibility of the hidden portion and the visbile portion of the model, use (0,1,0)  instead of (0,-1,0) for the direction of the Section Plane.
var_coordinate_system = 'Section Plane Coordinate System'

coord_sys = [cs for cs in Model.CoordinateSystems.Children if cs.Name == var_coordinate_system][0]
section_plane = Graphics.SectionPlanes.CreateSectionPlane(coord_sys)
# section_plane = Graphics.SectionPlanes.CreateSectionPlane(coord_sys,MechanicalEnums.Common.PlaneOrientation.PlaneOrientation_XZ)
section_plane.Direction = Vector3D(0,-1,0)

📝 Steps to reproduce

  1. Import geometry (I am unable to attach the geometry file that I used, but any geometry can be used for this purpose).
  2. Create coordinate system
  3. Create section plane
# Import Geometry File into the Model with Import Preferences for Line Bodies and Named Selections
var_geometry_path = 'D:\\PyAnsysDataLab\\Snap-Fit Buckle\\Geometry_and_Material_Files\\Buckle_Geometry.dsco'
var_process_lines = True
var_process_ns = True
var_namedselection_key = ''

geometry_import_preferences = Ansys.ACT.Mechanical.Utilities.GeometryImportPreferences()
geometry_import_preferences.ProcessLines = var_process_lines
geometry_import_preferences.ProcessNamedSelections = var_process_ns 
geometry_import_preferences.NamedSelectionKey = var_namedselection_key
geometry_import_format = Ansys.Mechanical.DataModel.Enums.GeometryImportPreference.Format.Automatic

geometry_import = Model.GeometryImportGroup.AddGeometryImport()
geometry_import.Import(var_geometry_path,geometry_import_format,geometry_import_preferences)

# Create Cartesian Coordinate System Based on Origin Location - Akshay S.
var_coordinate_system = 'Section Plane Coordinate System'
var_Origin_x = 0
var_Origin_y = 1.56
var_Origin_z = 0

csys_grp = Model.CoordinateSystems
lcs = csys_grp.AddCoordinateSystem()
length_unit = ExtAPI.DataModel.CurrentConsistentUnitFromQuantityName('Length')
lcs.OriginX = Quantity(var_Origin_x, length_unit)
lcs.OriginY = Quantity(var_Origin_y, length_unit)
lcs.OriginZ = Quantity(var_Origin_z, length_unit)
lcs.Name = var_coordinate_system

# ***** This module works in the Scripting window of Mechanical, but not via PyMechanical *****
#**********************************************************************
# Create Section Plane along the X-Z Plane Using a Specified Coordinate System
# Note: if you want the flip the visibility of the hidden portion and the visbile portion of the model, use (0,1,0)  instead of (0,-1,0) for the direction of the Section Plane.
var_coordinate_system = 'Section Plane Coordinate System'

coord_sys = [cs for cs in Model.CoordinateSystems.Children if cs.Name == var_coordinate_system][0]
# section_plane = Graphics.SectionPlanes.CreateSectionPlane(coord_sys)
section_plane = Graphics.SectionPlanes.CreateSectionPlane(coord_sys,MechanicalEnums.Common.PlaneOrientation.PlaneOrientation_XZ)
# section_plane.Direction = Vector3D(0,-1,0)
```can be used for this 

### 💻 Which operating system are you using?

Windows

### 📀 Which ANSYS version are you using?

2025R2

### 🐍 Which Python version are you using?

3.12

### 📦 Installed packages

```shell
aiohappyeyeballs==2.4.4
aiohttp==3.11.12
aiosignal==1.3.2
annotated-types==0.7.0
ansys-api-mechanical==0.1.2
ansys-dpf-composites==0.7.0
ansys-dpf-core==0.14.2
ansys-dpf-post==0.10.1
ansys-mechanical-core==0.11.28
ansys-mechanical-env==0.1.16
ansys-mechanical-stubs==0.1.6
ansys-pythonnet==3.1.0rc6
ansys-tools-path==0.7.3
anyio==4.6.2.post1
appdirs==1.4.4
asttokens==3.0.0
async-timeout==4.0.3
attrs==25.1.0
azure-cognitiveservices-speech==1.32.1
azure-common==1.1.28
azure-core==1.29.6
azure-identity==1.13.0
azure-search-documents==11.4.0
beautifulsoup4==4.12.2
bidict==0.23.1
blinker==1.9.0
bs4==0.0.2
cachetools==5.5.2
certifi==2024.8.30
cffi==1.17.1
charset-normalizer==3.4.1
click==8.1.8
clr_loader==0.2.7.post0
colorama==0.4.6
comm==0.2.3
contourpy==1.3.2
cryptography==44.0.0
cycler==0.12.1
dataclasses-json==0.5.14
debugpy==1.8.15
decorator==5.2.1
defusedxml==0.7.1
distro==1.9.0
docopt==0.6.2
et_xmlfile==2.0.0
exceptiongroup==1.2.2
executing==2.2.0
filelock==3.17.0
Flask==2.3.2
Flask-Cors==3.0.10
Flask-JWT-Extended==4.5.2
Flask-SocketIO==5.3.4
fonttools==4.58.0
frozenlist==1.5.0
fsspec==2025.2.0
gevent==24.11.1
gevent-websocket==0.10.1
google-api-core==2.24.2
google-api-python-client==2.169.0
google-auth==2.40.1
google-auth-httplib2==0.2.0
googleapis-common-protos==1.70.0
greenlet==3.1.1
grpcio==1.71.0
h11==0.14.0
httpcore==1.0.7
httplib2==0.22.0
httpx==0.28.0
huggingface-hub==0.28.1
idna==3.10
imageio==2.28.0
imageio-ffmpeg==0.6.0
importlib_metadata==8.7.0
ipykernel==6.30.1
ipython==8.37.0
isodate==0.7.2
itsdangerous==2.2.0
jedi==0.19.2
Jinja2==3.1.5
jiter==0.8.0
jupyter_client==8.6.3
jupyter_core==5.8.1
kiwisolver==1.4.8
langchain==0.0.152
langdetect==1.0.9
logging==0.4.9.6
lxml==5.3.1
MarkupSafe==3.0.2
marshmallow==3.26.1
matplotlib==3.10.3
matplotlib-inline==0.1.7
msal==1.31.1
msal-extensions==1.2.0
multidict==6.1.0
mypy-extensions==1.0.0
nest-asyncio==1.6.0
num2words==0.5.12
numexpr==2.10.2
numpy==2.2.6
openai==1.34.0
openapi-schema-pydantic==1.2.4
openpyxl==3.1.5
outcome==1.3.0.post0
packaging==24.2
pandas==1.5.2
parso==0.8.4
pillow==11.1.0
platformdirs==4.3.8
playwright==1.52.0
pooch==1.8.2
portalocker==2.10.1
prompt_toolkit==3.0.51
propcache==0.2.1
proto-plus==1.26.1
protobuf==5.29.5
psutil==7.0.0
pure_eval==0.2.3
pyasn1==0.6.1
pyasn1_modules==0.4.2
pycparser==2.22
pydantic==1.10.21
pydantic_core==2.27.1
pyee==13.0.0
Pygments==2.19.2
PyJWT==2.10.1
pyparsing==3.2.3
PyPDF2==3.0.1
PySocks==1.7.1
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-engineio==4.11.2
python-pptx==1.0.2
python-socketio==5.12.1
pytz==2025.1
pyvista==0.45.2
pywin32==308
PyYAML==6.0.2
pyzmq==27.0.1
regex==2024.11.6
requests==2.28.2
rsa==4.9.1
scooby==0.10.1
selenium==4.20.0
simple-websocket==1.1.0
six==1.17.0
sniffio==1.3.1
sortedcontainers==2.4.0
soupsieve==2.6
SQLAlchemy==2.0.37
stack-data==0.6.3
tenacity==8.2.2
tiktoken==0.3.3
tokenizers==0.13.3
tornado==6.5.1
tqdm==4.67.1
traitlets==5.14.3
transformers==4.28.1
trio==0.28.0
trio-websocket==0.11.1
typing-inspect==0.9.0
typing_extensions==4.12.2
uritemplate==4.1.1
urllib3==1.26.20
vtk==9.4.2
wcwidth==0.2.13
webdriver-manager==4.0.1
Werkzeug==3.1.3
wsproto==1.2.0
XlsxWriter==3.2.2
yarl==1.18.3
youtube-transcript-api==0.6.3
yt-dlp==2025.2.19
zipp==3.21.0
zope.event==5.0
zope.interface==7.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfutureTo be implemented in the future

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions