Custom python script caller for write#1033
Open
jginternational wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
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::GetCustomScriptsto discoverscripts/Custom/*.pyand populate a new “Custom scripts” submenu. - Add
Kratos::ExecuteCustomScriptto source and call a selected Python script from Tcl. - Add an example custom script (
python_writer.py) underscripts/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 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
By adding python scripts as seen in the example:

The GiD kratos menú will show this

@RiccardoRossi