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


RE: Scripting with Scheme and Python - ivla - 10-02-2023

(10-02-2023, 07:39 AM)edb Wrote: Try the paths in the text boxes without double quotes.

It's working! Thank you very much!


RE: Scripting with Scheme and Python - ivla - 10-03-2023

Sorry but I come with yet another trouble. Simple python script for new shape creation does not create new shape.
Please help with troubleshooting.

Details:

Nothing in erlang console.

W3D log window:
wpc_scripting_shapes:command/3: bad return value: {shape,
                                                  {shape_from_script,
                                                    {{command_rec,
                                                      [["type","py"],
                                                      ["name","Test Shape"]],
                                                      "c:/Users/kav/Documents/new_shape_test/test_shape.py",
                                                      "py",[]},
                                                    []}}}

test_shape.py: (should generate 2x2 cube)

Code:
import w3d_e3d
import w3d_newshape
import sys
def mnewshape():
  mesh = w3d_e3d.E3DMesh()
  mesh.type = "polygon"
  mesh.vs = [(-1,1,-1),(-1,1,1),(1,1,-1),(1,1,1),(-1,-1,-1),(-1,-1,1),(1,-1,-1),(1,-1,1)]
  mesh.fs = [[0,1,2,3],[6,7,5,4],[1,0,4,5],[2,3,7,6],[0,2,6,4],[3,1,5,7]]
  e3d_o = w3d_e3d.E3DObject()
  e3d_o.obj = mesh
  e3d_o.name = "test mesh"
  nshp = w3d_newshape.NewShape()
  nshp.prefix = "test"
  nshp.obj = e3d_o
  o = nshp.as_output_list()
  o.write_list_out(sys.stdout)
w3d_main_function = mnewshape

test_shape.wscr:

type "py"
name ?__(1,"Test Shape")


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

ivla Wrote:Sorry but I come with yet another trouble. Simple python script for new shape creation does not create new shape.
Please help with troubleshooting.

I tested it and it seems there has to be at least one parameter, a bug in the script plugin, which I'll try to find time to fix soon.

Add to test_shape.wscr:
Code:
params {
  param "unused" "0"
}

After that the error is further into parts where the E3D that was constructed might cause errors, I recommend trying with the simpler NewShape form which only takes fs and vs.

Code:
  nshp = w3d_newshape.NewShape()
  nshp.prefix = "test"
  ## nshp.obj = e3d_o
  nshp.fs = ...
  nshp.vs = ...

Here I notice a combine_half_edges error, which might mean one of the faces might be facing the other direction.
You'll need to change the first face:
[0,1,2,3]
to
[0,1,3,2]

And the vertices have to be floats, it can cause weird errors in wings if there are integers in the mesh:
[(-1,1,-1),(-1,1,1),(1,1,-1),(1,1,1),(-1,-1,-1),(-1,-1,1),(1,-1,-1),(1,-1,1)]
now
[(-1.0,1.0,-1.0),(-1.0,1.0,1.0),(1.0,1.0,-1.0),(1.0,1.0,1.0),(-1.0,-1.0,-1.0),(-1.0,-1.0,1.0),(1.0,-1.0,-1.0),(1.0,-1.0,1.0)]



EDIT: I forgot to mention about the main function:

Code:
def mnewshape():
might be better as:
Code:
def mnewshape(params, params_by_key, extra_params):



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

Thank you, it works as expected.


RE: Scripting with Scheme and Python - ivla - 10-11-2023

Profiled thread generator:

.zip   thread.zip (Size: 2.31 KB / Downloads: 2)

Currently only ISO/DIN13 profile.


RE: Scripting with Scheme and Python - ivla - 10-11-2023

Two questions about it:
1. How to select or even visual define in-place the thread profile if there will be more than one?
2. How to construct the thread ends? I don't like the current way (especially upper end).


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

That looks great ivla.

The wscr doesn't yet have a way to choose from a list, I'd have to implement that.

You can add preview easily by adding to .wscr:
params_preview 1

I'm not sure of the best approach about the thread ends geometry, personally I'd probably try to triangulate it with a central point.


RE: Scripting with Scheme and Python - micheus - 10-13-2023

(10-11-2023, 10:42 AM)ivla Wrote: 2. How to construct the thread ends? I don't like the current way (especially upper end).
I don't know if that can help you to evaluate ways to construct it, but I just shared three type of bolts I've made starting from the Threads primitive (here).
I think that is something that require a good attention to get it right - I'm not sure that is possible to create and automatized way to build it for many cases.


RE: Scripting with Scheme and Python - ivla - 10-13-2023

(10-12-2023, 10:58 PM)edb Wrote: The wscr doesn't yet have a way to choose from a list, I'd have to implement that.
Thank you.
(10-12-2023, 10:58 PM)edb Wrote: try to triangulate it with a central point.
Looks as a good idea. I'll try.


RE: Scripting with Scheme and Python - ivla - 10-13-2023

(10-13-2023, 07:33 AM)micheus Wrote: I think that is something that require a good attention to get it right
I think it can be done by defining separate profiles for the first and last vertical sections of the thread... I'll try it.