(command "DELAY") in button OnClicked callback not working in 5.0.0.13

Started by hermanm, May 03, 2008, 08:18:16 PM

Previous topic - Next topic

hermanm

I wrote this function



;;blink an object on/off a specified number of times
;;accepts an ename or vla-object
(defun blink (obj times milliseconds / *error* flip-vis oldecho oldvis)
  (defun *error* (msg / )
   (vla-put-visible obj oldvis)
   (setvar "CMDECHO" oldecho)
  )
  (defun flip-vis (obj / )
    (if (eq :vlax-true (vla-get-visible obj))
      (vla-put-visible obj :vlax-false)
      (vla-put-visible obj :vlax-true))
  )
  (if (eq (type obj) 'ENAME) (setq obj (vlax-ename->vla-object obj)))
  (setq oldecho (getvar "CMDECHO")
        oldvis (vla-get-visible obj))
  (setvar "CMDECHO" 0)
  (repeat (* 2 times)
    (progn
      (flip-vis obj)
      (command "delay" milliseconds)
    )
  )
  (setvar "CMDECHO" oldecho)
  (princ)
);blink



and used it with success in a button callback on a palette form in 5.0.0.12,
but no joy with same form in 5.0.0.13

The control is working (verified with an (alert) stub),
and the callback works if called from the command line

Callback looks like this:



(defun C:DimensionChecker_Palette_BlinkAll_OnClicked ()
  ;(alert "Function Called")
  (and ss
    (setq i 0)
    (repeat (sslength ss)
      (blink (ssname ss i) blink# duration)
      (setq i (1+ i))
    );repeat
  );and
);defun



I read about the dcl_DelayedInvoke function as a supposed alternative to (command "DELAY"), but I don't see a way to try it in this context, since it requires a string as argument.
I tried passing a LISP expression as a string to dcl_DelayedInvoke, but that didn't work.

Has anyone else tried a similar callback on a palette control in 5.0.0.13?
If so, can you confirm my (lack of) results?

Any suggestions?

Project files are attached (W.I.P.)



BazzaCAD

Have you had a look at "FormMover.lsp" & "Splash.lsp" for examples on how to use (dcl_DelayedInvoke).
I have this old example that show how to flash a control on & off,
http://www.opendcl.com/forum/index.php?topic=115.0
But I still need to update it to use (dcl_DelayedInvoke) & I haven't tested it on a palette yet either.
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

hermanm

My callback function blinks entities in the dwg, not a form control.

The examples you cite are thus:

(dcl_DelayedInvoke 50 "C:FormMinMax")

but I need to call a function which has an argument:

Command: (dcl_DelayedInvoke milliseconds "(vla-put-visible obj :vlax-true)")
; error: ADS request error

Command: (dcl_DelayedInvoke milliseconds "vla-put-visible obj :vlax-true")
; error: ADS request error

so, if there is a syntax which works, and works in a button callback, I'd be happy to see it.

hermanm

It occurred to me to try calling a "dummy" function w/ no arguments,

Thus:

(defun c:dummy ()(princ))
;;blink an object on/off a specified number of times
;;accepts an ename or vla-object
(defun blink_dcl (obj times milliseconds / *error* flip-vis oldvis)
  (defun *error* (msg / )
   (vla-put-visible obj oldvis)
  )
  (defun flip-vis (obj / )
    (if (eq :vlax-true (vla-get-visible obj))
      (vla-put-visible obj :vlax-false)
      (vla-put-visible obj :vlax-true))
  )
  (if (eq (type obj) 'ENAME) (setq obj (vlax-ename->vla-object obj)))
  (setq oldvis (vla-get-visible obj))
  (repeat (* 2 times)
    (progn
      (flip-vis obj)
      (dcl_DelayedInvoke milliseconds "C:dummy")
    )
  )
  (princ)
);blink_dcl



but his does not work as desired

the result is a sequence of newlines as (princ) is called, but the visibility state remains unchanged
I tried increasing the delay from 250 to 1000, but no difference.
It _appears_ to me that the (dcl_DelayedInvoke) executes after the callback returns, which is of no use to me in this case

hermanm

well, that's weird..

I decided to write my own (delay) function
(doesn't have to be very accurate)

Thus:

(defun delay (ms / base)
  (setq base (getvar "DATE"))
  (while (< (* 86400000 (-(getvar "DATE") base)) ms))
);delay


forget about ODCL for a moment,

just function call from command line

Command: (flip-vis obj)
nil

Yep, obj disappears

Command: (flip-vis obj)
nil

Yep, it comes back

Now try:

(flip-vis obj)(delay 250)(flip-vis obj)

Nothing happens!

Oh, there is a delay, alright, but the object remains always visible

Try a longer delay:

(flip-vis obj)(delay 2000)(flip-vis obj)

same result, w/ longer delay

so, I conclude I don't know how (vla-put-visible) ACTUALLY WORKS

puzzling..., at this point

more tomorrow.(?)




BazzaCAD

What if you call the Update method after you set the visibility?
I had the same type of issue with the controls not repainting, so I had to force a refresh on them.
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

hermanm

<nodding head>
Yes, I had suspected it was exactly that - graphics not updating.
So, I tried (entupd) after (vla-put-visible)
Which doesn't work - apparently mixing the "old-style" (entxxx ) functions with Active X is a no-no.
I was trying to remember how to do an (entupd(entmod)) on a list which doesn't contain the desired DFX code when I read your post..
Figuring "all old-style" might do the trick (it might).

But, Voila!

This works:

(flip-vis obj)(vla-update obj)(delay 250)(flip-vis obj)

and no command call, either, with my own  delay function, so no need to mess with "CMDECHO"

Thanks, Barry, for pointing out the Update method.
:)

BazzaCAD

a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom