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

Command-S Question

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
bakerrl2
1607 Views, 6 Replies

Command-S Question

According to the AutoCAD 2015 help on the AutoLisp Command-S function it has the following signature.

 

(command-s [cmdname [arguments ...]])

 

If I am interpreting this signature correctly, I should be able to supply any number of commands and their arguments to the function.  In the case of Command-S I would assume each set of commands and arguments would have to be complete in order for function to work.

 

Recently, I tried to execute the following code in an AutoLisp function.

 

(setvar "attreq" 1) (setvar "attdia" 0)

(command-s

   ".CELTYPE" "CONTINUOUS"
   ".INSERT" (F:D "GEN_S" "" "A2ASB005") Cenpt (dwgscale) (dwgscale) 0 Dsign Dwgno

)

 

This code sets the current entity linetype and then inserts a block with two attribute values.

(F:D "GEN_S" "" "A2ASB005") returns c:\acadapps\pwr2015\gen\gen\sym5\a2asb005

CenPt = 0,0,0

(dwgscale) = 1.0

Dsign = "1"

DwgNo = "2"

 

When I execute the code it DOES NOT inserted the block even though both commands are completed in the list.  In addition, it does not produce any error messages.  The only way I can get it to work is to change the code like this:

 

(command-s ".CELTYPE" "CONTINUOUS")
(command-s ".INSERT" (F:D "GEN_S" "" "A2ASB005") Cenpt (dwgscale) (dwgscale) 0 Dsign Dwgno)

 

Is the Help wrong?  Will the Command-S function only accept one command at a time?

 

 

6 REPLIES 6
Message 2 of 7
owenwengerd
in reply to: bakerrl2

The help syntax lists only one 'cmdname' argument. How do you interpret that to mean more than one command is allowed?

--
Owen Wengerd
ManuSoft
Message 3 of 7
bakerrl2
in reply to: owenwengerd

That was a mistake on my part.  I saw the ellipsis at the end of the signature and thought it indicated there could be multiple commands and arguments.  I looked at the help again this morning and realized the ellipsis was indicating that there could be multiple arguments.

 

However, it is interesting that the Command-S function will allow you to type in multiple commands and arguments and it will not generate an error when you execute the function.  It only executes the first command provided.  So if you weren't paying attention when you wrote the code you might wonder why some of the commands in your AutoLisp program weren't being executed.

Message 4 of 7
rodb
in reply to: bakerrl2

Hi everyone,

 

Not using command-s in 2015 results in a polite suggestion to use it which is a pain because command works fine.

 

We also have some 2012, 2013, 2014 versions of AutoCAD running. I assume command-s won't work in 2012 ?

 

I never use get calls inside the command function they are always used something like this :-

 

(setq bp (getpoint "\nPick Basepoint for Attribute Block..."))
      (command "insert" "LVLED_018" bp userr5 userr5 "" "" "" "" watts "" "" "" leng "")
      (command "-block" blkname bp ep "")
      (command "-insert" blkname bp "1" "1" "0")

 

I could change all 200 lisp programs to command-s if its worth it or use something like

(if command-s (setq command command-s)) in each program

 

But the easiest would be to leave command as it is if I can stop the polite request by AutoCAD unless there is a good reason for using command-s

 

Any help on this would be much appreciated!!!!

 

 

 

 

 

 

Message 5 of 7
hmsilva
in reply to: rodb

Hi rodb,
 
Command-s was introduced in AutoCAD 2012, also *push-error-using-command*, *push-error-using-stack* and *pop-error-mode* were introduced in AC2012.

Command function was not removed, so we can continuing to use the command function in AC2015...

Command-s function is required within a custom *error* handler in AC2015, if command is used in a custom *error* handler will throw an error, we only have to change command to command-s within a custom *error* handler...

 

Even in a AC2015 custom *error* handler you can still use command, look at the help files Error-Handling Functions Reference (AutoLISP)

 

Outside a custom *error* handler, command-s is faster then command, but have some limitations...
This might help Differences from the Command Function


I hope this helps
Henrique

EESignature

Message 6 of 7
rodb
in reply to: hmsilva

Hi Hmsilva,

 

Once again you have answered the question so clearly for me. I read the AutoCAD file about it but could not find which versions would run command-s. I think I will leave my lisp as is as long as I can stop AutoCAD prompting me to use command-s all the time at the end of a program.

 

Thank you!!!!

Message 7 of 7
hmsilva
in reply to: rodb

You're welcome, rodb
Glad I could help

Henrique

EESignature

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

Post to forums  

Autodesk Design & Make Report

”Boost