Skip to content

Commit

Permalink
added add_mechanical_python_libraries and Enum arg
Browse files Browse the repository at this point in the history
  • Loading branch information
rs-bh-n committed Feb 27, 2024
1 parent b4077b8 commit 9a4c43b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cheat_sheets/pymechanical_cheat_sheet/pymechanical_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,18 @@

# BREAK BLOCK
from ansys.mechanical.core import App

app = App(version=241)
print(app)
# BREAK BLOCK

# Extract the global API entry points (available from built-in Mechanical scripting)
from ansys.mechanical.core import global_variables
# Merge them into your Python global variables
globals().update(global_variables(app))
# Optional argument for Enums without namespaces
globals().update(global_variables(app),True)
# Import python modules shipped with Mechanical
from ansys.mechanical.core.embedding import add_mechanical_python_libraries
add_mechanical_python_libraries(241)
# BREAK BLOCK
ExtAPI # Application.ExtAPI
DataModel # Application.DataModel
Expand All @@ -89,16 +92,13 @@
file = r"D:\\Workdir\\bracket.mechdb"
app.open(file)
allbodies = DataModel.Project.Model.GetChildren(
Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory.Body,
True)
DataModelObjectCategory.Body,True)
print(allbodies.Count)
# BREAK BLOCK
import logging
from ansys.mechanical.core import App
from ansys.mechanical.core.embedding.logger import (
Configuration,
Logger)

Configuration,Logger)
Configuration.configure(level=logging.WARNING, to_stdout=True)
app = App(version=241)
Logger.error("message")

0 comments on commit 9a4c43b

Please sign in to comment.