• Website
  • Search
  • Member List
  • Help
  • Old Forum
  • Social Media
    •   @Wings3dOfficial
    •   @Wings3dOfficial
    •   Wings3dOfficial
    •   Wings3dOfficial
  • Register
  • Login
  • Website
  • Search
  • Member List
  • Help
  • Old Forum
  • Register
  • Login
Wings 3D Development Forum Wings 3D Design & Development v
1 2 3 4 5 … 11 Next »
Scripting with Scheme and Python

 
  • 0 Vote(s) - 0 Average
Scripting with Scheme and Python

Pages (5): « Previous 1 2 3 4 5
ivla
Offline

Member

Posts: 62
Threads: 7
Joined: May 2023
#41
03-14-2025, 12:32 PM
New version of thread generating script (python)

Changed parameters dialog;
Corrected "Round" profile;
Added "Semi-round inside" profile.
edb
Offline

Member

Posts: 135
Threads: 16
Joined: Nov 2022
#42
03-22-2025, 06:16 PM (This post was last modified: 03-22-2025, 06:32 PM by edb.)
Some of the new features in the next build:
  • Simplified returning data from script
  • Plugin Scripts
  • Script Folders
  • Better designed command script API

Simplified returning data from script

Scripts for the next release will have to have a small change,
as previously scripts had to write the result themselves using
write_list_out(sys.stdout), now the data can simply be returned
instead.

In Python, this was how to create a new shape:

Code:
    ...
    shape = w3d_newshape.NewShape()
    shape.fs = Fs
    shape.vs = Vs
    o = shape.as_output_list()
    print("")
    o.write_list_out(sys.stdout)

Now it will be:

Code:
    ...
    shape = w3d_newshape.NewShape()
    shape.fs = Fs
    shape.vs = Vs
    return shape

And this was how to do a file import:

Code:
    print("")
    e3df = w3d_e3d.E3DFile()
    e3df.objs = objs
    e3df.mat = mats
    o_ok = OutputList()
    o_ok.add_symbol("ok")
    o_ok.add_list(e3df.as_output_list())
    o_ok.write_list_out(sys.stdout)

Now it has changed to:

Code:
    e3df = w3d_e3d.E3DFile()
    e3df.objs = objs
    e3df.mat = mats
    return Okay(e3df)

In Scheme, a new shape was created with:

Code:
    ...
    (newline)
    (write (list new_shape "Shape" Fs Vs)))

Now it has changed to:

Code:
    ...
    (list 'new_shape "Shape" Fs Vs))

And for a file import:

Code:
    ...
    (newline)
    (write `(ok ,e3df)))

Has now changed to:

Code:
    ...
    `(ok ,e3df))

Scripts in the wings script pack repository will be updated to
the new style when I'll have the new build available.


Plugin Scripts

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 now
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.


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.


Better designed command script API

Until now the scripting plugin didn't provide a way to actually
change anything too complicated in the #we{} other than vertex
positions and colors. The next build command scripts can actually
make changes to #we{} directly using wings' various functions
in wings_we, wings_face, wings_edge, wings_vertex, etc.

This part is getting close to complete and I'll have a new build
available when I have a few test scripts working.
ivla
Offline

Member

Posts: 62
Threads: 7
Joined: May 2023
#43
03-24-2025, 08:20 AM
Good news, edb!

(03-22-2025, 06:16 PM)edb Wrote: 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"
You mean it can be packed like other plugins in .tar file?
Show an example, please.
edb
Offline

Member

Posts: 135
Threads: 16
Joined: Nov 2022
#44
03-25-2025, 06:01 PM (This post was last modified: 03-25-2025, 06:23 PM by edb.)
Hello ivla

(03-24-2025, 08:20 AM)ivla Wrote: You mean it can be packed like other plugins in .tar file?
Show an example, please.

Yep that's exactly it, the script can be packaged in a tar file and
will be installable the same way as plugins.

The script and .wscr file won't need any changes to turn it into
a plugin script, and the extra .conf file provides the menu location.
For the .tar file, there might be a fourth file that is like a "manifest"
so wings knows which plugin to ask about installing the .tar file.

An example package might have:

Code:
manifest
special_shape_bumpy.conf
special_shape_bumpy/special_shape_bumpy.wscr
special_shape_bumpy/special_shape_bumpy.py

the file special_shape_bumpy.conf might look like:

Code:
{"unique-script-name.author-name.special-shape-bumpy.1", [
    {wscr, "special_shape_bumpy/special_shape_bumpy.wscr"},
    {menu, [
        {[shape, special_shapes, special_shape_bumpy], []}
    ]}
]}.

{strings, [
    {plugin, "unique-script-name.author-name.special-shape-bumpy.1"},
    {"en", [
        {{plugin,name}, "Bumpy Shape"},
        {{menu,special_shapes}, "Special Shapes"},
        {{menu,special_shape_bumpy}, "Bumpy Shape"}
    ]}
]}.

Some explanations:

Code:
{wscr, "special_shape_bumpy/special_shape_bumpy.wscr"},
.wscr is in a subfolder "special_shape_bumpy" relative to the .conf file.

Code:
    {menu, [
        {[shape, special_shapes, special_shape_bumpy], []}
    ]}
It will be added to a menu "Bumpy Shape" inside a custom sub menu
called "Special Shapes", inside the new shape menu.

Code:
{strings, [
    {plugin, "unique-script-name.author-name.special-shape-bumpy.1"},
    {"en", [
        {{plugin,name}, "Bumpy Shape"},
        {{menu,special_shapes}, "Special Shapes"},
        {{menu,special_shape_bumpy}, "Bumpy Shape"}
    ]}
]}.
For each language a set of strings can be made. The unique
string "unique-script-name.author-name.special-shape-bumpy.1"
needs to match though.
ivla
Offline

Member

Posts: 62
Threads: 7
Joined: May 2023
#45
03-26-2025, 03:37 AM
edb, thank  you.
edb
Offline

Member

Posts: 135
Threads: 16
Joined: Nov 2022
#46
05-05-2025, 02:41 AM (This post was last modified: 05-05-2025, 03:34 AM by edb.)
A new build of the scripting plugin:

PLUGIN:
wpc_scripting_shapes.tar

PATCH:
patch_scripting.tar


Another change for this release.

The syntax of .wscr has changed slightly but only
if you were using parameter queries, now they have a
different syntax to distinguish them from strings and atoms
by enclosing the parameter query in %[...] instead of "...".
Atoms used to be enclosed with "'atom'", now they are
enclosed just with single quotes 'atom'.

As an example, this .wscr file for the milkshape exporter
used to look like this:

Code:
params_title ?__(3,"Milkshape3D Exporter Settings")
...
params_set {
  export_param "tesselation"  "'triangulate'"
  export_param "include_uvs"  "'true'"
  export_param "subdivisions" "params/subdivisions"
  export_param "include_normals" "'true'"
  export_param "include_hard_edges" "bool(params/include_normals)"
  export_param "script_texture_convert" "'user'"
}
...

Now the file will look like this:

Code:
params_title ?__(3,"Milkshape3D Exporter Settings")
...
params_set {
  export_param "tesselation"  'triangulate'
  export_param "include_uvs"  'true'
  export_param "subdivisions" %[params/subdivisions]
  export_param "include_normals" 'true'
  export_param "include_hard_edges" %[bool(params/include_normals)]
  export_param "script_texture_convert" 'user'
}
...
micheus
Offline

Forum's Admin and Support | Bug fixer
Posts: 3,676
Threads: 183
Joined: Jun 2012
#47
05-06-2025, 04:25 PM
Thanks for the update
[Image: tw.png] @MicheusVieira [Image: yt.png] @MicheusVieira [Image: da.png] Micheuss [Image: ig.png] micheus4wings3d
* Wings3D Team stands for: Björn and Dan
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (5): « Previous 1 2 3 4 5


  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D - Powered by MyBB

Linear Mode
Threaded Mode