Author Topic: "If" modification for attributes  (Read 2184 times)

0 Members and 1 Guest are viewing this topic.

Biscuits

  • Swamp Rat
  • Posts: 502
"If" modification for attributes
« on: August 11, 2005, 03:31:30 PM »
This routine will change all attributes with the value of 2005 to 2006.
How can I make it so it will also change any attribute value of 2004, 2003, 2002, etc. to 2006?
Thanks


Code: [Select]


(defun c:YEAR () ;(/  dastr )
 (setvar "cmdecho" 0)

 (setq dastr (strcat "2006"))

 (setq atts (ssget "x" '((0 . "INSERT") (66 . 1))))
 (if atts
  (progn
   (setq cnt 0)
   (repeat (sslength atts)
    (setq ename (ssname atts cnt))
    (while ename
     (setq ename (entnext ename))
     (if (/= (cdr (assoc 0 (entget ename))) "ATTRIB")
      (setq ename nil)
      (progn
       (if (= (cdr (assoc 1 (entget ename))) "2005")
        (progn
         (entmod (subst (cons 1 dastr) (assoc 1 (entget ename)) (entget ename)))
         (entupd (ssname atts cnt))
         (setq ename nil)
        )
       );end if
      )
     );end if
    );end while
    (setq cnt (1+ cnt))
   );end repeat      
 ));end if
)

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
"If" modification for attributes
« Reply #1 on: August 11, 2005, 03:42:56 PM »
Code: [Select]
...
      (setq ename nil)
      (progn
       (setq AttVal (cdr (assoc 1 (entget ename))))
       (if (and
            (wcmatch AttVal "####")
            (> (atoi AttVal)  1990)
            (< (atoi AttVal)  2006)
           )
        (progn
...
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

Biscuits

  • Swamp Rat
  • Posts: 502
"If" modification for attributes
« Reply #2 on: August 11, 2005, 04:05:31 PM »
I forgot to mention I'm using 2002 and I'm not sure where to place your portion of the code.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
"If" modification for attributes
« Reply #3 on: August 11, 2005, 04:12:01 PM »
Biscuits, Jürg used the ..... to show that he is clipping into the original code and then the
Code: [Select]

(setq ename nil)
    (progn
shows WHERE it is cutting in
and the last (progn is where it is done cutting in. So in the original code replace this part with what he posted:
Code: [Select]
(setq ename nil)
      (progn
       (if (= (cdr (assoc 1 (entget ename))) "2005")
        (progn