Notifications
Clear all
[Closed] Draw rubberband
May 29, 2017 12:23 pm
Is there a way to draw a rubberband, or even multiple, without using PickObject or PickPoint? I would like to use it for custom scripts, but I can’t find a way to draw it without using said functions.
2 Replies
May 29, 2017 12:23 pm
DenisT has posted a solution a while ago.
(
global _points = #()
global _pmouse = undefined
unRegisterRedrawViewsCallback drawRubberband
fn drawRubberband = if _points.count > 0 and _pmouse != undefined do
(
gw.setTransform (matrix3 1)
local points = for p in _points collect (gw.transPoint p)
append points (gw.transPoint _pmouse)
gw.setcolor #line (color 200 200 200)
for k=2 to points.count do gw.wPolyline #(points[k-1], points[k]) off
gw.enlargeUpdateRect #whole
gw.updateScreen()
)
fn mouseTracking msg ir obj faceNum shift ctrl alt =
(
_pmouse = ir.pos
case msg of
(
#mouseAbort: ()
#freeMove: if _points.count > 0 do completeRedraw()
#mousePoint: append _points _pmouse
#mouseMove: if _points.count > 0 do completeRedraw()
)
if msg == #mouseAbort then #abort else #continue
)
_points = #()
registerRedrawViewsCallback drawRubberband
act = mouseTrack trackCallback:mouseTracking snap:#3D
unRegisterRedrawViewsCallback drawRubberband
completeRedraw()
format "act:% numpoints:% points:%
" act _points.count _points
)
May 29, 2017 12:23 pm
Awesome. I ended up making a wPolyline implementation, but the right click cancel from that snippet I couldn’t figure out of so thanks for sharing!