A scripted Geometry plug-in is declared by specifying the <superclass> as geometry. Scripted Geometry plug-ins require a create tool unless they are invisible, temporary, or extend another plug-in. If the plug-in extends another plug-in, and a create tool is specified, it will override the delegate's create tool.
Example:
plugin geometry foo_plugin_def
name:"FooBar"
category:"Scripted Primitives"
(
boxes, clickAt
tool create
(
on mousePoint click do
(
clickAt = worldPoint
boxes = for i in 1 to 10 collect box pos:([i*20,0,0] + clickAt)
#stop
)
)
rollout frab "Parameters"
(
spinner frab "Frabulate" range:[-1000,1000,20]
on frab changed val do
for i in 1 to 10 do boxes[i].pos = [i*val,0,0] + clickAt
)
)
This adds a new geometry category with one button to the Create panel. Pressing the FooBar button starts a mouse command mode that creates a row of 10 boxes where you click and adds a rollout to the command panel with one spinner that lets you adjust the separation of the boxes. This is very similar to a System object like the RingArray, except it lives in the Geometry tab. This is the simplest type of scripted of plug-in; it has no specific scene object and no storable parameters.
In the tool handlers, you can set the delegate properties as needed. For example:
Example:
plugin geometry Cuboid
name:"Cuboid"
classID:#(0x133067, 0x54374)
category:"Scripted Primitives"
extends:Box
(
fmax val1 val2 = if val1 > val2 then val1 else val2
tool create
(
on mousePoint click do
case click of
(
1: nodeTM.translation = gridPoint
2: #stop
)
on mouseMove click do
if click == 2 then
delegate.width = delegate.length =
delegate.height = 2 * fmax (abs gridDist.x) (abs gridDist.y)
)
)
See also