+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Forum Newbie
    Discipline
    HVAC
    Using
    AutoCAD 2015
    Join Date
    Sep 2017
    Posts
    8

    Default Incremental Attribute using AutoLisp

    Registered forum members do not see this ad.

    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:


    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".
    Attached Files
    Last edited by SLW210; 12th Feb 2018 at 01:10 pm. Reason: Added Code Tags!

  2. #2
    Senior Member satishrajdev's Avatar
    Computer Details
    satishrajdev's Computer Details
    Operating System:
    Windows 7 - 64bit
    Computer:
    DELL
    RAM:
    8 GB
    Primary Storage:
    500 GB
    Monitor:
    DELL
    Discipline
    Surveying
    satishrajdev's Discipline Details
    Occupation
    CAD Engineer
    Discipline
    Surveying
    Details
    Design Survey Utilities (i.e. Bathymetry & Geophysical Survey) Design of Survey Planning. Preparation of Alignment Sheets. Programming in AutoCAD.
    Using
    AutoCAD 2014
    Join Date
    Apr 2012
    Location
    Aamchi Mumbai, India
    Posts
    451

    Default

    Alternate Method :-

    Code:
    (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))
    )
    Best Regards,
    Satish Rajdev

    If you ride like there is no tomorrow... Don't worry, there won't be !!!!
    www.facebook.com/satish.rajdev

  3. #3
    Super Moderator SLW210's Avatar
    Computer Details
    SLW210's Computer Details
    Operating System:
    Windows 7 PRO 64-bit
    Computer:
    IBM Lenovo
    Motherboard:
    ACPI x64
    CPU:
    Pentium(R) i5 4570 @ 3.2GHz
    RAM:
    8 GB RAM
    Graphics:
    Nvidia Quadro 600 1GB
    Primary Storage:
    300 GB
    Secondary Storage:
    650GB
    Monitor:
    2x ThinkVision 24"
    Discipline
    Multi-disciplinary
    SLW210's Discipline Details
    Occupation
    Design Draftsman
    Discipline
    Multi-disciplinary
    Details
    Mostly do drafting related to manufacturing. From doing site layouts with proposed updates, additions and renovations to be budgeted and submitted for bid, to updating and changing existing drawings to reflect maintenance and repair/revision work done on site.
    Using
    AutoCAD 2018
    Join Date
    May 2007
    Location
    South Florida, USA
    Posts
    12,124

    Default

    Please read the Code Posting Guidelines and have your Code to be included in Code Tags.[CODE]Your Code Here[/CODE] =
    Code:
    Your Code Here
    “A narrow mind and a fat head invariably come on the same person” Zig Zigler



  4. #4
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,702

    Default

    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.
    A man who never made mistakes never made anything

  5. #5
    Senior Member satishrajdev's Avatar
    Computer Details
    satishrajdev's Computer Details
    Operating System:
    Windows 7 - 64bit
    Computer:
    DELL
    RAM:
    8 GB
    Primary Storage:
    500 GB
    Monitor:
    DELL
    Discipline
    Surveying
    satishrajdev's Discipline Details
    Occupation
    CAD Engineer
    Discipline
    Surveying
    Details
    Design Survey Utilities (i.e. Bathymetry & Geophysical Survey) Design of Survey Planning. Preparation of Alignment Sheets. Programming in AutoCAD.
    Using
    AutoCAD 2014
    Join Date
    Apr 2012
    Location
    Aamchi Mumbai, India
    Posts
    451

    Default

    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.
    Best Regards,
    Satish Rajdev

    If you ride like there is no tomorrow... Don't worry, there won't be !!!!
    www.facebook.com/satish.rajdev

  6. #6
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,702

    Default

    Registered forum members do not see this ad.

    No worries, reminds of when I started learning programming using fortran punch cards.
    A man who never made mistakes never made anything

Similar Threads

  1. Incremental Attribute
    By satishrajdev in forum AutoLISP, Visual LISP & DCL
    Replies: 30
    Last Post: 19th Feb 2016, 02:34 pm
  2. Incremental numbering attribute block
    By crowscratch in forum AutoLISP, Visual LISP & DCL
    Replies: 9
    Last Post: 14th Jun 2014, 03:33 pm
  3. Incremental attribute edit by like values
    By scottE in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 26th Jun 2009, 02:13 pm
  4. Assign block attribute value to an AutoLISP variable?
    By cliath in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 22nd Mar 2006, 01:33 am
  5. Linking text box to attribute value (AutoLISP, VBA or...?)
    By scootermac in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 27th Sep 2005, 12:35 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts