Author Topic: lisp routine has stopped working  (Read 1889 times)

0 Members and 1 Guest are viewing this topic.

Nielsen

  • Guest
lisp routine has stopped working
« on: February 21, 2006, 12:01:27 AM »
This lisp routine worked fine until I copied and pasted it within the same folder.  When I renamed it the original file name (ie minus 'copy of..') it stopped.  The routine adds a number to the number only text.

I dont think it's a problem with the code but I have included it anyway.  Does anyone have any ideas ?  I'm using 2006.

;* DXF takes an integer dxf code and an entity data list.
;* It returns the data element of the association pair.
(defun dxf (code elist)
  (cdr (assoc code elist))
)

;* ADD - adds/subtracts a number to/from selected figures. Requires DXF function.
(defun c:add ()
  (prompt "\nSelect numbers to amend...")
  (if (setq ss1 (ssget))
    (progn
      (setq amt     (getreal "\nEnter No. to add: ")
       count 0
       emax  (sslength ss1)
      )
      (prompt "\nSearching ")
      (while (< count emax)
   (setq en (ssname ss1 count)
         ed (entget en)
         et (dxf 0 ed)
   )
   (princ et)
   (prompt ".")
   (cond
     ((= et "mTEXT")
      (setq num (atof (cdr (assoc 1 ed))))
      (setq old (assoc 1 ed))
      (setq num (+ num amt))
      (setq nums (cons 1 (rtos num)))
      (setq ed (subst nums old ed))
      (entmod ed)
     )
   )
   (setq count (1+ count))
      )
    )
  )
  (setq ss1 nil)
)
(princ)

LUCAS

  • Newt
  • Posts: 32
Re: lisp routine has stopped working
« Reply #1 on: February 21, 2006, 12:27:04 AM »
     (= ET "mTEXT")
=> (or (= ET "TEXT") (= ET "MTEXT"))

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: lisp routine has stopped working
« Reply #2 on: February 21, 2006, 01:00:39 AM »
Incase you are looking for something more robust.

http://www.theswamp.org/forum/index.php?topic=518.0
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: lisp routine has stopped working
« Reply #3 on: February 21, 2006, 01:12:52 AM »
As Lucas fixed the error but did not elaborate.
Here is another way.
Code: [Select]
     ((member et '("MTEXT" "TEXT")) ; incorrect case "mTEXT"
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.