Author Topic: New to LISP - Need Help with Routine  (Read 1435 times)

0 Members and 1 Guest are viewing this topic.

NPatton

  • Guest
New to LISP - Need Help with Routine
« on: April 05, 2017, 02:54:10 PM »
Hello Everyone,

I'm new to the LISP world and I'm having an issue with the routine below. As you can see I'm creating a circle at specific coords, creating a block of the circle, inserting the block, redoing that process over and over by moving the block down 5 units, and rename the block each time.

The problem I experience is that this process doesn't seem to work correctly from LISP routine to LISP routine. I created 4 of the same routines and the only difference between any of them is the LISP name, command name, coords, and saved file name. 2 out of the 4 routines work correctly. When the routine doesn't work correctly I will get 3 groups of blocks stacked on top of each other within the DWG at various points instead of a row of let's say 20 blocks spaced 5 units apart. Hopefully, I explained all this correctly and thanks in advance for any help.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:TS-1WD ()
  2.         (setq count 1)
  3.         (setq pt1 (list 230.0 535.0))
  4.         (setq filename "TS-1WD-")
  5.         (setq blks (getint "\nEnter the number of blocks you would like to create:" ))
  6.         (while (< count blks)
  7.                 (command "circle" pt1 0.25 )
  8.                 (setq countstr (itoa count))
  9.                 (princ countstr)
  10.                 (setq filename1 (strcat filename countstr))
  11.                 (princ filename1)
  12.                 (command "-block" filename1 pt1 "last" "")
  13.                 (command "-insert" filename1 pt1 "1" "1" "0")
  14.                 (setq pt1 (list  (car pt1)  (- (cadr pt1) 5.0)))
  15.         (setq count (+ count 1))
  16.         )
  17. )

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: New to LISP - Need Help with Routine
« Reply #1 on: April 05, 2017, 03:17:58 PM »
I think this is probably the *Classic* Command and Running Osnaps issue.

Since you are using command calls in your code the OSMODE variable can have an impact on the result.
Two solutions:

1. Temporarily change OSMODE to zero.

2. Use "_non" to override the running osnaps. Example:
Code: [Select]
(command "circle" "_non" pt1 0.25 )
EDIT: Typo.
« Last Edit: April 05, 2017, 03:38:19 PM by roy_043 »

NPatton

  • Guest
Re: New to LISP - Need Help with Routine
« Reply #2 on: April 06, 2017, 08:16:11 AM »
I will give this a try.

Thanks for the help Roy_043

ChrisCarlson

  • Guest
Re: New to LISP - Need Help with Routine
« Reply #3 on: April 06, 2017, 03:52:30 PM »
Don't forget to incorporate error trapping, it'll set the vars back to how they were pre-execution.