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

Prior call to (*push-error-using-command*)

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
Anonymous
18728 Views, 11 Replies

Prior call to (*push-error-using-command*)

A little background:  I am not well verse (if at not in LISP) and been reading thru some forum  on error handling but still can not get it to work. The code was written by person who is no longer with company and I am needing to get this working in AutoCAD 2016 (yes, we currently still on this version) from AutoCAD 2010.

 

The error still pops up:

   Function cancelled
   Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
   Converting (command) calls to (command-s) is recommended.

 

I been hitting the ESC key to cause the error to come up.  I am assuming its the custom error handler and it attempting to reset certain setting back.  Like I mention, I attempt to search forum and documentation but cant seem to make heads or tails on getting it to work.

 

Any help would be greatly appreciated.

 

LSP code included.

 

 

11 REPLIES 11
Message 2 of 12
dlanorh
in reply to: Anonymous

It's to do with how the custom error handler is constructed. (*push-error-using-command*) should have been inserted after the the first (setq err *error* *error* trap) and at the end of the file, (*pop-error-mode*) should have been inserted after (setq *error* err) as well as in the trap routine. I'm not sure if these are causing the error though.

 

The program is a mess as it doesn't use any local variables, and could do with a serious update. Copy the lisp and save as pp2.lsp then make the following changes

 

Make the beginning of the lisp look like this

(defun c:pp ( / *error*  );<<== insert forward slash and *error* between brackets making a local error function

(command "viewres" "Y" 20000)

(defun *error* (msg) ;<<== copy *error* from below and replace trap change errmsg to msg
(prompt msg) <<== change errmsg to msg
(setvar "highlight" 1)
(setvar "cmdecho" cmd)
(setvar "osmode" osm)
(setvar "pickbox" orgpb)
; (setq *error* err) <<== put a semi-colon before this line
(princ)
);endfunction *error*
;(setq err *error* *error* trap) ; <<== put a semi-colon before this line
(setq orgpb(getvar "pickbox"))
(setq cmd(getvar "cmdecho"))
(setq osm(getvar "osmode"))
(setvar "cmdecho" 0)

 Make the end of file look like this

(setvar "highlight" 1)
(setvar "cmdecho" cmd)
(setvar "osmode" osm)
(setvar "pickbox" orgpb)
;(setq *error* err) <<== put a semi-colon before this line
(princ)

Once this is done try running the lisp and see what errors it produces if any.

If it runs OK then you can delete the three setq lines you've just put a semi-colon in front of.

I am not one of the robots you're looking for

Message 3 of 12
dlanorh
in reply to: Anonymous

Just noticed this towards end of lisp

     (progn
        (setq continuous nil) ;no point selected so bale out <<== there was no semi-colon before this comment, insert one
     );endpro - There is NO APT1

This could also be causing problems as autocad thinks its code but it's a comment

I am not one of the robots you're looking for

Message 4 of 12
roland.r71
in reply to: Anonymous

For your understanding:

Up to AutoCAD 2014 any custom *error* trapping function could contain command calls (command "acadfunc" "etc")

 

As of AutoCAD 2015 this is no longer supported. Instead you should use (command-s "acadfunc" "etc")

-or- force it to still allow command calls. (using command-s is recommended)

 

However, your trap does not contain such calls. (at least not directly)

& actually works fine, for what i tested. Even with the bad "comments" pointed out by N4mr4hdlanor (until the script actually gets to that part. (No, point, selected, so, bail & out are all "unrecognized commands" ...)

 

Even if i define a bad *error* using command before calling your function (as it stores and restores the content of *error*, it could be caused by another lisp defining a bad *error*, but doesn't make a difference here)

 

Running it & hitting the "Esc" key will get me a normal

*cancel*

Function cancelled

 

Anyway, besides giving some explanation i can't do more at the moment, as i can not reproduce your problem. (on Acad2015 x64)

Message 5 of 12
Anonymous
in reply to: dlanorh

This has much better results if I reset any customization loaded and just load the pp.lsp.

 

Upon running the command.

It prompts 1st messge: 1 = 1/0 DBE, 2 = #2 LBE <2 = #2 LBE>:

When I hit ESC from this point, it does not prompt the "can not invoke..." but what should be normal:

   1 = 1/0 DBE, 2 = #2 LBE <2 = #2 LBE>: *Cancel*
   Function cancelled

 

If I do attempt to select one of the options and attempt to cancel at that point, it does cancel but is stuck at this point.

   1 = 1/0 DBE, 2 = #2 LBE <2 = #2 LBE>: 1
   Select P/L: (approx. PAD loc.) bad argument type: lentityp nil
   Command: *Cancel*

I would try to go back into the command after ESC from this point and it starts off at the Select P/L: (approx. PAD loc.)

Should it not start back from the beginning?

 

I believe roland.r71 is correct as I recall the Trap function in other custom lsp code.  😞 

Upon running the command with all the other customizations and custom lsp code the way the system suppose to be setup, i still get the 

Cannot invoke (command) from *error* without prior call to (*push-error-using-command*)

 

Do I have alot of work to do, ugh.

Message 6 of 12
dlanorh
in reply to: Anonymous


@Anonymouswrote:

This has much better results if I reset any customization loaded and just load the pp.lsp.

 

Upon running the command.

It prompts 1st messge: 1 = 1/0 DBE, 2 = #2 LBE <2 = #2 LBE>:

When I hit ESC from this point, it does not prompt the "can not invoke..." but what should be normal:

   1 = 1/0 DBE, 2 = #2 LBE <2 = #2 LBE>: *Cancel*
   Function cancelled

 

If I do attempt to select one of the options and attempt to cancel at that point, it does cancel but is stuck at this point.

   1 = 1/0 DBE, 2 = #2 LBE <2 = #2 LBE>: 1
   Select P/L: (approx. PAD loc.) bad argument type: lentityp nil
   Command: *Cancel*

I would try to go back into the command after ESC from this point and it starts off at the Select P/L: (approx. PAD loc.)

Should it not start back from the beginning?

 

I believe roland.r71 is correct as I recall the Trap function in other custom lsp code.  😞 

Upon running the command with all the other customizations and custom lsp code the way the system suppose to be setup, i still get the 

Cannot invoke (command) from *error* without prior call to (*push-error-using-command*)

 

Do I have alot of work to do, ugh.


 


I will look at this tomorrow. There is a lot of redundant code and loop controls, but I think that this is the first program prompt. What should happen is that all the variables are local to the lisp and disappear once the lisp finishes, but the programmer has made them all global by not defining them in the brackets and after the slash at the start of the lisp. This means they stick around in autocad clogging up memory and cause problems when errors occur.

Re: lot of work
Just copy the new *error* defun to the other lisps, the " / *error* " is a copy and paste and you only have to put a semi-colon in front of any setq with err *error* or trap in it.
If you get stuck just pop back here and i'm sure someone will help.

I am not one of the robots you're looking for

Message 7 of 12
roland.r71
in reply to: Anonymous


@Anonymouswrote:

This has much better results if I reset any customization loaded and just load the pp.lsp.

 

Upon running the command.

It prompts 1st messge: 1 = 1/0 DBE, 2 = #2 LBE <2 = #2 LBE>:

When I hit ESC from this point, it does not prompt the "can not invoke..." but what should be normal:

   1 = 1/0 DBE, 2 = #2 LBE <2 = #2 LBE>: *Cancel*
   Function cancelled

 

If I do attempt to select one of the options and attempt to cancel at that point, it does cancel but is stuck at this point.

   1 = 1/0 DBE, 2 = #2 LBE <2 = #2 LBE>: 1
   Select P/L: (approx. PAD loc.) bad argument type: lentityp nil
   Command: *Cancel*


This is a clear sign another lisp is causing the error.

 


I would try to go back into the command after ESC from this point and it starts off at the Select P/L: (approx. PAD loc.)

Should it not start back from the beginning?


Because non of the variables are declared as local to the function, acad keeps their values.

This means in this case that after the first run the variable trans-block-name has a value and the function will not ask again because (if (= trans-block-name nil) is false.

 


I believe roland.r71 is correct as I recall the Trap function in other custom lsp code.  😞 

Upon running the command with all the other customizations and custom lsp code the way the system suppose to be setup, i still get the 

Cannot invoke (command) from *error* without prior call to (*push-error-using-command*)

 

Do I have alot of work to do, ugh.


I'm pretty sure i am 😛

 

Although i agree with N4mr4hdlanor that the code could use a serious overhaul, pp.lsp is not the source of your problem. If you follow his instructions on making the *error* trap local to the pp function, it should at least not occur while using it.

 

Like so:

(defun c:pp ( / *error* trans-block-name) 

   (defun *error* (msg)
      (princ msg)
      (setvar "highlight" 1)
      (setvar "cmdecho" cmd)
      (setvar "osmode" osm)
      (setvar "pickbox" orgpb)
      (princ)
   )

and delete (or comment) ALL other lines within the pp.lsp containing *error*.

 

note: it is best practice to add all vars used to the function definition as well

(like: (defun c:pp ( / *error* trans-block-name cmd osm orgpb etc etc etc))

Except those you wish to use globally (or to 'remember' previous user choices)

 

This will ensure the used variables do not exist (and can not accidentally be set (incorrectly)) outside the function. They  always start with value nil. After the function finnishes the variables get removed. Freeing up memory.

 

You should definately add trans-block-name here, if you wish the function to start from the beginning.

However, it looks like the original code supported it being global, and 'preset' but part of it has been commented.

 

Note: if you comment a "else" section for an (if, don't forget to comment the (cond ) ! (as has been forgotten here)

 

I took a look at the code to see if i could quickly rewrite it, but its a bit big for that. It does what it should do, anyway.

Message 8 of 12
dlanorh
in reply to: Anonymous

Slow going, as per Roland.r71's post above I'm attempting to localise all variables. There is a lot of redundant code. If you could give me an outline of what the lisp does it might help me filter out un neccessary code.

I am not one of the robots you're looking for

Message 9 of 12
Anonymous
in reply to: Anonymous

Going to piggy back on this thread as I am having the same issue with an old Express Command Mkshape & MkLtype... I guess they are just outdated as no one has ever touched these lisp files. My understanding of LISP is near Zero on coding.

MKshape Error.jpg

 

 

 

Have no clue what "Calls to (Command-s) is recommended" is or does or how to call to it.

 

All I wanted to do was create a new linetype, which requires me to make a new shape.

Attached the two LISP files, any help would be great! Thanks!

 

Tags (2)
Message 10 of 12
roland.r71
in reply to: Anonymous

Wierd.

The problem is not with any of these two functions/files.

They don't contain any "command" calls inside an *error* function.

 

They both DO use the ACET-ERROR-INIT, which comes with the ACETUTIL.ARX

 

As your lisps are exactly the same as mine & it all works on ACAD2015 (the first version requiring command-s) your problem is most likely caused by the ACET-ERROR-INIT.

 

Which in turn makes me wonder:

What version ACAD are you using?

& are you using the ExpressTools as supplied with that version, or are you using an older acetutil.arx?

Message 11 of 12

I too am having this issue with an older code that I came across.

This code calls an .lyr file, populates a DCL dialog and then gives the user the option to select everything or by selection. 

 

I have modified the (command)  --> to (command-s), but this has not resolved the issue.

 

I'm at a loss currently. The code runs intermittently depending on how many "layers" you select from the list.

 

help.

Message 12 of 12


@steve.carlsonZYQ68 wrote:

I too am having this issue with an older code that I came across.

....

I have modified the (command)  --> to (command-s), but this has not resolved the issue.

....


Help us help you.  Post the code.

Kent Cooper, AIA

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

Post to forums  

Forma Design Contest


AutoCAD Beta