This tool provides measuring tape functionality. Either individual buttons can be assigned for placement of the end points and clearing the measuring tape, or the cycle command can be used. The order of the cycle command is place the first point, place the second point, and the clear the line. When placing the first point the second point will automatically be placed directly orthogonal to/across from the first point. The measuring tape does not require that items be set and will work with any geometry in the scene. The ray from the measuring tape intersecting the scene comes along the positive z axis relative to the measuring tape node.
The following command creates a MeasuringTape object:
Command |
measuring_tape.MeasuringTape() |
The following methods are available on the MeasuringTape object:
Method |
Description |
<MeasuringTape>.setStartWall() |
Draws a ray and sets the starting position of the measuring tape at the intersection point. |
<MeasuringTape>.setEndWall() |
Draws a ray and sets the ending position of the measuring tape at the intersection point. |
<MeasuringTape>.clear() |
Clears the measuring tape. |
<MeasuringTape>.cycle() |
Cycles through the setStartWall, setEndWall, and clear commands. |
<MeasuringTape>.remove() |
Removes the measuring tape. |
<MeasuringTape>.setUpdateFunction(updateFunction) |
Sets the update function that gets called every frame. The update function calls methods on the tool based on the state of input devices. |
The following events are triggered when the start and end positions of the measuring tape are set:
Event |
Description |
measuring_tape.START_WALL_SET_EVENT |
This event is generated when the starting position of the measuring tape is set. It provides a single event structure e with the following attributes: e.intersection: A viz.Intersect object. See the table below for a list of fields contained in this object. e.distance: The length of the measuring tape line. |
measuring_tape.END_WALL_SET_EVENT |
This event is generated when the ending position of the measuring tape is set. It provides a single event structure e with the following attributes: e.intersection: A viz.Intersect object. See the table below for a list of fields contained in this object. e.distance: The length of the measuring tape line. |
The following is a list of fields of the viz.Intersect object:
Attribute |
Description |
valid |
True if the line intersected, False if it didn't. |
point |
The point the line intersected with the object. |
normal |
The normal vector of the intersect point. |
object |
The geometry object the line intersected with. |
name |
The name of the subobject that the line intersected with. |
In the following example the left mouse button calls the cycle command and shows how a single input signal can control the measuring tape. The cycle command cycles through the start,end, and clear commands. The '1','2','3' keys call the same start, end, and clear commands with different input signals. The advantage of calling the commands individually is the start/end positions of the tape can be dragged into position. Try holding the '1' or '2' key as you move the arrow to see this: