Examples are OUTDATED, currently supported format version >= "0.2"
Draw rectangle tool
https://user-images.githubusercontent.com/11227020/217048634-6be97df5-f201-433e-afa6-fd96c34e24ab.mp4
{
id = "draw-rectangle-tool",
formatVersion = "0.1",
stateMachine = {
data = {
parameters = {
b = {
type = "point-projected-to-ray",
point = { type = "point", id = "c" },
ray = [{ type = "point", id = "a" }, { type = "vector", id = "xAxis" }],
},
c = { type = "cursor" },
d = {
type = "point-projected-to-ray",
point = { type = "point", id = "c" },
ray = [{ type = "point", id = "a" }, { type = "vector", id = "yAxis" }],
},
xAxis = { type = "vector-value", value = [1, 0, 0] },
yAxis = { type = "vector-value", value = [0, 1, 0] },
}
},
states = [
{
id = "0",
visuals = [{ type = "dot", geometry = { type = "cursor" } },],
},
{
id = "1",
visuals = [
{ type = "dot", geometry = { type = "point", id = "a" } },
{ type = "dot", geometry = { type = "point", id = "b" } },
{ type = "dot", geometry = { type = "point", id = "c" } },
{ type = "dot", geometry = { type = "point", id = "d" } },
{ type = "line", geometry = [{ type = "point", id = "a" }, { type = "point", id = "b" }] },
{ type = "line", geometry = [{ type = "point", id = "b" }, { type = "point", id = "c" }] },
{ type = "line", geometry = [{ type = "point", id = "c" }, { type = "point", id = "d" }] },
{ type = "line", geometry = [{ type = "point", id = "d" }, { type = "point", id = "a" }] },
{ type = "triangle-fan", geometry = [{ type = "point", id = "a" }, { type = "point", id = "b" }, { type = "point", id = "c" }, { type = "point", id = "d" }], options = { color = "#778187", opacity = 0.8 } },
],
},
{
id = "2",
visuals = [
{ type = "dot", geometry = { type = "point", id = "a" } },
{ type = "dot", geometry = { type = "point", id = "b" } },
{ type = "dot", geometry = { type = "point", id = "c" } },
{ type = "dot", geometry = { type = "point", id = "d" } },
{ type = "line", geometry = [{ type = "point", id = "a" }, { type = "point", id = "b" }] },
{ type = "line", geometry = [{ type = "point", id = "b" }, { type = "point", id = "c" }] },
{ type = "line", geometry = [{ type = "point", id = "c" }, { type = "point", id = "d" }] },
{ type = "line", geometry = [{ type = "point", id = "d" }, { type = "point", id = "a" }] },
{ type = "triangle-fan", geometry = [{ type = "point", id = "a" }, { type = "point", id = "b" }, { type = "point", id = "c" }, { type = "point", id = "d" }], options = { color = "#778187" } },
],
},
],
transitions = [
{
from = "0",
to = "1",
condition = {
type = "enter-point",
point = { type = "cursor" },
saveAsPointId = "a",
},
},
{
from = "1",
to = "2",
condition = {
type = "enter-point",
point = { type = "cursor" },
saveAsPointId = "c",
},
},
],
initState = "0",
finalStates = ["2"],
}
}
Draw volume tool
https://user-images.githubusercontent.com/11227020/217048671-68636545-77ca-457e-8512-b22bce5641a1.mp4
{
id = "draw-volume-tool",
formatVersion = "0.1",
stateMachine = {
data = {
parameters = {
xAxis = { type = "vector-value", value = [1, 0, 0] },
yAxis = { type = "vector-value", value = [0, 1, 0] },
zAxis = { type = "vector-value", value = [0, 0, 1] },
snapPoints = { type = "point-values", values = [0, 0, 0], [10, 10, 10](/HiStructClient/femcad-doc/wiki/0,-0,-0],-[10,-10,-10) },
firstPoint = { type = "cursor" },
secondPoint = { type = "cursor" },
thirdPoint = {
type = "point-projected-to-ray",
point = { type = "point-projected-to-plane", point = { type = "cursor" }, plane = [{ type = "point", id = "secondPoint" }, { type = "camera-azimuth" }] },
ray = [{ type = "point", id = "secondPoint" }, { type = "vector", id = "zAxis" }],
clampToStart = true,
},
a = { type = "point", id = "firstPoint" },
b = { type = "point-projected-to-ray", point = { type = "point", id = "c" }, ray = [{ type = "point", id = "a" }, { type = "vector", id = "yAxis" }] },
c = { type = "point", id = "secondPoint" },
d = { type = "point-projected-to-ray", point = { type = "point", id = "c" }, ray = [{ type = "point", id = "a" }, { type = "vector", id = "xAxis" }] },
e = { type = "point-projected-to-ray", point = { type = "point", id = "g" }, ray = [{ type = "point", id = "a" }, { type = "vector", id = "zAxis" }] },
f = { type = "point-projected-to-ray", point = { type = "point", id = "g" }, ray = [{ type = "point", id = "b" }, { type = "vector", id = "zAxis" }] },
g = { type = "point", id = "thirdPoint" },
h = { type = "point-projected-to-ray", point = { type = "point", id = "g" }, ray = [{ type = "point", id = "d" }, { type = "vector", id = "zAxis" }] },
},
},
states = [
{
id = "0"
},
{
id = "1",
visuals = [
{ type = "line", geometry = [{ type = "point", id = "a" }, { type = "point", id = "b" }] },
{ type = "line", geometry = [{ type = "point", id = "b" }, { type = "point", id = "c" }] },
{ type = "line", geometry = [{ type = "point", id = "c" }, { type = "point", id = "d" }] },
{ type = "line", geometry = [{ type = "point", id = "d" }, { type = "point", id = "a" }] },
{ type = "triangle-fan", geometry = [{ type = "point", id = "a" }, { type = "point", id = "b" }, { type = "point", id = "c" }, { type = "point", id = "d" }], options = { opacity = 0.5 } },
]
},
{
id = "2",
visuals = [
{ type = "line", geometry = [{ type = "point", id = "a" }, { type = "point", id = "b" }] },
{ type = "line", geometry = [{ type = "point", id = "b" }, { type = "point", id = "c" }] },
{ type = "line", geometry = [{ type = "point", id = "c" }, { type = "point", id = "d" }] },
{ type = "line", geometry = [{ type = "point", id = "d" }, { type = "point", id = "a" }] },
{ type = "triangle-fan", geometry = [{ type = "point", id = "a" }, { type = "point", id = "b" }, { type = "point", id = "c" }, { type = "point", id = "d" }], options = { opacity = 0.5 } },
{ type = "line", geometry = [{ type = "point", id = "a" }, { type = "point", id = "e" }] },
{ type = "line", geometry = [{ type = "point", id = "b" }, { type = "point", id = "f" }] },
{ type = "line", geometry = [{ type = "point", id = "c" }, { type = "point", id = "g" }] },
{ type = "line", geometry = [{ type = "point", id = "d" }, { type = "point", id = "h" }] },
{ type = "line", geometry = [{ type = "point", id = "e" }, { type = "point", id = "f" }] },
{ type = "line", geometry = [{ type = "point", id = "f" }, { type = "point", id = "g" }] },
{ type = "line", geometry = [{ type = "point", id = "g" }, { type = "point", id = "h" }] },
{ type = "line", geometry = [{ type = "point", id = "h" }, { type = "point", id = "e" }] },
{ type = "triangle-fan", geometry = [{ type = "point", id = "e" }, { type = "point", id = "f" }, { type = "point", id = "g" }, { type = "point", id = "h" }], options = { opacity = 0.5 } },
{ type = "triangle-fan", geometry = [{ type = "point", id = "a" }, { type = "point", id = "b" }, { type = "point", id = "f" }, { type = "point", id = "e" }], options = { opacity = 0.5 } },
{ type = "triangle-fan", geometry = [{ type = "point", id = "b" }, { type = "point", id = "c" }, { type = "point", id = "g" }, { type = "point", id = "f" }], options = { opacity = 0.5 } },
{ type = "triangle-fan", geometry = [{ type = "point", id = "c" }, { type = "point", id = "d" }, { type = "point", id = "h" }, { type = "point", id = "g" }], options = { opacity = 0.5 } },
{ type = "triangle-fan", geometry = [{ type = "point", id = "d" }, { type = "point", id = "a" }, { type = "point", id = "e" }, { type = "point", id = "h" }], options = { opacity = 0.5 } },
]
},
{
id = "3",
visuals = [
{ type = "line", geometry = [{ type = "point", id = "a" }, { type = "point", id = "b" }] },
{ type = "line", geometry = [{ type = "point", id = "b" }, { type = "point", id = "c" }] },
{ type = "line", geometry = [{ type = "point", id = "c" }, { type = "point", id = "d" }] },
{ type = "line", geometry = [{ type = "point", id = "d" }, { type = "point", id = "a" }] },
{ type = "triangle-fan", geometry = [{ type = "point", id = "a" }, { type = "point", id = "b" }, { type = "point", id = "c" }, { type = "point", id = "d" }] },
{ type = "line", geometry = [{ type = "point", id = "a" }, { type = "point", id = "e" }] },
{ type = "line", geometry = [{ type = "point", id = "b" }, { type = "point", id = "f" }] },
{ type = "line", geometry = [{ type = "point", id = "c" }, { type = "point", id = "g" }] },
{ type = "line", geometry = [{ type = "point", id = "d" }, { type = "point", id = "h" }] },
{ type = "line", geometry = [{ type = "point", id = "e" }, { type = "point", id = "f" }] },
{ type = "line", geometry = [{ type = "point", id = "f" }, { type = "point", id = "g" }] },
{ type = "line", geometry = [{ type = "point", id = "g" }, { type = "point", id = "h" }] },
{ type = "line", geometry = [{ type = "point", id = "h" }, { type = "point", id = "e" }] },
{ type = "triangle-fan", geometry = [{ type = "point", id = "e" }, { type = "point", id = "f" }, { type = "point", id = "g" }, { type = "point", id = "h" }] },
{ type = "triangle-fan", geometry = [{ type = "point", id = "a" }, { type = "point", id = "b" }, { type = "point", id = "f" }, { type = "point", id = "e" }] },
{ type = "triangle-fan", geometry = [{ type = "point", id = "b" }, { type = "point", id = "c" }, { type = "point", id = "g" }, { type = "point", id = "f" }] },
{ type = "triangle-fan", geometry = [{ type = "point", id = "c" }, { type = "point", id = "d" }, { type = "point", id = "h" }, { type = "point", id = "g" }] },
{ type = "triangle-fan", geometry = [{ type = "point", id = "d" }, { type = "point", id = "a" }, { type = "point", id = "e" }, { type = "point", id = "h" }] },
]
},
],
transitions = [
{
from = "0",
to = "1",
condition = {
type = "enter-point",
point = { type = "point", id = "firstPoint" },
saveAsPointId = "firstPoint"
},
visuals = [{ type = "dot", geometry = { type = "point", id = "firstPoint" } }]
},
{
from = "0",
to = "1",
condition = {
type = "select-point",
point = { type = "point", id = "snapPoints" },
saveAsPointId = "firstPoint"
},
visuals = [{ type = "dot", geometry = { type = "point", id = "firstPoint" }, options = { color = "yellow" } }]
},
{
from = "1",
to = "2",
condition = {
type = "enter-point",
point = { type = "point", id = "secondPoint" },
saveAsPointId = "secondPoint"
},
visuals = [{ type = "dot", geometry = { type = "point", id = "secondPoint" } }]
},
{
from = "1",
to = "2",
condition = {
type = "select-point",
point = { type = "point", id = "snapPoints" },
saveAsPointId = "secondPoint"
},
visuals = [{ type = "dot", geometry = { type = "point", id = "secondPoint" }, options = { color = "yellow" } }]
},
{
from = "2",
to = "3",
condition = {
type = "enter-point",
point = { type = "point", id = "thirdPoint" },
saveAsPointId = "thirdPoint"
}
}
],
initState = "0",
finalStates = ["3"],
},
}
Dimension tool
https://user-images.githubusercontent.com/11227020/217048754-1b2fc6d4-7c6b-43ef-9a0a-530c8cda9fce.mp4
{
id = "dimension-tool",
formatVersion = "0.1",
stateMachine = {
data = {
parameters = {
bbox = { type = "point-values", values = bboxPoints },
dimNormal = { type = "perpendicular-vector", line = [{ type = "point", id = "firstPoint" }, { type = "point", id = "secondPoint" }] },
pointer = {
type = "point-projected-to-plane", point = { type = "cursor" }, plane = [{ type = "point", id = "secondPoint" }, { type = "vector-value", value = [0, 0, 1] }]
},
pointerY = {
type = "point-projected-to-plane", point = { type = "cursor" }, plane = [{ type = "point", id = "secondPoint" }, { type = "vector", id = "dimNormal" }]
},
dimPoint1 = {
type = "point-projected-to-ray", point = { type = "point", id = "pointer" }, ray = [{ type = "point", id = "firstPoint" }, { type = "vector", id = "dimNormal" }]
},
dimPoint2 = {
type = "point-projected-to-ray", point = { type = "point", id = "pointer" }, ray = [{ type = "point", id = "secondPoint" }, { type = "vector", id = "dimNormal" }]
},
dimPoint1Y = {
type = "point-projected-to-ray", point = { type = "point", id = "pointerY" }, ray = [{ type = "point", id = "firstPoint" }, { type = "vector-value", value = [0, 0, 1] }], clampToStart = True
},
dimPoint2Y = {
type = "point-projected-to-ray", point = { type = "point", id = "pointerY" }, ray = [{ type = "point", id = "secondPoint" }, { type = "vector-value", value = [0, 0, 1] }], clampToStart = True
},
dimPoint1Plus = {
type = "point-on-line-segment", line = [{ type = "point", id = "firstPoint" }, { type = "point", id = "dimPoint1" }], fromEnd = 0.2,
},
dimPoint2Plus = {
type = "point-on-line-segment", line = [{ type = "point", id = "secondPoint" }, { type = "point", id = "dimPoint2" }], fromEnd = 0.2,
},
dimPoint1YPlus = {
type = "point-on-line-segment", line = [{ type = "point", id = "firstPoint" }, { type = "point", id = "dimPoint1Y" }], fromEnd = 0.2,
},
dimPoint2YPlus = {
type = "point-on-line-segment", line = [{ type = "point", id = "secondPoint" }, { type = "point", id = "dimPoint2Y" }], fromEnd = 0.2,
},
dimNormalZ = { type = "parallel-vector", line = [{ type = "point", id = "secondPoint" }, { type = "point", id = "thirdPoint" }] },
dimPoint1Final = {
type = "point-projected-to-ray", point = { type = "point", id = "thirdPoint" }, ray = [{ type = "point", id = "firstPoint" }, { type = "vector", id = "dimNormalZ" }]
},
dimPoint2Final = {
type = "point-projected-to-ray", point = { type = "point", id = "thirdPoint" }, ray = [{ type = "point", id = "secondPoint" }, { type = "vector", id = "dimNormalZ" }]
},
dimPoint1FinalPlus = {
type = "point-on-line-segment", line = [{ type = "point", id = "firstPoint" }, { type = "point", id = "dimPoint1Final" }], fromEnd = 0.2,
},
dimPoint2FinalPlus = {
type = "point-on-line-segment", line = [{ type = "point", id = "secondPoint" }, { type = "point", id = "dimPoint2Final" }], fromEnd = 0.2,
},
}
},
states = [
{
id = "0",
},
{
id = "1",
visuals = [
{
type = "dot",
geometry = { type = "point", id = "firstPoint" },
},
]
},
{
id = "2",
},
{
id = "3",
visuals = [
{
type = "line",
geometry = [{ type = "point", id = "firstPoint" }, { type = "point", id = "dimPoint1FinalPlus" }],
},
{
type = "line",
geometry = [{ type = "point", id = "secondPoint" }, { type = "point", id = "dimPoint2FinalPlus" }],
},
{
type = "line",
geometry = [{ type = "point", id = "dimPoint1Final" }, { type = "point", id = "dimPoint2Final" }],
},
],
}
],
transitions = [
{
from = "0",
to = "1",
condition = {
type = "select-point",
point = { type = "point", id = "bbox", range = ".." },
saveAsPointId = "firstPoint",
},
visuals = [
{ type = "dot", geometry = { type = "point", id = "firstPoint" }, options = { alwaysVisible = True } }
],
},
{
from = "0",
to = "2",
condition = {
type = "enter-text",
key = "fdf"
},
},
{
from = "1",
to = "2",
condition = {
type = "select-point",
point = { type = "point", id = "bbox", range = ".." },
saveAsPointId = "secondPoint",
},
visuals = [
{ type = "dot", geometry = { type = "point", id = "secondPoint" }, options = { alwaysVisible = True } }
],
},
{
from = "2",
to = "3",
condition = {
type = "enter-point",
point = { type = "point", id = "dimPoint2" },
saveAsPointId = "thirdPoint",
},
visuals = [
{
type = "line",
geometry = [{ type = "point", id = "firstPoint" }, { type = "point", id = "dimPoint1Plus" }],
},
{
type = "line",
geometry = [{ type = "point", id = "secondPoint" }, { type = "point", id = "dimPoint2Plus" }],
},
{
type = "line",
geometry = [{ type = "point", id = "dimPoint1" }, { type = "point", id = "dimPoint2" }],
},
]
},
{
from = "2",
to = "3",
condition = {
type = "enter-point",
point = { type = "point", id = "dimPoint2Y" },
saveAsPointId = "thirdPoint",
},
visuals = [
{
type = "line",
geometry = [{ type = "point", id = "firstPoint" }, { type = "point", id = "dimPoint1YPlus" }],
},
{
type = "line",
geometry = [{ type = "point", id = "secondPoint" }, { type = "point", id = "dimPoint2YPlus" }],
},
{
type = "line",
geometry = [{ type = "point", id = "dimPoint1Y" }, { type = "point", id = "dimPoint2Y" }],
},
]
},
],
initState = "0",
finalStates = ["3"],
},
}
Simple dimension tool
https://user-images.githubusercontent.com/11227020/218409324-35baf62e-f261-4a79-9036-6526cc9323d9.mp4
{
id = "simple-dimension-tool",
formatVersion = "0.1",
stateMachine = {
data = {
parameters = {
bbox = {
type = "point-values",
values = bboxPoints
},
dimNormal = {
type = "perpendicular-vector",
line = [
{
type = "point",
id = "firstPoint"
},
{
type = "point",
id = "secondPoint"
}
]
},
pointer = {
type = "point-projected-to-plane",
point = {
type = "cursor"
},
plane = [
{
type = "point",
id = "secondPoint"
},
{
type = "vector-value",
value = [
0,
0,
1
]
}
]
},
dimPoint1 = {
type = "point-projected-to-ray",
point = {
type = "point",
id = "pointer"
},
ray = [
{
type = "point",
id = "firstPoint"
},
{
type = "vector",
id = "dimNormal"
}
]
},
dimPoint2 = {
type = "point-projected-to-ray",
point = {
type = "point",
id = "pointer"
},
ray = [
{
type = "point",
id = "secondPoint"
},
{
type = "vector",
id = "dimNormal"
}
]
},
dimPoint1Final = {
type = "point-projected-to-ray",
point = {
type = "point",
id = "thirdPoint"
},
ray = [
{
type = "point",
id = "firstPoint"
},
{
type = "vector",
id = "dimNormal"
}
]
},
dimPoint2Final = {
type = "point-projected-to-ray",
point = {
type = "point",
id = "thirdPoint"
},
ray = [
{
type = "point",
id = "secondPoint"
},
{
type = "vector",
id = "dimNormal"
}
]
}
}
},
states = [
{
id = "0"
},
{
id = "1",
visuals = [
{
type = "dot",
geometry = {
type = "point",
id = "firstPoint"
}
}
]
},
{
id = "2"
},
{
id = "3",
visuals = [
{
type = "line",
geometry = [
{
type = "point",
id = "firstPoint"
},
{
type = "point",
id = "dimPoint1Final"
}
]
},
{
type = "line",
geometry = [
{
type = "point",
id = "secondPoint"
},
{
type = "point",
id = "dimPoint2Final"
}
]
},
{
type = "line",
geometry = [
{
type = "point",
id = "dimPoint1Final"
},
{
type = "point",
id = "dimPoint2Final"
}
]
}
]
}
],
transitions = [
{
from = "0",
to = "1",
condition = {
type = "select-point",
point = {
type = "point",
id = "bbox",
range = ".."
},
saveAsPointId = "firstPoint"
},
visuals = [
{
type = "dot",
geometry = {
type = "point",
id = "firstPoint"
}
}
]
},
{
from = "0",
to = "2",
condition = {
type = "enter-text",
key = "fdf"
}
},
{
from = "1",
to = "2",
condition = {
type = "select-point",
point = {
type = "point",
id = "bbox",
range = ".."
},
saveAsPointId = "secondPoint"
},
visuals = [
{
type = "dot",
geometry = {
type = "point",
id = "secondPoint"
}
}
]
},
{
from = "2",
to = "3",
condition = {
type = "enter-point",
point = {
type = "point",
id = "dimPoint2"
},
saveAsPointId = "thirdPoint"
},
visuals = [
{
type = "line",
geometry = [
{
type = "point",
id = "firstPoint"
},
{
type = "point",
id = "dimPoint1"
}
]
},
{
type = "line",
geometry = [
{
type = "point",
id = "secondPoint"
},
{
type = "point",
id = "dimPoint2"
}
]
},
{
type = "line",
geometry = [
{
type = "point",
id = "dimPoint1"
},
{
type = "point",
id = "dimPoint2"
}
]
}
]
}
],
initState = "0",
finalStates = [
"3"
]
}
}
Dimension tool with axes projections
https://user-images.githubusercontent.com/11227020/218794045-a5f49c41-8edb-49a4-a4db-44df4f1f2bfa.mp4
dimensionToolActionScriptDefinition := {
id = "dimension-tool-with-axes-projections",
formatVersion = "0.1",
stateMachine = {
data = {
parameters = {
bbox = { type = "point-values", values = bboxPoints },
dimNormal = { type = "perpendicular-vector", line = [{ type = "point", id = "firstPoint" }, { type = "point", id = "secondPoint" }] },
xAxis = { type = "vector-value", value = [1, 0, 0] },
yAxis = { type = "vector-value", value = [0, 1, 0] },
thirdPoint = {
type = "point-projected-to-plane", point = { type = "cursor" }, plane = [{ type = "point", id = "secondPoint" }, { type = "vector-value", value = [0, 0, 1] }]
},
dimPoint1 = {
type = "point-projected-to-ray", point = { type = "point", id = "thirdPoint" }, ray = [{ type = "point", id = "firstPoint" }, { type = "vector", id = "dimNormal" }]
},
dimPoint2 = {
type = "point-projected-to-ray", point = { type = "point", id = "thirdPoint" }, ray = [{ type = "point", id = "secondPoint" }, { type = "vector", id = "dimNormal" }]
},
dimPoint1X = {
type = "point-projected-to-ray", point = { type = "point", id = "thirdPoint" }, ray = [{ type = "point", id = "firstPoint" }, { type = "vector", id = "xAxis" }]
},
dimPoint2X = {
type = "point-projected-to-ray", point = { type = "point", id = "thirdPoint" }, ray = [{ type = "point", id = "secondPoint" }, { type = "vector", id = "xAxis" }]
},
dimPoint1Y = {
type = "point-projected-to-ray", point = { type = "point", id = "thirdPoint" }, ray = [{ type = "point", id = "firstPoint" }, { type = "vector", id = "yAxis" }]
},
dimPoint2Y = {
type = "point-projected-to-ray", point = { type = "point", id = "thirdPoint" }, ray = [{ type = "point", id = "secondPoint" }, { type = "vector", id = "yAxis" }]
},
dimPoint1Final = {
type = "point-projected-to-ray", point = { type = "point", id = "thirdPoint" }, ray = [{ type = "point", id = "firstPoint" }, { type = "parallel-vector", line = [{ type = "point", id = "secondPoint" }, { type = "point", id = "thirdPoint" }] }]
},
dimPoint2Final = { type = "point", id = "thirdPoint" },
}
},
states = [
{
id = "0",
},
{
id = "1",
visuals = [
{
type = "dot",
geometry = { type = "point", id = "firstPoint" },
},
]
},
{
id = "2",
},
{
id = "3",
visuals = [
{
type = "line",
geometry = [{ type = "point", id = "firstPoint" }, { type = "point", id = "dimPoint1Final" }],
},
{
type = "line",
geometry = [{ type = "point", id = "secondPoint" }, { type = "point", id = "dimPoint2Final" }],
},
{
type = "line",
geometry = [{ type = "point", id = "dimPoint1Final" }, { type = "point", id = "dimPoint2Final" }],
},
],
}
],
transitions = [
{
from = "0",
to = "1",
condition = {
type = "select-point",
point = { type = "point", id = "bbox", range = ".." },
saveAsPointId = "firstPoint",
},
visuals = [
{ type = "dot", geometry = { type = "point", id = "firstPoint" } }
],
},
{
from = "0",
to = "2",
condition = {
type = "enter-text",
key = "fdf"
},
},
{
from = "1",
to = "2",
condition = {
type = "select-point",
point = { type = "point", id = "bbox", range = ".." },
saveAsPointId = "secondPoint",
},
visuals = [
{ type = "dot", geometry = { type = "point", id = "secondPoint" } }
],
},
{
from = "2",
to = "3",
condition = {
type = "enter-point",
point = { type = "point", id = "dimPoint2" },
saveAsPointId = "thirdPoint",
},
visuals = [
{
type = "line",
geometry = [{ type = "point", id = "firstPoint" }, { type = "point", id = "dimPoint1" }],
},
{
type = "line",
geometry = [{ type = "point", id = "secondPoint" }, { type = "point", id = "dimPoint2" }],
},
{
type = "line",
geometry = [{ type = "point", id = "dimPoint1" }, { type = "point", id = "dimPoint2" }],
},
]
},
{
from = "2",
to = "3",
condition = {
type = "enter-point",
point = { type = "point", id = "dimPoint2X" },
saveAsPointId = "thirdPoint",
},
visuals = [
{
type = "line",
geometry = [{ type = "point", id = "firstPoint" }, { type = "point", id = "dimPoint1X" }],
},
{
type = "line",
geometry = [{ type = "point", id = "secondPoint" }, { type = "point", id = "dimPoint2X" }],
},
{
type = "line",
geometry = [{ type = "point", id = "dimPoint1X" }, { type = "point", id = "dimPoint2X" }],
},
]
},
{
from = "2",
to = "3",
condition = {
type = "enter-point",
point = { type = "point", id = "dimPoint2Y" },
saveAsPointId = "thirdPoint",
},
visuals = [
{
type = "line",
geometry = [{ type = "point", id = "firstPoint" }, { type = "point", id = "dimPoint1Y" }],
},
{
type = "line",
geometry = [{ type = "point", id = "secondPoint" }, { type = "point", id = "dimPoint2Y" }],
},
{
type = "line",
geometry = [{ type = "point", id = "dimPoint1Y" }, { type = "point", id = "dimPoint2Y" }],
},
]
},
],
initState = "0",
finalStates = ["3"],
},
}
Polygon draw example
https://user-images.githubusercontent.com/11227020/217048898-f8948b99-2315-4c2a-99b4-a28f0f3e42b7.mp4
{
id = "polygon-draw",
formatVersion = "0.1",
stateMachine = {
data = {
parameters = {
pointer = { type = "cursor" }
}
},
states = [
{
id = "0",
visuals = [
{ type = "dot", geometry = { type = "point", id = "clickPoints", range = "..^1" } },
{ type = "dot", geometry = { type = "point", id = "clickPoints", range = "^1.." }, options = { color = "yellow" } }
]
},
{
id = "1",
visuals = [
{
type = "triangle-fan",
geometry = [{ type = "point", id = "clickPoints", range = ".." }],
options = { color = "#0000DD" }
}
]
}
],
transitions = [
{
from = "0",
to = "0",
condition = {
type = "enter-point",
point = { type = "cursor" },
saveAsPointId = "clickPoints"
},
saveAs = {
clickPoints = { type = "point", id = "clickPoints", range = ".." },
},
visuals = [
{
type = "triangle-fan",
geometry = [{ type = "point", id = "clickPoints", range = ".." }, { type = "point", id = "pointer" }],
options = { color = "#00FF00", opacity = 0.4 }
}
]
},
{
from = "0",
to = "1",
condition = {
type = "select-point",
point = { type = "point", id = "clickPoints", range = "^1.." },
saveAsPointId = "pointer"
},
visuals = [
{
type = "triangle-fan",
geometry = [{ type = "point", id = "clickPoints", range = ".." }, { type = "point", id = "pointer" }],
options = { color = "#FF0000", opacity = 0.4 }
}
]
}
],
initState = "0",
finalStates = ["1"]
}
}
Line snapping example
https://user-images.githubusercontent.com/11227020/217048994-f0afadde-c07e-478f-8571-65b5908a6482.mp4
{
id = "line-snapping",
formatVersion = "0.1",
stateMachine = {
data = {
parameters = {
startPoint = { type = "cursor" },
projectedPoint = {
type = "point-projected-to-line", point = { type = "cursor" }, line = [{ type = "point-value", value = [0, 0, 0] }, { type = "point-value", value = [0, 0, 10] }], clampToStart = true,
},
}
},
states = [
{
id = "0",
visuals = [{ type = "dot", geometry = { type = "point", id = "startPoint" }, options = { color = "green" } }]
},
{
id = "1",
},
{
id = "2",
visuals = [
{ type = "dot", geometry = { type = "point", id = "userPoints" }, options = { color = "yellow" } },
{ type = "line", geometry = [{ type = "point", id = "startPoint" }, { type = "point", id = "userPoints" }] },
]
},
{
id = "3",
},
],
transitions = [
{
from = "0",
to = "1",
condition = {
type = "enter-point",
point = { type = "point", id = "startPoint" },
saveAsPointId = "startPoint"
}
},
{
from = "1",
to = "2",
condition = {
type = "enter-point",
point = { type = "point", id = "projectedPoint" },
saveAsPointId = "userPoints"
},
visuals = [
{
type = "dot",
geometry = { type = "point", id = "projectedPoint" }
},
{
type = "line",
geometry = [{ type = "point", id = "startPoint" }, { type = "point", id = "projectedPoint" }],
options = { dashSize = 10, gapSize = 10 },
},
]
},
{
from = "2",
to = "2",
condition = {
type = "enter-point",
point = { type = "point", id = "projectedPoint" },
saveAsPointId = "userPoints"
},
visuals = [
{
type = "dot",
geometry = { type = "point", id = "projectedPoint" }
},
{
type = "line",
geometry = [{ type = "point", id = "startPoint" }, { type = "point", id = "projectedPoint" }],
options = { dashSize = 10, gapSize = 10 },
},
]
},
{
from = "2",
to = "3",
condition = {
type = "enter-text",
key = "Enter"
}
}
],
initState = "0",
finalStates = ["3"]
}
}
Distance measurement tool
https://user-images.githubusercontent.com/11227020/217310600-72cb307d-2bdc-4f25-a83c-9795ad6239dc.mp4
{
id = "distance-measurement-tool",
formatVersion = "0.1",
stateMachine = {
data = {
parameters = {
snapPoints = {
type = "point-values", values = bboxPoints
}
}
},
states = [
{
id = "init",
visuals = [
{
type = "dot",
geometry = { type = "point", id = "snapPoints" },
options = { color = "black" }
},
]
},
{
id = "measuring",
visuals = [
{
type = "dot",
geometry = { type = "point", id = "snapPoints" },
options = { color = "black" }
},
{
type = "dot",
geometry = {
type = "point",
id = "startPoint"
},
options = { color = "red" }
},
]
},
{
id = "measured",
visuals = [
{
type = "dot",
geometry = {
type = "point",
id = "startPoint"
}
},
{
type = "line",
geometry = [
{
type = "point",
id = "startPoint"
},
{
type = "point",
id = "endPoint"
}
]
},
{
type = "dot",
geometry = {
type = "point",
id = "endPoint"
}
},
{
type = "text",
geometry = {
type = "line-length",
position = {
type = "point",
id = "endPoint"
},
line = [
{
type = "point",
id = "startPoint"
},
{
type = "point",
id = "endPoint"
}
],
format = "distance: {0} m"
}
}
]
},
{
id = "final"
}
],
transitions = [
{
from = "init",
to = "measuring",
condition = {
type = "select-point",
point = { type = "point", id = "snapPoints" },
saveAsPointId = "startPoint"
},
visuals = [
{
type = "dot",
geometry = { type = "point", id = "startPoint" },
options = { color = "orange", alwaysVisible = True }
}
]
},
{
from = "measuring",
to = "measured",
condition = {
type = "select-point",
point = { type = "point", id = "snapPoints" },
saveAsPointId = "endPoint"
},
visuals = [
{
type = "dot",
geometry = { type = "point", id = "endPoint" },
options = { color = "yellow", alwaysVisible = True }
},
{
type = "line",
geometry = [
{
type = "point",
id = "startPoint"
},
{
type = "point",
id = "endPoint"
}
],
options = { dashSize = 8, gapSize = 8, color = "#AA0000" }
},
{
type = "text",
geometry = {
type = "line-length",
position = {
type = "point",
id = "endPoint"
},
line = [
{
type = "point",
id = "startPoint"
},
{
type = "point",
id = "endPoint"
}
],
format = "distance: {0} m"
}
}
]
},
{
from = "measuring",
to = "measured",
condition = {
type = "enter-point",
point = { type = "cursor" },
saveAsPointId = "endPoint"
},
visuals = [
{
type = "line",
geometry = [
{
type = "point",
id = "startPoint"
},
{
type = "point",
id = "endPoint"
}
],
options = { dashSize = 8, gapSize = 8, color = "#FF0000" }
},
{
type = "text",
geometry = {
type = "line-length",
position = {
type = "point",
id = "endPoint"
},
line = [
{
type = "point",
id = "startPoint"
},
{
type = "point",
id = "endPoint"
}
],
format = "distance: {0} m"
}
}
]
},
{
from = "measured",
to = "final",
condition = {
type = "enter-point",
point = { type = "cursor" }
}
},
{
from = "measured",
to = "final",
condition = {
type = "enter-text",
key = "Enter"
}
},
],
initState = "init",
finalStates = ["final"]
}
}