Chapter 4 · The TnpixTool Interface

4.11Motion Brush

The layers and strokes of a Tnpix_Motion_Brush on the node. A stroke from script goes through the same functions as a stroke in the viewport, and each call is one undo step. A layer is named by its number, the one mbLayer "add" returns and mbInfo lists; positions are in the object's own space.

FunctionReturnsWhat it does
mbLayer node op layer textintegerop "add" makes a layer named text and returns its number; "duplicate" copies layer and returns the copy's number; "delete", "on", "off", "select"; "rename" to text; "easeIn" / "easeOut" set the Ease to text frames; "edit" puts layer in Edit (−1 ends Edit). Returns the layer's number, or −1 when refused.
mbStroke node layer frame tool from to radius strength dabs flagsintegerOne stroke on frame. tool: 0 Grab, 1 Relax, 2 Sculpt, 3 Erase. Grab drags what lies under from by to − from; the other brushes put dabs dabs along the line from from to to. flags is a sum: the falloff (0 Smooth, 1 Linear, 2 Sharp, 3 Flat), plus 4 × the mirror axis (1 X, 2 Y, 3 Z through the object's pivot), plus 16 for Follows the surface, 32 for Ctrl (Sculpt pushes in), 64 for Grab style Cloth, 128 for Shift held (Relax), 256 for Falloff Curve, and the pick for every brush: 512 for Picks On screen or 1024 for Picks On the surface (with neither, Around the point) - a script's screen is the object's own space seen from above: x and y on the screen, the depth along −z, the circle the radius; On the surface walks the cloth from the face nearest from. The frame becomes a key of the layer as in the viewport. Returns how many points the stroke touched, or −1 when refused (the panel's status line says why).
mbKey node layer frame opinteger"delete" deletes the layer's brushed frame frame (Delete Key): 1 done, 0 refused. "weight" keys the Weight on frame, or removes the key there (the K box). "count" returns how many brushed frames the layer holds.
mbInfo nodestringThe layers as text, one line each: the number, name, on/off, the Ease, the brushed frames with how many points each holds, and the Weight's keys (frame:value).
mb = Tnpix_Motion_Brush()
addModifier $Cloth mb
fold = TnpixTool.mbLayer $Cloth "add" 0 "fold"
TnpixTool.mbStroke $Cloth fold 30 2 [0,0,0] [0,0,0] 8.0 1.0 1 16     -- a Sculpt dab on frame 30, Follows the surface
TnpixTool.mbStroke $Cloth fold 30 1 [-5,0,0] [5,0,0] 8.0 0.5 4 16    -- three more dabs: Relax along a line
TnpixTool.mbInfo $Cloth