Wings 3D Development Forum

Full Version: batch importer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to figure out how to batch import multiple obj and collada files when wings starts up.
I'm new to erlang, and taken a look at the code in: e3d_obj.erl, wings_console.erl, wings_start.erl, wpa.erl, wpc_collada.erl, and wings_plugin.erl.

So far i have this code, which loads my obj, but then fails to update the view or show it in the Wings UI. What am i missing?

Code:
{ok, E3DFile} = e3d_obj:import("/home/username/test.obj").
St0 = wpa:get_state().
wings_import:import(E3DFile, St0).

https://github.com/dgud/wings/issues/298
I'm not expert, so maybe my suggestion can not to work. Smile

Import will return the new #st{}, then maybe you just need to update it by send that information to the main geometry window who handle most the command messages:
Code:
...
St = wings_import:import(E3DFile, St0),
wings_wm:send_after_redraw(geom, {update_state,St}).
actually i'm getting an error from `wings_import:import(E3dFile, wpa:get_state()).`
the error is:
Code:
** exception error: no function clause matching
                    gb_trees:get_1(wings_shape,nil) (gb_trees.erl, line 244)
     in function  wings_shape:new/3 (wings_shape.erl, line 64)
     in call from wings_import:translate_objects/7 (wings_import.erl, line 46)
     in call from wings_import:import/2 (wings_import.erl, line 31)
Did you already tried to print out the value of St0 in the line bellow?
St0 = wpa:get_state().
printing St0 gives this:
Code:
{st,
                              {0,nil},
                              face,false,[],
                              {0,nil},
                              none,
                              {1,
                               {default,
                                [{maps,[]},
                                 {opengl,
                                  [{ambient,
                                    {0.7898538076923077,0.8133333333333334,
                                     0.6940444444444445,1.0}},
                                   {diffuse,
                                    {0.7898538076923077,0.8133333333333334,
                                     0.6940444444444445,1.0}},
                                   {emission,{0.0,0.0,0.0,1.0}},
                                   {shininess,0.0},
                                   {specular,{0.0,0.0,...}},
                                   {vertex_colors,set}]}],
                                nil,nil}},
                              [],undefined,false,1,none,none,
                              {0,{}},
                              {0,nil},
                              ignore,undefined,undefined,
                              {ignore,ignore},
                              empty_scene,
                              {[],[]},
                              true,[]}])
Yeap, it's a invalid (null) #st{}