Author Topic: LISP to check for and add ONE annotation scale  (Read 10014 times)

0 Members and 1 Guest are viewing this topic.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: LISP to check for and add ONE annotation scale
« Reply #15 on: February 25, 2014, 01:53:01 PM »
OK so... I need an IF statement and an IF NOT statement for each scale in question? or just the IF NOT?

I'm using this code FYI:

Code - Auto/Visual Lisp: [Select]
  1. (defun _exists (dictionary name / d)
  2.   (if (setq d (cdr (assoc -1 (dictsearch (namedobjdict) dictionary))))
  3.     (dictsearch d name)
  4.   )
  5. )
  6. (IF (_exists "ACAD_SCALELIST" "TEST")
  7.      (command "-scalelistedit" "Add" "TEST" "1:100" "e")
  8. (command "-scalelistedit" "Add" "TEST" "Y" "1:100" "e")
  9. )

Thanks...
In your case:
Code: [Select]
(if (find-scale "TEST")
  (command "-scalelistedit" "Add" "TEST" "Y" "1:100" "e")
  (command "-scalelistedit" "Add" "TEST" "1:100" "e")
)
The 1st command will happen when the scale already exists. The 2nd if the scale doesn't exist. That's du to how if works (it's referred to as a if-then-else construct).

You could use either my find-scale function or Alan's. in this case they do the same thing.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

jpcadconsulting

  • Newt
  • Posts: 56
Re: LISP to check for and add ONE annotation scale
« Reply #16 on: February 25, 2014, 02:12:36 PM »
Brilliant!!!

Thanks so much...

-JP
Technology will save us all! *eyeroll*