Skip to content

New Plugin: Scripting#631

Open
elblake wants to merge 6 commits intodgud:masterfrom
elblake:eb/scripting-shapes
Open

New Plugin: Scripting#631
elblake wants to merge 6 commits intodgud:masterfrom
elblake:eb/scripting-shapes

Conversation

@elblake
Copy link
Collaborator

@elblake elblake commented Jan 2, 2026

First release of the scripting plugin.

This plugin makes it possible to implement new shapes, importers, exporters and command scripts using scripting languages like Scheme and Python.

Requires Gauche for Scheme runtime
Requires Python 3.6 or later

Scripts

The locations of scripts are specified by the user in preferences, and each script comprises of the script itself (.py or .scm) and the .wscr file, which contains information about how the script should be called, and how to construct its parameter dialog box.

The .wscr file contains directives to add specific variables for use by the script, add configuation keys to the wings:import and wings:export functions for importer and exporter scripts. .wscr files also have a simple query language when using %[...], to access parameter values, and access values as tuples, lists, orddict, as well as store and retrieve the parameter values into temporary variables.

New shape scripts show up in the new shape menu. They use the same new_shape return value as plugins.

Importer and exporter scripts show up in the File > Import and File > Export menus.

Command scripts show up on right click on a selected object and can modify meshes in three different ways:

  • Scripts can use a simplified API for simple tasks such as changing the vertex positions and colors.
  • Scripts can receive an e3d_mesh object, modify it, and return a e3d_mesh back.
  • Scripts can use we functions directly (wings_we, wings_face, wings_edge, wings_vertex, etc), the list of callable wings we functions is defined in callable.conf. This file also provides type information for the scripting plugin to convert
    lists to erlang data structures like sets and trees automatically.

Wings doesn't need to be restarted after modifying a script, the interpreter process is out-of-process and is started and closed on each invocation.

Script errors if any will show up in the wings console window.

Plugin Scripts

Plugin scripts are scripts that get added into wing's menu system so they can be accessed the same way as plugins. A script
(.py or .scm) and .wscr file can be bundled with a plugin script conf file and the three can be added to a folder in the user folder called "plugin_scripts" and the script will show up with its own menu entry in the right click menus. This makes it so a script can be packaged for distribution and installed like an actual plugin. The "Install Plugin" menu has had changes made so plugins can be queried when a tar file is being installed which does not contain a beam file.

Script Folders

Script folder conf files are added in a user folder called "script_folders" and this makes it so a folder of scripts can be made into a submenu in the wings program. It's similar to the plugin script conf file, but more for power users to have separate script folders in
different menus in wings.

Documentation

The scripting plugin adds information and a reference manual to the help menu. The reference manual contains information for python scripts, scheme scripts and the .wscr config file.

The we function documentation is generated from the funs file in the docs folder.

Changes to Wings

The pull request makes changes to wings_dialog, wings_plugin, and wings_va:

wings_dialog:
A new documentation system built on top of the current help text window in wings_dialog was created for the scripting documentation.

wings_plugin:
The "Install Plugin" menu item has been changed so that when a tar file does not contain a beam file, but does contain an XML file containing a type string, wings will query loaded plugins for one that recognize the type string.

wings_va:
Added set_face_attr_vs/4 to wings_va to change point vertex attributes using the same list data structure that is returned from face_attr/3.

Added replace_attr/3 to wings_va.

New tools added in the tools folder:

tools/pack_manual is a script for creating manuals, it can be used for future references for other plugins as well.

Credits

Earlier version of the scripting preference dialog used wxDialog API directly, the plugin preference dialog had been rewritten to now use wings ui dialog, many thanks to Micheus help to change it over.

NOTE: Added scripting to wings.

elblake and others added 6 commits May 19, 2025 13:48
Added a way to keep the plugin from timing out, as well as commands to show current progress.

Added preview functionality for scripts.
By building this branch I was getting lots of this warning:
> matching on the float 0.0 will no longer also match -0.0 in OTP 27.
> If you specifically intend to match 0.0 alone, write +0.0 instead.

Then, rebasing it to the main repository (dgud) fixed most of them,
but then it stopped in your code. This change fix that.
It was made changes to the code in order to allow us to replace the table
content. This way we can implemente addition, update and deletion of items
in a table list.

It was also disable the title highlight stuff since we don't handle its
event in order to promote ordering which can cause confusion to the user.
Added set_face_attr_vs/4 to wings_va which can set new attribute values from
the list returned by face_attr/3.

Added replace_attr/3 to wings_va.

Added new config files. Fixes to some types of values passed to the script.
More distinct use of vector vs list in returned script data. New preference
dialog implemented with help from micheus.

Scripts can now use checkboxes and dropdown lists for parameters in the
simple parameter layout. Scripts can also specify advanced parameter layouts
as erlang terms directly.

A lot of changes made to the scripting plugin. Added manual code,
documentation and tools, updated makefiles, added lang file, fixes.

NOTE: Added scripting to wings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants