Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

change table data

3 REPLIES 3
Reply
Message 1 of 4
BorisVian
282 Views, 3 Replies

change table data

Hi,

 

I'm working on a LISP function that adds a predeterminated string to each layername in the dwg.

 

I came up with this:

 

 

(SETQ prefix "A-_82-_")
 (TBLNEXT "LAYER" T)
 (WHILE (SETQ la (TBLNEXT "LAYER"))
  (SETQ old (ASSOC 2 la)
     new (CONS 2 (STRCAT prefix (CDR old)))
  );setq
  (SETQ la (SUBST new old la))
  (princ "\nla is: ")(princ la) (princ "\n")
  (ENTUPD la)
  (ENTMOD la)
 );while
 (TBLNEXT "LAYER" T)

 

The line  (princ "\nla is: ")(princ la) (princ "\n") is thrown in to enable me to see the result of the while function, and is to be removed from the final version.

 

Now, everything seems to work fine, as the princ shows on the acad textstcreen.

Yet, when I check the layer palette, all layernames remain unchanged.

My guess is that I should use some other function then ENTMOD or ENTUPD to change the layertable, but I'm at a bit of a loss as to which function is required.

 

Any ideas anyone?

 

 

Cheers,

 

Steven

Tags (1)
3 REPLIES 3
Message 2 of 4
_Tharwat
in reply to: BorisVian

This may help .....

 

(setq prefix "A-_82-_")
(While
  (setq la (TBLNEXT "LAYER" (null la)))
   (setq lay (entget (tblobjname "LAYER" (setq Nme (cdr (assoc 2 la))))))
   (if (not (eq Nme "0"))
     (entmod
       (subst (cons 2 (strcat prefix (setq old (cdr (assoc 2 lay)))))
              (assoc 2 lay)
              lay
       )
     )
   )
)

 Tharwat

Message 3 of 4
BorisVian
in reply to: _Tharwat

Thanks, that did the trick!

 

Enjoy the weekend!

 

Steven

Message 4 of 4
_Tharwat
in reply to: BorisVian

You're welcome Steven .

 

Regards.

 

Tharwat

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost