Author Topic: force update command bar  (Read 2085 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 343
force update command bar
« on: January 17, 2017, 05:38:49 AM »
Hi,
I wrote the following lisp:

Code: [Select]
(defun c:TEST (/ )
  (setq var (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  ;--------------------------------------
  (vl-load-com)
 
  (setq path (getfiled "Select a dwg file" "" "dwg" 8))
  (setq path (vl-filename-directory path))
  (setq listafile (vl-directory-files path "*.dwg"))

  ;--
  (setq n 0)
  (setq n_tot (length listafile))
  ;--
 
  (foreach el listafile
    (setq pathfiledwg (strcat path "\\" el))
    (setq pathfileplt (strcat (vl-string-right-trim ".dwg" pathfiledwg) ".plt"))
    (princ pathfileplt)
    (command "_.-insert" pathfiledwg "0,0,0" "1" "1" "0")
    (setq bloccogrigliacorrente (entlast))

    (command "_.-plot" "_n" "" "" "" "_y" pathfileplt "_n" "_y")
    (entdel bloccogrigliacorrente)
   
    (setq n (+ n 1))
    (princ (strcat "\nI'm processing the object " (itoa n) " of " (itoa n_tot)))   ;<----------------------------PROBLEM!!!!!!!!!!!!!!!!!!!!!!!!!
  )
  ;--------------------------------------
  (setvar "cmdecho" var)
)

(princ........) is displayed 7 or 8 times and then the command bar is not updated until the entire function.
Is there a way to force the update of the command bar?


Lee Mac

  • Seagull
  • Posts: 12910
  • London, England
Re: force update command bar
« Reply #1 on: January 17, 2017, 08:27:20 AM »

mailmaverick

  • Bull Frog
  • Posts: 493
Re: force update command bar
« Reply #2 on: January 17, 2017, 11:17:40 PM »
Try (command "_.delay" 0)

Lupo76

  • Bull Frog
  • Posts: 343
Re: force update command bar
« Reply #3 on: January 18, 2017, 01:50:16 AM »
See here perhaps:
https://www.theswamp.org/index.php?topic=50848.0

I have tried all or nearly all the proposed solutions, but none work.
In addition to the example that I had given above I had already used a progressbar using acetyl-ui-progress-safe but it seems that in my context, in BricsCAD, it does not work.

In other contexts it is okay, for example, if I remove the following lines of code everything works:
Code: [Select]
    (command "_.-insert" pathfiledwg "0,0,0" "1" "1" "0")
    (setq bloccogrigliacorrente (entlast))

    (command "_.-plot" "_n" "" "" "" "_y" pathfileplt "_n" "_y")
    (entdel bloccogrigliacorrente)

I've already lost too much time to find a solution here :-(
So I have decided to give up and instruct the user to wait

Lupo76

  • Bull Frog
  • Posts: 343
Re: force update command bar
« Reply #4 on: January 18, 2017, 01:50:55 AM »
Try (command "_.delay" 0)

Already tried but it does not work in my context :-(

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: force update command bar
« Reply #5 on: January 18, 2017, 04:49:49 AM »
Try:
(command "_.COMMANDLINEHIDE")
...
 (setvar "MODEMACRO" (strcat "\nI'm processing the object " (itoa n) " of " (itoa n_tot)))

Lupo76

  • Bull Frog
  • Posts: 343
Re: force update command bar
« Reply #6 on: January 18, 2017, 05:20:25 AM »
Try:
(command "_.COMMANDLINEHIDE")
...
 (setvar "MODEMACRO" (strcat "\nI'm processing the object " (itoa n) " of " (itoa n_tot)))

Tried but it does not work.
After a few seconds Windows marks BricsCAD as locked and therefore no solution works.
I also tried

(acet-ui-status .....)

but the problem is always the same.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: force update command bar
« Reply #7 on: January 18, 2017, 06:02:43 AM »
For Bricscad do not use (command "_.COMMANDLINEHIDE").
This sample works for me, files PLT MUST exists prior to run or change (vl-cmdf "_.-plot" "_n" "" "" "" "_y" pathfileplt "_y" "_n" "_y"):
Code: [Select]
(defun c:TEST (/ )
  (setq var (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  ;--------------------------------------
  (vl-load-com)
  ; (setq path (getfiled "Select a dwg file" "" "dwg" 8))
  (setq path "z:\\temp")
  (setq listafile (vl-directory-files "z:\\temp\\" "*.dwg"))
  ;--
  (setq n 0)
  (setq n_tot (length listafile))
  ;--
  (foreach el listafile
    (setq pathfiledwg (strcat path "\\" el))
    (setq pathfileplt (strcat (vl-string-right-trim ".dwg" pathfiledwg) ".plt"))
    (print pathfileplt)
    (vl-cmdf "_.-insert" pathfiledwg "0,0,0" "1" "1" "0")
    (setq bloccogrigliacorrente (entlast))
    (vl-cmdf "_.-plot" "_n" "" "" "" "_y" pathfileplt "_y" "_n" "_y")
    (entdel bloccogrigliacorrente)
    (setq n (+ n 1))
    (setvar "MODEMACRO" (strcat "\n processing the object " (itoa n) " of " (itoa n_tot)))   ;<----------------------------PROBLEM!!!!!!!!!!!!!!!!!!!!!!!!!
  )
  ;--------------------------------------
  (setvar "cmdecho" var)
)

David Bethel

  • Swamp Rat
  • Posts: 656
Re: force update command bar
« Reply #8 on: January 18, 2017, 08:31:27 AM »
Starting with ACAD 2000, I have had the same problem with a lot of different commands. 

This is the work around that I found:
Code - Auto/Visual Lisp: [Select]
  1.   (setq q 212
  2.         i 0)
  3.  
  4.   (princ (strcat "\nProcessing " (rtos q 2 0) " Things...\n"))
  5.  
  6.   (repeat q
  7.      (command "_.REGENALL")
  8.      (princ (strcat "\r" (itoa i) "     "))
  9.      (setq i (1+ i)))


HTH  -David
R12 Dos - A2K