Layout Tools

Lightwave has been given the ability to create interactive tools with handles through Lscript. Examples of this are Plugins\Lscripts\utility\tool\ or included with 9.6. has comments on the functions called.

@script layouttool

This pragma indicates an lscript is a tool.
It then consists of a number of preset functions and UDFs. The preset functions are:

tooldraw: coa { }

This tells the script how to draw the handles in the viewport. The coa is an object agent for the 'cursor' handle for the script.


Sets the drawing Coordinate system to the item object agent's local coordinate system.

This sets an number of toggles using the sum of the toggle constants. These are:

So to set Depthtest and depthwrite you would write

This sets the colour to be drawn next, values being percentages.

This sets the type of line to be drawn next, values being:

drawLine(vec1,vec2, coordsys)

drawQuad(vec1,vec2,vec3,vec4, coordsys)
These two draw in the viewport using the Coordinate system and colour specified previously. The coordsys determines which plane to draw in and can be:
SYS_VIEWPORT or "viewport"
SYS_OBJECT or "object"

tooldown: te
toolmove: te
toolup: te

These UDFs tell the script what to do in the event of a button press by the user. tooldown is called on a mouse button down event. toolmove is called when the mouse is moved with a mousebutton down. toolup is called when the mouse button is released. te is the object agent for the mouse information. It will be useful in your script to have variables to keep track of when a handle has been moved or not, and which handle this was, as te does not have a member for this value.It has the following members.

Returns a value containing the @x,y,z@ of the mouse.

Returns a value containing the @x,y,z@ of the mouse click axis vector.

Returns a value containing the viewport id

In addition, a method has been added to the Scene() object to transform a position to a viewport position.

Returns the given position as a position in the given viewport eg.
mousepos = scene.viewportProject(te.viewNumber, mousepos);