sanetmunde Posted February 12, 2018 Posted February 12, 2018 (edited) Hello, 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 () (princ "\n AUTOMATIC ATTRIBUTE SEQUENTIAL NUMBERING") (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 (progn (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 (princ) ) PFA ACAD file to test. Try putting incremental numbers in place of "0". HVAC Dynamic Blocks 09.02.2018.dwg Edited February 12, 2018 by SLW210 Added Code Tags! Quote
satishrajdev Posted February 12, 2018 Posted February 12, 2018 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)) ) Quote
SLW210 Posted February 12, 2018 Posted February 12, 2018 Please read the Code Posting Guidelines and have your Code to be included in Code Tags.[NOPARSE] Your Code Here[/NOPARSE] = Your Code Here Quote
BIGAL Posted February 13, 2018 Posted February 13, 2018 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. Quote
satishrajdev Posted February 13, 2018 Posted February 13, 2018 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. Quote
BIGAL Posted February 13, 2018 Posted February 13, 2018 No worries, reminds of when I started learning programming using fortran punch cards. Quote
Recommended Posts
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.