Author Topic: Acad giving error while executing code  (Read 1013 times)

0 Members and 1 Guest are viewing this topic.

vincent.r

  • Newt
  • Posts: 101
Acad giving error while executing code
« on: April 15, 2018, 02:02:04 AM »
Hi guys,

I wrote some code to change attributed value in all blocks in a drawing. While executing command Acad perform the operation only for first block of selection set and gives error.

Error is - ; error: bad argument type: lentityp ((-1 . <Entity name: 7ef0fc90>) (0 . "ATTRIB") (330 . <Entity name: 7ef0fc78>) (5 . "37A") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "G-ANNO-TEXT") (100 . "AcDbText") (10 209.177 -1.01067 -4.91332e-047) (40 . 0.860742) (1 . "54") (50 . 0.0) (41 . 1.0) ..................


code is -
(setq ss (ssget "_X" '((0 . "INSERT") (66 . 1))))
   (while (/= (sslength ss) 0)
   (setq ssfi (ssname ss 0))
   (setq ssx (entnext ssfi))
   (setq ssy (entget ssx))

      (while (/= (cdr (assoc 1 (entget ssx))) "XYZ")
             (setq ssx (entnext ssx))
      )

      (if (= (cdr (assoc 1 (entget ssx))) "XYZ")
      (progn
      (setq ssx (entget ssx))
      (setq newVal "54")
      (setq ssx (subst (cons 1 newVal) (assoc 1 ssx) ssx))
      )
      )

   (entmod ssx)
   (entupd ssx)
   (ssdel ssfi ss)
   )

Drawing file attached.

I dont know where I made mistake.

Please help.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Acad giving error while executing code
« Reply #1 on: April 15, 2018, 02:55:52 AM »
Hi,

You're using the same symbol ssx for both the attrib ename and its dxf list: (sets ssx (entget ssx))

You should use more self explanatory symbol for your variables

Code - Auto/Visual Lisp: [Select]
  1. (setq ss (ssget "_X" '((0 . "INSERT") (66 . 1))))
  2. (repeat (setq index (sslength ss))
  3.   (setq block (ssname ss (setq index (1- index))))
  4.   (setq attrib (entnext block))
  5.   (while (and (setq attribDxfList (entget attrib))
  6.               (= (cdr (assoc 0 attribDxfList)) "ATTRIB")
  7.          )
  8.     (if (= (cdr (assoc 1 attribDxfList)) "XYZ")
  9.       (entmod (subst '(1 . "54") '(1 . "XYZ") attribDxfList))
  10.     )
  11.     (setq attrib (entnext attrib))
  12.   )
  13. )
Speaking English as a French Frog

vincent.r

  • Newt
  • Posts: 101
Re: Acad giving error while executing code
« Reply #2 on: April 15, 2018, 03:37:31 AM »
Oh. Thank you very much gile,

will follow your guideline.