Wings 3D Development Forum
Scripting with Scheme and Python - Printable Version

+- Wings 3D Development Forum (https://www.wings3d.com/forum)
+-- Forum: Wings 3D (https://www.wings3d.com/forum/forumdisplay.php?fid=1)
+--- Forum: Design & Development (https://www.wings3d.com/forum/forumdisplay.php?fid=6)
+--- Thread: Scripting with Scheme and Python (/showthread.php?tid=3096)

Pages: 1 2 3 4


Scripting with Scheme and Python - edb - 04-05-2023

Many months ago I started experimenting with running scheme scripts to generate
mesh data as a way for me to get more familiar with how wings plugins worked.
A while later I added python interpreter support so now this is a plugin that makes it
possible to run scheme and python scripts as if they were simple plugins.

[Image: R1EUep1O_o.png]

Some of the uses at the moment for it there is some scripts for generating shapes.

There are also exporters to export wings3d meshes to some game formats:
Godot (.tres) and Panda3d (.egg).

A python script based exporter has some advantages for game developers for exporting
to game engine formats. Game engines change at a fairly fast pace
and their formats might not be set in stone as much like formats like .obj. Game developers
will also likely need to have easy access to the script to make changes and customizations
to the mesh output for their day-to-day use.


Installing this plugin has a few steps:
  1. Install the plugin tar (it includes the .beam and a directory of startup scripts)
    wpc_scripting_shapes.tar


  2. Install a recent python 3.x (3.6+) (WEBSITE), add to PATH env if needed.

  3. Install a recent Gauche scheme (WEBSITE), add to PATH env if needed.

  4. Download the scripts pack to a directory
    https://github.com/elblake/wings-scripts-pack

  5. In plug-in preferences > "Scripts Preference", add the directory to the list of paths in the import/export and shapes tabs.

  6. Try right click > "Shape from Script"

NOTE: Be careful when searching for open source software in Google. Links are added to find the real python and scheme.

Documentation:
Scripting_Plugin_Wings3D_en.pdf


When writing scripts:
  • Wings3D 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.

  • Information can be printed to the console for debugging purpose with print (python) or
    display (scheme), as long as the beginning of the line doesn't start with an open
    parenthesis, which the script plugin interprets as the start of incoming return data.
    If printing a variable will likely print an expression enclosed in parenthesis,
    print another character just before it on the same line.

The plugin code can be found in the branch:
eb/scripting-shapes


RE: Scripting with Scheme and Python - micheus - 04-05-2023

This sounds like a useful addition for some users.

I'm getting antivirus warning about the Python installer been infected by Win32: PWSX-gen [Trj]. I didn't find any reference about this issue to be false on the net. (I don't like that).

It's a pity that Guache runs at Windows via MingW.

Could you include in the pack's readme a short explanation about meaning and use of the files with the extensions .wscr, .inclr, .scm?


RE: Scripting with Scheme and Python - edb - 04-06-2023

Hi micheus,
I added an explanation of the file extensions into the pack README.

I'm not sure about the warning, I think the python.org installers are signed.


RE: Scripting with Scheme and Python - micheus - 04-06-2023

Thanks for the description. It should help users interested to try the plugin to understand what and where to implement/change on their code.

I went back to download Python and today got the installer correctly. And I used Google search again.

So, by verifying the page history from yesterday I noticed that for some reason I was "redirected" to a page in https://www.pythonstudy.live/ - which is a clone of the original Python's download page, but the installer to be downloaded is "FileSetupApplication18.1.0.zip" from https://github.com/zetrocode/server/releases/download (instead of python-3.11.3-amd64.exe).

Very strange. So, pay attention.


RE: Scripting with Scheme and Python - edb - 04-07-2023

Hi micheus, I've updated my post with the missing links.

I'll have a bit more documentation available soon as well.


RE: Scripting with Scheme and Python - edb - 04-07-2023

I've put together a more comprehensive documentation:
Scripting_Plugin_Wings3D_en.pdf

Update: a few small corrections.


RE: Scripting with Scheme and Python - edb - 04-10-2023

Updated with changes made for command scripts for changing vertex color and uv attributes:
wpc_scripting_shapes.tar

The scripts pack is updated with improvements to some of the scripts.
https://github.com/elblake/wings-scripts-pack


RE: Scripting with Scheme and Python - sciroccorics - 04-10-2023

Hi,

I downloaded your plugin and your script pack today. I've been using Python for years, so this sounds like a very interesting extension to me, as I could never find some time to learn Erlang :-(

I am used to generating 3D shapes with Python (using 'numpy' and/or 'pyvista' to get heavy speedup by vectorization) and usually export them as OBJ files, to rework on them with Wings3D. Performing such shape imports directly in Wings, using a Python script is very appetizing !

I quickly skimmed the code of some scripts (e.g. pixel_art_shape.py) and everything seems very clean and very clear. I'm going to make some experiments with you code in a "near" future (lot of ideas for the 'new shape' plugin) and will certainly come back here for some questions ;-)

Thanks a lot for your work...


RE: Scripting with Scheme and Python - edb - 04-11-2023

Hi sciroccorics,

Thank you for the feedback. I'm glad that the scripting plugin might find some use.

Let me know if you have any questions.


RE: Scripting with Scheme and Python - tkbd - 04-13-2023

Hello,edb!!
I tried to your plugin whether work on MacOS.
It successfuly,so I create an instruction of the setting.
This is a great plugin. I feel the possibilities.

[MacOS] How to get ready Wings3D Scripting Plug-ins
http://wings3d.com/forum/showthread.php?tid=3099
It works on mojave(OSX10.14) and big sur(MacOS11)

but Some issue happend,so I report it to you.
Crash When interpreter pathes are wrong
This mean is Wings3d crash without error dialog.

new_shape_pixel_art script plugin
Read to large size pgm(ppm)file(e.g. 256px*256px),
it slow down Wings3D and freeze at last.

Distorted scaling script plugin
It doesn't work,it returned error a following.
Code:
DEBUG: *** ERROR: ScmSmallInt required, but got 2.0
DEBUG:     While loading "/Users/*****/wings-scripts-pack-main/simple_shape_effects/distorted_scaling.scm" at line 25
DEBUG:     While loading "/Users/*****/Library/Application Support/Wings3D/2.2.9/plugins/wpc_scripting_shapes_init/init.scm" at line 199
DEBUG: Stack Trace:
DEBUG: _______________________________________
DEBUG:   0  (list-ref *params* (list-ref *params* 4))
DEBUG:         at "/Users/*****/wings-scripts-pack-main/simple_shape_effects/distorted_scaling.scm":25
DEBUG:   1  (load *script-full-path*)
DEBUG:         at "/Users/*****/Library/Application Support/Wings3D/2.2.9/plugins/wpc_scripting_shapes_init/init.scm":192
NOTE: Script runtime exited with code: 70
Error: "/Users/*****/wings-scripts-pack-main/simple_shape_effects/distorted_scaling.scm": "No results"



Thank you very much and cheers!
-----
tkbd