Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 69 additions & 17 deletions docs/src/gui/vismach.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ or raw data:
possible to assemble the model in the CAD package.

Alternatively parts can be created inside the model script from a range
of *shape primitives*. Many shapes are created at the origin and need to
be moved to the required location after creation:
of *shape primitives*. All primitives accept static numeric arguments or
an optional leading HAL component (`comp`) followed by HAL pin names
for dynamic dimensions. Many shapes are created at the origin and need
to be moved to the required location
after creation:


* `cylinder = CylinderX(x1, r1, x2, r2) +
cylinder = CylinderY(y1, r1, y2, r2) +
Expand All @@ -108,6 +112,37 @@ be moved to the required location after creation:
Creates an xw by yw by zw box centred on the origin.
* `box = BoxCenteredXY(xw, yw, z)` +
Creates a box of width xw / yw and height z.
* `line = Line([comp,] x1, y1, z1, x2, y2, z2, stretch=1, r=5)` +
Creates a cylindrical line segment starting at `(x1, y1, z1)` along
vector `(x2, y2, z2)` scaled by `stretch` with radius `r`.
* `grid = Grid([comp,] s=500) +
grid = Grid([comp,] x, y, z, vx, vy, vz, s=500) +
grid = Grid([comp,] ox, oy, oz, xx, xy, xz, zx, zy, zz, s=500)` +
Creates a reference grid of half-size `s` on the XY plane at the
origin, perpendicular to normal vector `(vx, vy, vz)` at `(x, y, z)`,
or aligned to origin `(ox, oy, oz)`, X-direction `(xx, xy, xz)`, and
Z-normal `(zx, zy, zz)`.
* `plane = Plane([comp,] s=500) +
plane = Plane([comp,] x, y, z, vx, vy, vz, s=500) +
plane = Plane([comp,] ox, oy, oz, xx, xy, xz, zx, zy, zz, s=500)` +
Creates a solid reference plane of half-size `s` at the origin,
aligned to a normal vector, or aligned to an origin, X-direction
vector, and Z-normal vector.
* `coords = Coords([comp,] stretch=1, r=5) +
coords = Coords([comp,] ox, oy, oz, zx, zy, zz, stretch=1, r=5) +
coords = Coords([comp,] ox, oy, oz, xx, xy, xz, zx, zy, zz, stretch=1, r=5)` +
Creates a 3-axis RGB coordinate indicator (X=Red, Y=Green, Z=Blue) of
base length `50 * stretch` and radius `r` at the origin, aligned to a
Z-normal vector, or aligned to an origin, X-direction vector, and
Z-normal vector.

[NOTE]
====
Legacy `Hal*` aliases (such as `HalLine`, `HalGrid`,
`HalGridFromNormal`, `HalGridFromNormalAndDirection`, `HalPlaneFromNormal`,
and `HalCoordsFromNormalAndDirection`) remain supported for backwards
compatibility, though they may be deprecated in the future.
====

Composite parts may be created by *assembling* these primitives either
at creation time or subsequently using `Collection()`:
Expand All @@ -131,22 +166,39 @@ rotation axis is created at the origin (but moves with the Part):
* `part1 = Rotate([part1], theta, x, y, z)` +
Rotate the part by angle theta about an axis between the origin and
x, y, z.
* `part1 = Scale([part1], x, y, z)` +
Scale the part by factors `x`, `y`, and `z` along the respective axes.
* `part1 = RotateEuler([part1], th1, th2, th3, order=123)` +
Apply three successive Euler rotations (`th1`, `th2`, `th3` in degrees)
about the axes specified by `order` (default `123` for X-Y-Z).
* `part1 = Show([part1], const, var, scaleby_true=1, scaleby_false=0)` +
Toggle part visibility/scale between `scaleby_true` and `scaleby_false`
depending on whether `const == var`.

[NOTE]
====
Legacy `Hal*` aliases (such as `HalTranslate`, `HalVectorTranslate`,
`HalRotate`, `HalVectorRotate`, `HalScale`, `HalRotateEuler`, and
`HalShow`) remain supported for backwards compatibility, though they may
be deprecated in the future.
====

== Animating Parts

To animate the model (controlled by the values of HAL pins) there are
two functions 'HalTranslate' and 'HalRotate'. For parts to move inside
an assembly they need to have their HAL motions defined before being
assembled with the "Collection" command. The rotation axis and
translation vector move with the part as it is moved by the vismach
script during model assembly, or as it moves in response to the HAL pins
as the model is animated:
To animate the model (controlled by the values of HAL pins), `Translate`,
`Rotate`, `Scale`, `RotateEuler`, and `Show` accept a HAL component and
HAL pin names. For parts to move inside an assembly they need to have
their motions defined before being assembled with the "Collection" command.
The rotation axis and translation vector move with the part as it is moved
by the vismach script during model assembly, or as it moves in response to
the HAL pins as the model is animated:


* `part = HalTranslate([part], comp, "hal_pin", xs, ys, zs)` +
* `part = Translate([part], comp, "hal_pin", xs, ys, zs)` +
The function arguments are:
** first a _collection/part_ which can be pre-created earlier in the
script, or could be created at this point if preferred eg
`part1 = HalTranslate([Box(....)], ...)`.
`part1 = Translate([Box(....)], ...)`.
** The _HAL component_ is the next argument, i.e. the object returned by
the `comp = hal.component(...)` command. After that is the name of
the HAL in that will animate the motion, this needs to match an
Expand All @@ -158,8 +210,8 @@ as the model is animated:
However if the STL file happened to be in cm and the machine was in
inches, this could be fixed at this point by using 0.3937
(1cm /2.54in) as the scale.
* `part = HalRotate([part], comp, "hal_pin", angle_scale, x, y, z)` +
This command is similar in its operation to HalTranslate except that
* `part = Rotate([part], comp, "hal_pin", angle_scale, x, y, z)` +
This command is similar in its operation to Translate except that
it is typically necessary to move the part to the origin first to
define the axis.
** The _axis of rotation_ is from the origin point to the point defined
Expand Down Expand Up @@ -195,21 +247,21 @@ of drive dogs:
#Drive dogs
dogs = Box(-6,-3,94,6,3,100)
dogs = Color([1,1,1,1],[dogs])
dogs = HalRotate([dogs],c,"spindle",360,0,0,1)
dogs = Rotate([dogs],c,"spindle",360,0,0,1)
dogs = Translate([dogs],-1,49,0)

#Drawbar
draw = CylinderZ(120,3,125,3)
draw = Color([1,0,.5,1],[draw])
draw = Translate([draw],-1,49,0)
draw = HalTranslate([draw],c,"drawbar",0,0,1)
draw = Translate([draw],c,"drawbar",0,0,1)

# head/spindle
head = AsciiSTL(filename="./head.stl")
head = Color([0.3,0.3,0.3,1],[head])
head = Translate([head],0,0,4)
head = Collection([head, tool, dogs, draw])
head = HalTranslate([head],c,"Z",0,0,0.1)
head = Translate([head],c,"Z",0,0,0.1)

# base
base = AsciiSTL(filename="./base.stl")
Expand Down Expand Up @@ -295,7 +347,7 @@ tooltip = Capture()
#Build and assemble the model
part1 = Collection([Box(-6,-3,94,6,3,100)])
part1 = Color([1,1,1,1],[part1])
part1 = HalRotate([part1],comp,"pin_name",360,0,0,1)
part1 = Rotate([part1],comp,"pin_name",360,0,0,1)
part1 = Translate([dogs],-1,49,0)
...
#create a top-level model
Expand Down
Loading