Jump to content

Incremental Attribute using AutoLisp


Recommended Posts


I am new to AutoLISP world. I am trying to write a code which will edit attribute in incremental numbering with each click on attribute. The easiest way command for it is "ATTIPEDIT".

But I failed use ATTIPEDIT in LISP. Pls help to run this code:



(defun c:DTAG ()
(setq no (getint "\n Enter Starting Number : "))
(setq pt T)
(while pt
 (setq notxt (itoa no))
 (setq pt (getpoint (strcat "\n Select Attribute to be changed ( "notxt" ) < exit > : ")))
 (if pt
  (command "_.ATTIPEDIT" pt notxt)
  (setq no (+ no 1))
 (princ "\n Routine terminated normally by User")
(setvar "CMDECHO" ocmd)
(setq *error* olderr) ;;Restore old error handler





PFA ACAD file to test. Try putting incremental numbers in place of "0".

HVAC Dynamic Blocks 09.02.2018.dwg

Edited by SLW210
Added Code Tags!
Link to comment
Share on other sites

Alternate Method :-


(while (setq pt	(nentsel (strcat "\n Select Attribute to be changed ( "
			 (itoa no)
			 " ) < exit > : "
 (setq e (entget (car pt)))
 (entmod (subst (cons 1 (itoa no)) (assoc 1 e) e))
 (setq no (1+ no))

Link to comment
Share on other sites

Satishrajdev you confused me for a moment I thought the same use nentsel then read your post, first glance Pt so it was looking for a xy point thats strange then realised its the variable name. Just me but 99% of the code here would use Pt Pt1 etc for xyz points. I am not being critical but what I am suggesting is that it would be better to use something like ent att etc as a variable name, particuarly for what appears to be a newcomer to the world of programming.

Link to comment
Share on other sites

Bigal, I know its standard practice what you suggested but I was just trying to simply OP's code and that's why I didn't change his any variable so that as newbie he can understand and learn where to make changes in code accordingly. I use the same standard practice which you mentioned above.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...