+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Forum Newbie
    Using
    AutoCAD 2010
    Join Date
    Oct 2009
    Posts
    3

    Default need help making addition to existing attribute block numbering lisp

    Registered forum members do not see this ad.

    Hey,

    New to the forums, old to CAD, might as well jump right in with my problem.

    I recently found this amazing lisp app by ASMI (AsmiTools_Renum.lsp)

    while i find this app very useful, there is another little attribute that i would like added to the lisp.

    As it stands, after you give your prefix/suffix/starting number, the lisp begins to start counting from 1 etc...

    The problem is that sometimes my blocks need to hold decimal places for counts that will be over 100/1000 etc...

    Would it be possible for the app to ask you how many integer places the sequential number should have.

    ie.. 3 places for example, so it starts the count at 001 instead of 1.
    or for 2 places, so it starts at 01,
    or 4 places, so it starts at 0001.

    If someone could include the code to do this, or edit the lisp itself, it would be greatly appreciated.

  2. #2
    Senior Member
    Using
    AutoCAD 2011
    Join Date
    Mar 2009
    Location
    Queensland, Australia
    Posts
    350

    Default

    Hey,

    Quick question, why can't you just enter a 0 (or multiple zeros) when the program asks for a prefix? Admittedly you'd have to reset the program when you reach say 10, but is that so common?

  3. #3
    Senior Member
    Using
    AutoCAD 2011
    Join Date
    Mar 2009
    Location
    Queensland, Australia
    Posts
    350

    Default

    Anyways I had a minute, something like this? (changes are highlighted)

    Code:
    ;;                                                                      ;;
    ;; ==================================================================== ;;
    ;;                                                                      ;;
    ;;  RENUM.LSP - This program converts TEXT, MTEXT and ATTRIBUTES in     ;;
    ;;              numbers with a prefix and a suffix.                     ;;
    ;;                                                                      ;;
    ;; ==================================================================== ;;
    ;;                                                                      ;;
    ;;  Command(s) to call: RENUM                                           ;;
    ;;                                                                      ;;
    ;;  Specify a suffix, a prefix and starting number (for erase the old   ;;
    ;;  suffix or prefix you should press Spacebar). Pick to TEXT, MTEXT    ;;
    ;;  ATTRIBUTES or press Esc to quit. The program remembers old          ;;
    ;;  properties and it is possible to confirm it pressing of Spacebar    ;;
    ;;  key.                                                                ;;
    ;;                                                                      ;;
    ;; ==================================================================== ;;
    ;;                                                                      ;;
    ;;  THIS PROGRAM AND PARTS OF IT MAY REPRODUCED BY ANY METHOD ON ANY    ;;
    ;;  MEDIUM FOR ANY REASON. YOU CAN USE OR MODIFY THIS PROGRAM OR        ;;
    ;;  PARTS OF IT ABSOLUTELY FREE.                                        ;;
    ;;                                                                      ;;
    ;;  THIS PROGRAM PROVIDES 'AS IS' WITH ALL FAULTS AND SPECIFICALLY      ;;
    ;;  DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS        ;;
    ;;  FOR A PARTICULAR USE.                                               ;;
    ;;                                                                      ;;
    ;; ==================================================================== ;;
    ;;                                                                      ;;
    ;;  V1.0, 16 June, 2005, Riga, Latvia                                   ;;
    ;;  © Aleksandr Smirnov (ASMI)                                          ;;
    ;;  For AutoCAD 2000 - 2008 (isn't tested in a next versions)           ;;
    ;;                                                                      ;;
    ;;                             http://www.asmitools.com                 ;;
    ;;                                                                      ;;
    ;; ==================================================================== ;;
    
    
    
    (defun c:renum (/ oldPref oldSuf oldStart curText curStr
            numZeros)
      (vl-load-com)
    
      (initget 6)
      (setq numZeros (getInt "\nEnter number of 0 prefix's:"))
    
      (defun num2str (num / numStr)
        (setq numStr (itoa num))
        (If (< (strlen numStr) numZeros)
          (repeat (- numZeros (strlen numStr))
        (setq numStr (strcat "0" numStr))
        )
          )
        numStr
        )
      
      (if(not rnm:Pref)(setq rnm:Pref "")) 
      (if(not rnm:Suf)(setq rnm:Suf "")) 
      (if(not rnm:Start)(setq rnm:Start 1)) 
      (setq oldPref rnm:Pref 
            oldSuf rnm:Suf 
            oldStart rnm:Start); end setq 
      (setq rnm:Pref 
        (getstring T 
          (strcat "\nPrefix: <"rnm:Pref">: "))) 
      (if(= "" rnm:Pref)(setq rnm:Pref oldPref)) 
      (if(= " " rnm:Pref)(setq rnm:Pref "")) 
      (setq rnm:Suf 
        (getstring T 
          (strcat "\nSuffix: <"rnm:Suf">: "))) 
      (if(= "" rnm:Suf)(setq rnm:Suf oldSuf)) 
      (if(= " " rnm:Suf)(setq rnm:Suf "")) 
      (setq rnm:Start 
        (getint 
          (strcat "\nStarting number <" 
             (itoa rnm:Start)">: "))) 
      (if(null rnm:Start)(setq rnm:Start oldStart))
         (while T 
           (setq curStr(strcat rnm:Pref(num2Str rnm:Start)rnm:Suf)) 
             (setq curText 
               (car 
                 (nentsel "\n<<< Pick TEXT, MTEXT or ATTRIBUTE or press Esc to quit >>> "))) 
           (if 
             (and 
               curText 
               (member(cdr(assoc 0(entget curText))) '("TEXT" "MTEXT" "ATTRIB")) 
               ); end and 
             (progn 
             (vla-put-TextString 
               (vlax-ename->vla-object curText)curStr) 
                (setq rnm:Start(1+ rnm:Start)) 
             ); end progn 
            (princ "\n This is not DText or MText ") 
            ); end if 
           ); end while 
       (princ) 
      ); end of c:renum
    
    (princ "\n[Info] http:\\\\www.AsmiTools.com [Info]")
    (princ "\n[Info] Renumber tool. Type RENUM to run. [Info]")

  4. #4
    Forum Newbie
    Using
    AutoCAD 2010
    Join Date
    Oct 2009
    Posts
    3

    Default

    its actually very common,

    being a telecom consultant, i have to label outlets in a office building,

    so we're talking hundreds of outlets per floor

    im going to try the code addition and see if it works shortly.

  5. #5
    Forum Newbie
    Using
    AutoCAD 2010
    Join Date
    Oct 2009
    Posts
    3

    Default

    amazing work steve, works like a charm, thank you

  6. #6
    Senior Member
    Using
    AutoCAD 2011
    Join Date
    Mar 2009
    Location
    Queensland, Australia
    Posts
    350

    Default

    No problem.
    Not sure if you'll find it more useful but have you tried Lee Mac's Number Incrementing program?

  7. #7
    Senior Member vinod's Avatar
    Using
    AutoCAD 2008
    Join Date
    Jul 2007
    Location
    India
    Posts
    167

    Default

    Quote Originally Posted by SteveK View Post
    Anyways I had a minute, something like this? (changes are highlighted)

    Code:
    ;;                                                                      ;;
    ;; ==================================================================== ;;
    ;;                                                                      ;;
    ;;  RENUM.LSP - This program converts TEXT, MTEXT and ATTRIBUTES in     ;;
    ;;              numbers with a prefix and a suffix.                     ;;
    ;;                                                                      ;;
    ;; ==================================================================== ;;
    ;;                                                                      ;;
    ;;  Command(s) to call: RENUM                                           ;;
    ;;                                                                      ;;
    ;;  Specify a suffix, a prefix and starting number (for erase the old   ;;
    ;;  suffix or prefix you should press Spacebar). Pick to TEXT, MTEXT    ;;
    ;;  ATTRIBUTES or press Esc to quit. The program remembers old          ;;
    ;;  properties and it is possible to confirm it pressing of Spacebar    ;;
    ;;  key.                                                                ;;
    ;;                                                                      ;;
    ;; ==================================================================== ;;
    ;;                                                                      ;;
    ;;  THIS PROGRAM AND PARTS OF IT MAY REPRODUCED BY ANY METHOD ON ANY    ;;
    ;;  MEDIUM FOR ANY REASON. YOU CAN USE OR MODIFY THIS PROGRAM OR        ;;
    ;;  PARTS OF IT ABSOLUTELY FREE.                                        ;;
    ;;                                                                      ;;
    ;;  THIS PROGRAM PROVIDES 'AS IS' WITH ALL FAULTS AND SPECIFICALLY      ;;
    ;;  DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS        ;;
    ;;  FOR A PARTICULAR USE.                                               ;;
    ;;                                                                      ;;
    ;; ==================================================================== ;;
    ;;                                                                      ;;
    ;;  V1.0, 16 June, 2005, Riga, Latvia                                   ;;
    ;;  © Aleksandr Smirnov (ASMI)                                          ;;
    ;;  For AutoCAD 2000 - 2008 (isn't tested in a next versions)           ;;
    ;;                                                                      ;;
    ;;                             http://www.asmitools.com                 ;;
    ;;                                                                      ;;
    ;; ==================================================================== ;;
     
     
     
    (defun c:renum (/ oldPref oldSuf oldStart curText curStr
            numZeros)
      (vl-load-com)
     
     (initget 6)
     (setq numZeros (getInt "\nEnter number of 0 prefix's:"))
     
     (defun num2str (num / numStr)
       (setq numStr (itoa num))
       (If (< (strlen numStr) numZeros)
         (repeat (- numZeros (strlen numStr))
       (setq numStr (strcat "0" numStr))
       )
         )
       numStr
       )
     
      (if(not rnm:Pref)(setq rnm:Pref "")) 
      (if(not rnm:Suf)(setq rnm:Suf "")) 
      (if(not rnm:Start)(setq rnm:Start 1)) 
      (setq oldPref rnm:Pref 
            oldSuf rnm:Suf 
            oldStart rnm:Start); end setq 
      (setq rnm:Pref 
        (getstring T 
          (strcat "\nPrefix: <"rnm:Pref">: "))) 
      (if(= "" rnm:Pref)(setq rnm:Pref oldPref)) 
      (if(= " " rnm:Pref)(setq rnm:Pref "")) 
      (setq rnm:Suf 
        (getstring T 
          (strcat "\nSuffix: <"rnm:Suf">: "))) 
      (if(= "" rnm:Suf)(setq rnm:Suf oldSuf)) 
      (if(= " " rnm:Suf)(setq rnm:Suf "")) 
      (setq rnm:Start 
        (getint 
          (strcat "\nStarting number <" 
             (itoa rnm:Start)">: "))) 
      (if(null rnm:Start)(setq rnm:Start oldStart))
         (while T 
           (setq curStr(strcat rnm:Pref(num2Str rnm:Start)rnm:Suf)) 
             (setq curText 
               (car 
                 (nentsel "\n<<< Pick TEXT, MTEXT or ATTRIBUTE or press Esc to quit >>> "))) 
           (if 
             (and 
               curText 
               (member(cdr(assoc 0(entget curText))) '("TEXT" "MTEXT" "ATTRIB")) 
               ); end and 
             (progn 
             (vla-put-TextString 
               (vlax-ename->vla-object curText)curStr) 
                (setq rnm:Start(1+ rnm:Start)) 
             ); end progn 
            (princ "\n This is not DText or MText ") 
            ); end if 
           ); end while 
       (princ) 
      ); end of c:renum
     
    (princ "\n[Info] http:\\\\www.AsmiTools.com [Info]")
    (princ "\n[Info] Renumber tool. Type RENUM to run. [Info]")

    I've got what I was looking for long time. It's working in my laptop and failed to get the same result in my office system which installed the same version (Acad2009) Autocad. I've been receiving error message something like 'cant paste text'. Please get me a solution in this regard.

    Thanks in advance

  8. #8
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2011
    Join Date
    Apr 2008
    Posts
    5,985

    Default

    Works fine on my end. Can't say I've ever seen the 'can't past text' error. Are you trying it on the same drawing? Post a sample drawing.
    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  9. #9
    Senior Member vinod's Avatar
    Using
    AutoCAD 2008
    Join Date
    Jul 2007
    Location
    India
    Posts
    167

    Default

    I have tried it on the same drawing in different machines. The difference is 34 bit Autocad in my office sysytem and 64 bit in my laptop.

  10. #10
    Senior Member vinod's Avatar
    Using
    AutoCAD 2008
    Join Date
    Jul 2007
    Location
    India
    Posts
    167

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by alanjt View Post
    Works fine on my end. Can't say I've ever seen the 'can't past text' error. Are you trying it on the same drawing? Post a sample drawing.
    A little bit crazzzy.. Today I've got the error related to ActiveX
    Any idea ?

Similar Threads

  1. Replies: 36
    Last Post: 8th May 2012, 05:33 pm
  2. Attribute vs existing block
    By bert in forum AutoCAD Beginners' Area
    Replies: 4
    Last Post: 26th Aug 2008, 07:43 pm
  3. Problem adding attribute to existing block
    By Lucid in forum AutoCAD Drawing Management & Output
    Replies: 5
    Last Post: 16th Jan 2008, 05:48 pm
  4. add an attribute to existing block?
    By Leen in forum AutoCAD General
    Replies: 3
    Last Post: 19th Apr 2006, 08:11 am
  5. Making block with lisp. Name?
    By J-LYLE in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 20th Oct 2005, 10:59 pm

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