Jump to content

need help making addition to existing attribute block numbering lisp


mtreyger

Recommended Posts

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

 

;;                                                                      ;;
;; ==================================================================== ;;
;;                                                                      ;;
;;  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
       [color=Blue]numZeros[/color])
 (vl-load-com)

[color=Blue]  (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
   )[/color]
 
 (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([color=Blue]num2Str[/color] 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]")

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 8 months later...
Anyways I had a minute, something like this? (changes are highlighted)

 

;;                                                                      ;;
;; ==================================================================== ;;
;;                                                                      ;;
;;  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
       [color=blue]numZeros[/color])
 (vl-load-com)

[color=blue] (initget 6)[/color]
[color=blue] (setq numZeros (getInt "\nEnter number of 0 prefix's:"))[/color]

[color=blue] (defun num2str (num / numStr)[/color]
[color=blue]   (setq numStr (itoa num))[/color]
[color=blue]   (If (< (strlen numStr) numZeros)[/color]
[color=blue]     (repeat (- numZeros (strlen numStr))[/color]
[color=blue]   (setq numStr (strcat "0" numStr))[/color]
[color=blue]   )[/color]
[color=blue]     )[/color]
[color=blue]   numStr[/color]
[color=blue]   )[/color]

 (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([color=blue]num2Str[/color] 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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

:o:oI 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.
Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

:o:oI 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.

It's 32 or 64 bit. No such thing as 34 - must be divisible by 8.

A little bit crazzzy.. Today I've got the error related to ActiveX

Any idea ?

Not sure what error you are referring to. Why don't you post the exact error displayed.

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.

Guest
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...