Author Topic: setvar not working before a command call  (Read 900 times)

0 Members and 1 Guest are viewing this topic.

steve.carson

  • Newt
  • Posts: 108
setvar not working before a command call
« on: June 30, 2023, 01:03:53 PM »
Hi Everybody,

I am trying to set commandpreview to 0 prior to running the matchprop command.

For some reason, this isn't changing commandpreview:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:mp ( / OldCP)
  2.  
  3.     (setq OldCP (getvar "CommandPreview"))
  4.     (setvar "CommandPreview" 0)
  5.     (command "_matchprop")
  6.     (setvar "CommandPreview" OldCP)
  7.     (princ)
  8. )
  9.  

Any thoughts on why this might be?


Thanks,

Steve

BIGAL

  • Swamp Rat
  • Posts: 1417
  • 40 + years of using Autocad
Re: setvar not working before a command call
« Reply #1 on: June 30, 2023, 11:33:06 PM »
Copy the 1 line (command "_matchprop") to command line and count the number of requests, you have not allowed for them, try using pause.

Code: [Select]
(command "_matchprop" pause pause "")
A man who never made a mistake never made anything

steve.carson

  • Newt
  • Posts: 108
Re: setvar not working before a command call
« Reply #2 on: July 01, 2023, 10:00:02 AM »
Thanks BIGAL, I’ll give it a try on Monday. I imagine I’ll have to go the “while cmdactive pause” route to allow multiple picks before it’s done. I’m just surprised it’s not doing the initial setvar since it’s supposed to happen before the command call.

steve.carson

  • Newt
  • Posts: 108
Re: setvar not working before a command call
« Reply #3 on: July 03, 2023, 11:27:14 AM »
That worked, BIGAL, thanks! Here's what I ended up with:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:mp ( / OldCP)
  2.  
  3.     (setq OldCP (getvar "CommandPreview"))
  4.     (setvar "CommandPreview" 0)
  5.     (princ "\nSelect objects: ")
  6.     (command "_matchprop")
  7.     (while (/= (getvar "CMDACTIVE") 0)
  8.         (command pause)
  9.     )
  10.     (setvar "CommandPreview" OldCP)
  11.     (princ)
  12. )
  13.  


Steve