[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [femm] obtaining node co-ordinates



James Pawson wrote:
I'm using a basic LUA file in BELA to start evaluating its scripting
capabilities.

When I call showmesh() from the console or script file, the mesh
appears and then as the view is refreshed, disappears agian.

It's just a minor niggle, but does anyone know a way around it?

LUA file being used

-- Run "triangle" to generate a mesh
createmesh()

-- show the mesh in BELAdraw
showmesh()
The "showmesh" command actually toggles the state of some internal variable called showmesh which determines whether or no the mesh is shown.  By default, "createmesh" shows the mesh that it creates.  So, by calling createmesh() and then showmesh(), you're actually telling it to not display the mesh.  If you want to make a mesh and have it displayed, just calle createmesh() alone.

In addition to my first question, I have another (this is the first
time I've used BELA)

I want to obtain the x,y co-ordinates for a selected node in LUA.

There is already the facility to select the node nearest to a set of
given x,y co-ordinates using the  selectnode() command, but I want to
extract the exact co-ordinates of the selected node

Can anyone help?
There currently isn't a built-in way of doing that, but it would be easy to modify the implementation of the selectnode() command to return the coordinates of the selected node.  At the end of the lua_selectnode implemenation in luadoc.cpp, just replace:
return 0;
with
lua_pushnumber(L,thisDoc->nodelist[node].x);
lua_pushnumber(L,thisDoc->nodelist[node].y);
return 2;
and recompile.  This would then return the coordinates of the selected node.