Skip to content

Custom python script caller for write#1033

Open
jginternational wants to merge 1 commit into
masterfrom
write-custom-python
Open

Custom python script caller for write#1033
jginternational wants to merge 1 commit into
masterfrom
write-custom-python

Conversation

@jginternational
Copy link
Copy Markdown
Member

By adding python scripts as seen in the example:
image

The GiD kratos menú will show this
image

@RiccardoRossi

Copilot AI review requested due to automatic review settings May 21, 2026 14:09
@jginternational jginternational self-assigned this May 21, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a mechanism to discover and execute user-provided Python scripts from the GiD “Kratos” menu, intended (initially) to support custom mesh writing workflows.

Changes:

  • Add Kratos::GetCustomScripts to discover scripts/Custom/*.py and populate a new “Custom scripts” submenu.
  • Add Kratos::ExecuteCustomScript to source and call a selected Python script from Tcl.
  • Add an example custom script (python_writer.py) under scripts/Custom/.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
kratos.gid/scripts/Utils.tcl Adds the Tcl entry point that sources and executes a selected custom Python script.
kratos.gid/scripts/Menus.tcl Adds menu entries for custom scripts and discovers available .py files.
kratos.gid/scripts/Custom/python_writer.py Provides an example custom Python script callable from the new menu.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +415 to +424
set script_path [file join $kratos_private(Path) scripts Custom ${script_name}.py]
if {[file exists $script_path]} {
# first version will assume that its for writing meshes in mdpa format
# must be python
# W "Executing custom script: $script_path"
GiD_Python_Source $script_path
GiD_Python_Call ${script_name}.start "[GiD_Info project ModelName].mdpa"
# [GiD_Python_Call gid_meshio.my_meshio_write_mesh2 $filename]
} else {
W "Custom script $script_name not found in path $script_path"
Comment on lines +420 to +421
GiD_Python_Source $script_path
GiD_Python_Call ${script_name}.start "[GiD_Info project ModelName].mdpa"
# must be python
# W "Executing custom script: $script_path"
GiD_Python_Source $script_path
GiD_Python_Call ${script_name}.start "[GiD_Info project ModelName].mdpa"
}

proc Kratos::GetCustomScripts { } {
# Custom scripts are defined in the folder scipts/Custom/*.py, and they are added to the menu with the name of the file (without extension)
Comment on lines +3 to +5
from objarray_numpy_tools import objarray_to_nparray,nparray_to_objarray
from pathlib import Path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants