• 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 Programming v
1 2 3 4 Next »
how to make plugins from the command line

 
  • 0 Vote(s) - 0 Average
how to make plugins from the command line

hartsantler
Offline

Junior Member

Posts: 8
Threads: 3
Joined: Sep 2018
#1
09-08-2018, 10:00 PM
I am trying to figure out how to create simple shapes from the command line (using expressions and not compiling it as a plugin), here is what i have so far that is not working yet.

Code:
BuildShape = fun(Prefix, Fs, Vs, PostFix) ->
    We = wings_we:build(Fs, Vs),
    Name = Prefix++PostFix,
    St = wpa:get_state(),
    Shapes0 = element(1, St),
    Shapes = gb_trees:insert(0, We, Shapes0),
    erlang:setelement(1, St, Shapes) end.

Tetrahedron = fun(L, PostFix) ->
    Xi = L/2.0,
    Hp = math:sqrt(3.0),
    Li = Xi*Hp,
    Zi = Xi/Hp,
    Yi = L * math:sqrt(2.0/3.0),
    Yf = Yi / 3.0,

    Fs = [[2,1,0],[1,2,3],[1,3,0],[3,2,0]],
    Vs0 = [{ 0.0,  Yi-Yf,  0.0},
       { 0.0, -Yf,   Li-Zi},
       { -Xi, -Yf,     -Zi},
       {  Xi, -Yf,     -Zi}],
    BuildShape("tetrahedron", Fs, Vs0, PostFix) end.

Tetrahedron(1.0, "1").

The error i get is:
Code:
** exception error: no function clause matching
                    gb_trees:insert(0,
                                    {we,undefined,0,[],
                                     {array,6,10,undefined,
                                      {{edge,0,1,2,0,4,2,1,3},
                                       {edge,0,2,0,3,3,0,2,5},
                                       {edge,0,3,3,2,5,1,0,4},
                                       {edge,1,2,1,0,5,4,0,1},
                                       {edge,1,3,2,1,2,0,3,5},
                                       {edge,2,3,1,3,4,3,1,2},
                                       undefined,undefined,undefined,
                                       undefined}},
                                     none,none,
                                     {4,
                                      {2,0,
                                       {1,3,{0,0,nil,nil},nil},
                                       {3,1,nil,nil}}},
                                     {0,nil},
                                     {array,4,10,undefined,
                                      {0,0,1,2,undefined,undefined,undefined,
                                       undefined,undefined,undefined}},
                                     {array,4,10,undefined,
                                      {{0.0,0.5443310539518174,0.0},
                                       {0.0,-0.2721655269759087,
                                        0.5773502691896257},
                                       {-0.5,-0.2721655269759087,
                                        -0.2886751345948129},
                                       {0.5,-0.2721655269759087,
                                        -0.2886751345948129},
                                       undefined,undefined,undefined,
                                       undefined,undefined,undefined}},
                                     {0,nil},
                                     default,6,none,none,[]},
                                    st) (gb_trees.erl, line 276)
micheus
Offline

Forum's Admin and Support | Bug fixer
Posts: 3,675
Threads: 183
Joined: Jun 2012
#2
09-08-2018, 11:08 PM
I think it can be related to the same problem you have been experiencing in the other topic. Anyway, did you already took a look at this article: http://scorpius.github.io/tut-wings-shell.htm
If not, maybe it can help you.
[Image: tw.png] @MicheusVieira [Image: yt.png] @MicheusVieira [Image: da.png] Micheuss [Image: ig.png] micheus4wings3d
* Wings3D Team stands for: Björn and Dan
hartsantler
Offline

Junior Member

Posts: 8
Threads: 3
Joined: Sep 2018
#3
09-20-2019, 03:59 AM
Im still interested in automating Wings from the command line, but didn't have any luck hacking the source code directly. It would be great to have support for a simple macro language that could be used to generate models from the command line. Something like:
wings.exe --script "make_cube(x,y,z);scale(x,y,z);move_point(index,x,y,z);color_face(index,r,g,b);save_as('foo.wings');"
micheus
Offline

Forum's Admin and Support | Bug fixer
Posts: 3,675
Threads: 183
Joined: Jun 2012
#4
09-20-2019, 04:47 PM
Hi hartsantler
Did you already checked the erlang script that dgud included in the sources? It's called wings_convert.erl and there is some conversation about it in this feature request post.

I think that may help you, but please let we know if not.
[Image: tw.png] @MicheusVieira [Image: yt.png] @MicheusVieira [Image: da.png] Micheuss [Image: ig.png] micheus4wings3d
* Wings3D Team stands for: Björn and Dan
hartsantler
Offline

Junior Member

Posts: 8
Threads: 3
Joined: Sep 2018
#5
09-21-2019, 04:47 PM
i saw that post, and have read wings_convert.erl. And that solution would work fine for me locally on my machine, but what about windows users? Its too much to ask them to install an erlang environment.
micheus
Offline

Forum's Admin and Support | Bug fixer
Posts: 3,675
Threads: 183
Joined: Jun 2012
#6
09-21-2019, 09:20 PM
Understood.

I did a test here and I got a code working using my dev environment (MSys), but not using the built version.
I use this command line:
werl +S1 -pa /F/unixlike/src/wings/ebin -run wings_start start -extra --script 'make_cube(x,y,z);scale(x,y,z);move_point(index,x,y,z);color_face(index,r,g,b);save_as(foo.wings);'

But, a Windows shortcut adjusted to use the werl.exe under Wings3D install dir didn't work. Only dgud can help with that because it's beyond my erlang knowledge. Smile

If the any parameter would be catch by Wings3D, then you can just write a plugin to handle your script.
I added the code below to my w.i.p. plugin:
PHP Code:
init() ->
    
Script = pick_script(init:get_plain_arguments()),
    
io:format("\nScript: ~p\nCommands:\n",[Script]),
    
Commands = string:split(Script,";",all),
    [
io:format(" => ~s\n",[Cmd]) || Cmd <- Commands,  string:trim(Cmd)=/=""],
    ...
    
true.

pick_script([]) -> [];
pick_script(["script"|Params]) ->
    [
Script|_] = Params,
    
Script;
pick_script([_|Params]) ->
    
pick_script(Params). 

and the log got this printed out:
Code:
Script: "make_cube(x,y,z);scale(x,y,z);move_point(index,x,y,z);color_face(index,r,g,b);save_as(foo.wings);"
Commands:
=> make_cube(x,y,z)
=> scale(x,y,z)
=> move_point(index,x,y,z)
=> color_face(index,r,g,b)
=> save_as(foo.wings)
[Image: tw.png] @MicheusVieira [Image: yt.png] @MicheusVieira [Image: da.png] Micheuss [Image: ig.png] micheus4wings3d
* Wings3D Team stands for: Björn and Dan
dgud
Offline

Grumpy Dev
Posts: 692
Threads: 37
Joined: Nov 2012
#7
09-23-2019, 06:46 AM (This post was last modified: 09-23-2019, 06:47 AM by dgud.)
I have added the needed things to the wings installer so (after next release) you should be able to run,
the wings_convert script from command line without installing erlang, if I have done it correct :-)

Some hacks are involved, so to run other scripts you will have to run:
wings/bin/escript.exe <your_escript>
hartsantler
Offline

Junior Member

Posts: 8
Threads: 3
Joined: Sep 2018
#8
09-24-2019, 02:43 AM
@micheus and @dgud, you guys are awesome!
dgud
Offline

Grumpy Dev
Posts: 692
Threads: 37
Joined: Nov 2012
#9
12-09-2019, 07:43 AM
Please test, 2.2.5 :-)
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



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

© Designed by D&D - Powered by MyBB

Linear Mode
Threaded Mode