PAUSE in AutoLISP failing after starting new drawing from script.

PAUSE in AutoLISP failing after starting new drawing from script.

Niall3urke
Participant Participant
1,662 Views
7 Replies
Message 1 of 8

PAUSE in AutoLISP failing after starting new drawing from script.

Niall3urke
Participant
Participant

Can anyone help, please? A very specific problem has surfaced when using AutoCAD 2016 loading a new drawing from a script file and then a (command..) using PAUSE. The PAUSE causes failure. To show this, the following fragment: (original script and AutoLISP files attached. Script files renamed with TXT extension as cannot be attached otherwise!)

Thanks, John

 

;RECTPOS.LSP
;Simple fragment to test drawing and moving a rectangle when called from a script file
;in AutoCAD 2016
;The script file will start a new drawing (see below)
  (*push-error-using-command*)

  (princ "\nDraw rectangle and move it")
  ;Set some points
  (setq pt1 (list 100.0 100.0 0.0)
        pt2 (list 2100.0 100.0 0.0)
        pt3 (list 2100.0 1100.0 0.0)
        pt4 (list 100.0 1100.0 0.0)
  )
  ;Draw the rectangle
  (command "PLINE" pt1 pt2 pt3 pt4 pt1 "")

  (setq entp (entlast)
        ptZ (list 0.0 0.0 0.0)
        ptQ (list -100.0 -100.0 0.0)
  )

  ;show it
  (command "._ZOOM" "E")
  ;and make some space
  (command "._ZOOM" "0.5x")

  ;Drag the rectangle

  ;This works
  (command-s "._MOVE" entp "" ptZ ptQ )

  ;This fails when the script file has loaded a NEW drawing
  ;It works fine when this .LSP is loaded in an existing drawing
  ;It works fine in AutoCAD 2013!
  (command-s "._MOVE" entp "" ptZ PAUSE)

  (princ)


  ;The script file (A160627 NEW REC.SCR) starting a new drawing looks like:
  ; NEW
  ; Y
  ;
  ;(load "I:/MRC/DEV/RECTPOS.LSP")
  ;

  ;The script file (A160627 REC ONLY.SCR) only loading the above LSP into an existing drawing looks like:
  ;
  ;(load "I:/MRC/DEV/RECTPOS.LSP")
  ;

0 Likes
Accepted solutions (1)
1,663 Views
7 Replies
Replies (7)
Message 2 of 8

hmsilva
Mentor
Mentor

Hi John,

remove the empty line between Yes and load

 

  ;The script file (A160627 NEW REC.SCR) starting a new drawing looks like:
  ; NEW
  ; Y
  ;(load "I:/MRC/DEV/RECTPOS.LSP")
  ;

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 3 of 8

Niall3urke
Participant
Participant

Thank you for your response, Henrique. Unfortunately removing the blank line doesn't fix it: the blank line is there to accept the default template file, so omitting it skips over that and the output looks like: (see below, and slightly condensed).

(I've also use "." which works, giving the "none" template response)

 

Command: NEW
Really want to discard all changes to drawing? <N> Y
Enter template file name or [. (for none)] <C:\Users\John\appdata\local\autodesk\autocad 2016\r20.1\enu\template\acadiso.dwt>:(load "I:/MRC/DEV/RECTPOS.LSP")

Draw rectangle and move itPLINE Template drawing PLINE
is not on file.  Using defaults.Regenerating model.
Command:
Command:
Command:
Command:
Command:
Command:
Command: NEW
Enter template file name or [. (for none)] <C:\Users\John\appdata\local\autodesk\autocad 2016\r20.1\enu\template\acadiso.dwt>:._ZOOM Regenerating model.
Command:
Command: E Unknown command "E".  Press F1 for help.
Command: ._ZOOM
Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: 0.5x
Command: Application ERROR: Invalid type sent as command input
nil

0 Likes
Message 4 of 8

hmsilva
Mentor
Mentor

Weird, I did test the script in AC2016, without error...

 

 

 
Henrique

EESignature

0 Likes
Message 5 of 8

Niall3urke
Participant
Participant
Accepted solution

Yes, weird indeed Henrique

 

In desperation I tried a couple of things (included in revised listing, below):

1) Some random input to slow things down, a (getint). This worked but the prompt appeared twice, the first time with a *Cancel* after it. That led me to try 2) a (terpri) call, but no real logic behind that.

3) the *Cancel* response indicated to me that there was something left in the input buffer, so I added a (grread) call

 

Fixed! 

 

I'd still like to know the real reason why this occurs, but having wasted many hours trying track down the exact circumstances and then to sort it, I'm happy with this only very slightly kludgy solution.

 

Thanks for your interest.

 

John

0 Likes
Message 6 of 8

hmsilva
Mentor
Mentor

John,

glad you have it sorted!

 

In my current location I don't have 2016 to attempt to reproduce that behavior, but tomorrow I'll see if I can reproduce it.

 

Henrique

EESignature

0 Likes
Message 7 of 8

Niall3urke
Participant
Participant

Hello Henrique

 

I wonder if you've had a chance to look at that again, please? I've managed to find a workaround (as my previous post) but it would be nice if we could nail it properly! If only for others who might hit the same problem and to identify any underlying problem that has arisen in A2016

 

Regards

 

John

 

0 Likes
Message 8 of 8

hmsilva
Mentor
Mentor

@Anonymous wrote:

Hello Henrique

 

I wonder if you've had a chance to look at that again, please? I've managed to find a workaround (as my previous post) but it would be nice if we could nail it properly! If only for others who might hit the same problem and to identify any underlying problem that has arisen in A2016

 

Regards

 

John

 


Hi John,

unfortunately I can't reproduce that behavior in AC2016...

I don't have the slightest clue of what may be causing that problem. 😞

 

Henrique

EESignature

0 Likes