Page 2 of 2 FirstFirst 12
Results 11 to 11 of 11

Thread: Increment Selected Text

  1. #11
    Member
    Join Date
    2015-09
    Posts
    6
    Login to Give a bone
    0

    Default Re: Increment Selected Text

    Thanks for all your help Peter!

    I was able to create some code to do the text selection and offset and call your routines.

    I am not sure how it all works yet. It needs some error checking to stop if an offset is going to cause text less that 'A'.

    I realize now that some of the text is in blocks. That seems a bit more difficult to try to change. I will keep searching for code to do this also.

    Code:
     ;___________________________________________________________________________________________________________|
    
    (defun c:TEXT_Offset ( / entSelection intCount intLen strBase strList strNew strOld Offset )
    
        (setq strBase   "ABCDEFGHJKLMNPRSTUVWXYZ") ;AlphaNumeric
       
        (prompt "\nSelect Text to Change (any order):")
    
        (if (setq strList (ssget '((0 . "TEXT"))))
    
            (progn
    
                (setq intCount 0
    
                      intLen (sslength strList)
    
                )
    
    	    (setq Offset (getint "Enter Offset (+#/-#):"))
    
                (while (< intCount intLen)
                    
    		(setq entSelection (ssname strList intCount) 
    
    		      strOld (cdr(assoc 1 (entget entSelection)))  ;Get text from list
    		
    		      intNumber (BaseKToBase102 strBase strOld);  <- Convert BaseK String to Integer		
                    
    		      intNumber (+ Offset intNumber)
    
    		      strNew (Base10ToBaseK2 strBase intNumber);  <-Convert Integer to BaseK string
    
    		      entSelection (entget (ssname strList intCount))
    
                          entSelection (subst (cons 1 strNew) (assoc 1 entSelection) entSelection)
    
    		)
    
        		(entmod entSelection)
    
                    (Setq intCount (1+ intCount))
    
                 )
    
             ) 
    
        ) 
    
        (princ)
    )
    
    ;___________________________________________________________________________________________________________|
    ; By Peter http://forums.augi.com/
    
    (defun Base10ToBaseK2 (strBase intNumber / intBase intDigit intRemainder lstReturn )
     (setq intBase   (strlen strBase))
     (if (= intNumber 0)(setq lstReturn (list 0)))
     (while (> intNumber 0)
      (setq intDigit     (/ intNumber intBase))
      (setq intRemainder (- intNumber (* intBase intDigit)))
      (or (> intRemainder 0)
          (setq intRemainder intBase intDigit (1- intDigit))
      )
      (setq lstReturn    (cons intRemainder lstReturn))
      (setq intNumber    intDigit)
     )
     (apply 'strcat (mapcar '(lambda (X)(substr strBase X 1)) lstReturn))  
    )
    
    ;___________________________________________________________________________________________________________|
    ; By Peter http://forums.augi.com/
    (defun BaseKToBase102 (strBase strValue / intBase intCount intTotal)
     (setq intBase (strlen strBase))
     (setq intTotal 0)
     (repeat (setq intCount (strlen strValue))
      (setq intTotal (+ intTotal 
                        (* (expt intBase (- (strlen strValue) intCount))
                           (1+ (vl-string-search (substr strValue intCount 1) strBase))
                        )
                     )
      )
      (setq intCount (1- intCount))
     )
     intTotal
    
    )
    
    (vl-load-com)
    Attached Files Attached Files

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 5
    Last Post: 2016-08-11, 11:35 PM
  2. 2013: Copy and Increment Text
    By nlrdavid in forum AutoCAD General
    Replies: 6
    Last Post: 2013-05-16, 06:46 PM
  3. Replies: 2
    Last Post: 2007-12-17, 09:10 PM
  4. Increment Text
    By robert.1.hall72202 in forum AutoLISP
    Replies: 11
    Last Post: 2007-01-11, 08:11 PM
  5. Increment Text Numbers
    By larry.80915 in forum AutoCAD General
    Replies: 2
    Last Post: 2005-01-12, 05:39 PM

Posting Permissions

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