Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[Vlisp] What to do with 'command-s'

31 REPLIES 31
SOLVED
Reply
Message 1 of 32
Simon_Weel
32518 Views, 31 Replies

[Vlisp] What to do with 'command-s'

There's a post about the behavior of AutoCAD 2015 and (command ...) functions in custom *error* functions. AutoCAD 2015 displays this message if it encounters this situation: "Cannot invoke (command) from *error* without prior call to (*push-error-using-command*). Converting (command) calls to (command-s) is recommended." So I edited all LISP files and changed (command ...) to (command-s ...). And then I found out this doesn't work in AutoCAD 2010. Command-s was introduced in release 2012. We use different versions of AutoCAD and they all use the same LISP routines. I would like to keep it that way, so I wonder if I can either get rid of the 2015-message or tweak things to get (command-s ...) working in release 2010. Any ideas? Simon
31 REPLIES 31
Message 2 of 32
hmsilva
in reply to: Simon_Weel


@Simon_Weel wrote:
There's a post about the behavior of AutoCAD 2015 and (command ...) functions in custom *error* functions. AutoCAD 2015 displays this message if it encounters this situation: "Cannot invoke (command) from *error* without prior call to (*push-error-using-command*). Converting (command) calls to (command-s) is recommended." So I edited all LISP files and changed (command ...) to (command-s ...). And then I found out this doesn't work in AutoCAD 2010. Command-s was introduced in release 2012. We use different versions of AutoCAD and they all use the same LISP routines. I would like to keep it that way, so I wonder if I can either get rid of the 2015-message or tweak things to get (command-s ...) working in release 2010. Any ideas? Simon

Just a thought, untest (I don't have 2015 in this laptop) try to change the command function to vl-cmdf function (vl-load-com first)...

 

HTH

Henrique

EESignature

Message 3 of 32
Gary_J_Orr
in reply to: Simon_Weel

try performing a version check prior to calling the command/command-s so you can call the appropriate version...


(if (>= (atof (getvar "ACADVER")) 18.2)
(command-s ...)
(command ...)
)

-Gary
Gary J. Orr
(Your Friendly Neighborhood) CADD/BIM/VDC Applications Manager
http://www.linkedin.com/in/garyorr

aka (current and past user names):
Gary_J_Orr (GOMO Stuff 2008-Present); OrrG (Forum Studio 2005-2008); Gary J. Orr (LHB Inc 2002-2005); Orr, Gary J. (Gossen Livingston 1997-2002)
Message 4 of 32
Simon_Weel
in reply to: hmsilva

I tried 'vl-cmdf'. Replaced (command ...) in all LISP routines. But the result is the same, which is kind of weird, since the routines no longer use (command ...). Double checked the code to see if one had escaped me. Looks like vl-cmdf evaluates the code and then passes it on to (command ...)? Simon
Message 5 of 32
owenwengerd
in reply to: Simon_Weel

This works in all versions:

((if command-s command-s command) "XXXX" "XXXX")
--
Owen Wengerd
ManuSoft
Message 6 of 32
Gary_J_Orr
in reply to: owenwengerd

one could... but you would also need to consider a call to (initcommandversion) to ensure that all things are equal when passing the command options to the command...
My suggestion allows for an easy method to build seperate command strings if need be to account for such... and if the same command strings can be sent to both, well copy paste can duplicate the strings in both versions while allowing for an easy method to modify either as things change even more going forward.

-G
Gary J. Orr
(Your Friendly Neighborhood) CADD/BIM/VDC Applications Manager
http://www.linkedin.com/in/garyorr

aka (current and past user names):
Gary_J_Orr (GOMO Stuff 2008-Present); OrrG (Forum Studio 2005-2008); Gary J. Orr (LHB Inc 2002-2005); Orr, Gary J. (Gossen Livingston 1997-2002)
Message 7 of 32
dbroad
in reply to: owenwengerd

I like it Owen.  If a file used command-s more than once in a file, I wonder if it would be more convenient to put one of these at the top of the file:

 

;;backward compatibility for earlier versions

(if (not command-s) (setq command-s command))

 

or 

 

;;backward compatibility for earlier versions

(or command-s (setq command-s command))

 

or for the really paranoid to head of the case of a non-functional binding of command-s

 

;;backward compatibility for earlier versions

(if (/= 'subr (type command-s)) (setq command-s command))

 

Then the rest of the file could be written as normal.

 

For the benefit of the the casual readers of this thread, be reminded that command-s is only for complete command sequences.  No user input can be nested into the arguments to the command-s function.

Architect, Registered NC, VA, SC, & GA.
Message 8 of 32
owenwengerd
in reply to: dbroad


@dbroad3 wrote:

If a file used command-s more than once in a file, I wonder if it would be more convenient to put one of these at the top of the file:

 

Once could of course, but for code readability and debuggability, I prefer to see the logic at the point where it is used.

--
Owen Wengerd
ManuSoft
Message 9 of 32
dbroad
in reply to: owenwengerd

Another good point.

Architect, Registered NC, VA, SC, & GA.
Message 10 of 32
dgorsman
in reply to: dbroad

Could also build it as a utility wrapper defun e.g. (defun command-i ( arg_list / )...), although the arguments would need to be (list ...) 'ed rather than a variable number of strings.  Opens up a few additional interesting thought, like global variable(s) with re-useable command argument lists for common command sequences.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 11 of 32
Gary_J_Orr
in reply to: Gary_J_Orr

oops, wrong version... command-s was introduced in 2013 (ver 19) it seems...
G
Gary J. Orr
(Your Friendly Neighborhood) CADD/BIM/VDC Applications Manager
http://www.linkedin.com/in/garyorr

aka (current and past user names):
Gary_J_Orr (GOMO Stuff 2008-Present); OrrG (Forum Studio 2005-2008); Gary J. Orr (LHB Inc 2002-2005); Orr, Gary J. (Gossen Livingston 1997-2002)
Message 12 of 32
hmsilva
in reply to: Gary_J_Orr


@Anonymous wrote:
oops, wrong version... command-s was introduced in 2013 (ver 19) it seems...
G

Garry,

command-s was introduced in 2012, but only referenced in 2013 Help files...

 

Henrique

EESignature

Message 13 of 32
Gary_J_Orr
in reply to: hmsilva

thanks Henrique...
I had thought so but couldn't find proof so...
and it seems that it wasn't a "forced requirement" for command functions within the Error handler (or other post-processing functions) until more recently anyway (based upon my 2012 not having that particular warning when my error handlers kick in, either that or I've managed to catch all my errors in my code and it just hasn't impacted me)...
But it's good to know for future reference
-G
Gary J. Orr
(Your Friendly Neighborhood) CADD/BIM/VDC Applications Manager
http://www.linkedin.com/in/garyorr

aka (current and past user names):
Gary_J_Orr (GOMO Stuff 2008-Present); OrrG (Forum Studio 2005-2008); Gary J. Orr (LHB Inc 2002-2005); Orr, Gary J. (Gossen Livingston 1997-2002)
Message 14 of 32
dbroad
in reply to: dgorsman

I guess that is possible but I would probably not use such a function.  Over the years, I've built up my own way of handling defaults.  If you develop the thought further, I might be interested.

Architect, Registered NC, VA, SC, & GA.
Message 15 of 32
Simon_Weel
in reply to: owenwengerd

No, it doesn't work in 2010. However ((if command-s command-s vl-cmdf) "XXXX" "XXXX") DOES work. So problem fixed! Simon
Message 16 of 32
JamesMaeding
in reply to: owenwengerd

I know this is months past this thread, but

((if command-s command-s command) "XXXX" "XXXX")

 

does not work in acad 2009. It gives an odd error.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 17 of 32
sinisterkid
in reply to: JamesMaeding

Sounds like you guys all have really technical solutions, which I would appreciate if i had to hack further. I had this problem with the CLIPIT command (cropping some jpeg images) and I merely closed out of cad, regened, and reopened. Problem solved. just a thought before going to town on a LISP.

Message 18 of 32
JamesMaeding
in reply to: sinisterkid

@sinisterkid

That kind of answer makes support people look bad though.

You might get past one problem, but people start to lose faith in you if you don't fix things right, so hence the search for a real fix here.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 19 of 32

Hi Simon, 

I understand this is an old thread, but I hope you'll see my message! I encountered a similar problem with a lisp recently. all of a sudden, when trying to use a lisp which worked just fine until now, I get the message you mention. I have AutoCAD 2015 and would like to try edit all LISP files and change (command ...) to (command-s ...). Can you please tell me how? 

 

desperateMolly

Message 20 of 32

Just check each custom/local *error* function inside your LISPs, and change each (command "func" "arg") in (command-s "func" "arg"). (You can (SHOULD) leave the rest of the lisp alone !)

 

For the record, command-s became mandatory for *error* functions as of ACAD2015 (R20), so to keep it working in both newer and older versions, i use a version check myself (as has been mentioned before in this thread).

 

Example:

   (defun *error* ( msg / )
      (if (< (atoi (getvar "acadver")) 20) ; ACAD 2014 or older
         (command   "_.UNDO" "_End") ; End Undo - old version
      ; else
         (command-s "_.UNDO" "_End") ; End Undo - new version
      )
; rest of error function here...

 

edit:

...and don't mind @sinisterkid as he's comparing apples & oranges.

You can restart, regen and/or reopen until you weight about one ounce, but 2015 & higher will simply keep telling you it is not allowed to use (command ...) within a *error* function.

Just like 2011 & older will keep telling you it doesn't recognize the command (command-s ...)

(2012-2014 are 'hybrids'. They have the command-s, but they will (still) accept command for *error* functions.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost