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.
The error i get is:
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)