+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17
  1. #1
    Full Member
    Using
    Electrical 2011
    Join Date
    Apr 2011
    Posts
    88

    Default change incatt.lsp to work with numbers with point, comma etc etc

    Registered forum members do not see this ad.

    Hello,
    i have a lisp routine incatt.lsp dat increase a attribute. It does only numbers like:
    1, 2, 3 etc etc.
    Is it possible to change the lisp that it changes/increment(attributes) numbers like: 4.32, 4.33, 4.34 etc So with numbers with a . or , or - and with steps .01?

    Thanks
    Attached Files

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    Quote Originally Posted by pmxcad View Post
    Hello,
    i have a lisp routine incatt.lsp dat increase a attribute. It does only numbers like:
    1, 2, 3 etc etc.
    Is it possible to change the lisp that it changes/increment(attributes) numbers like: 4.32, 4.33, 4.34 etc So with numbers with a . or , or - and with steps .01?

    Thanks
    Yes, it is possible

  3. #3
    Full Member
    Using
    Electrical 2011
    Join Date
    Apr 2011
    Posts
    88

    Default

    Can you help me?

    Thanks

    Pmxcad

  4. #4
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    Quote Originally Posted by pmxcad View Post
    Can you help me?
    But of course i'll help. listen pmxcad, the way the code is written, the existing value of the attribute doesn't come into play at any way. so whats the deal with "," and "-" ? Will those be the supplied value at prompt? or the resulting incremented value for the attribute entity. if the former, we cant use getreal nor getint for it would not accept those symbols.

    if the latter, i suppose we can reverse the sequence by asking to select an attribute first then use the pattern of the existing string to determine the proper prompt (getint/getreal)

    Bottom line: How would you prompt for value? or is it numbers after "," and "-" symbols?

    Show us an example dude.
    Last edited by pBe; 6th Oct 2012 at 04:34 am.

  5. #5
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,791

    Default

    Just change a couple of lines in code and add increment step this can be just press enter for 1

    Code:
     (getreal (Strcat  "\nSpecify Starting Number
    and
    (setq inc (getreal "\nSpecify increment "))
     
     (setq *num* (+ inc *num*))
    A man who never made mistakes never made anything

  6. #6
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    Quote Originally Posted by BIGAL View Post
    Just change a couple of lines in code and add increment step this can be just press enter for 1
    What i'm after is this Bigal ---- > "," or "-" , when and where does these symbols fit in?

  7. #7
    Full Member
    Using
    Electrical 2011
    Join Date
    Apr 2011
    Posts
    88

    Default

    Hello PBE,

    the numbers could be: 1.25, 1.26, 1.27 or 1-25, 1-26, 1-27 etc etc
    see example.

    PmxCAD
    Attached Files

  8. #8
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    Quick mod [untested]

    Code:
    (defun c:incatt ( / tag pre ss1 ) (vl-load-com)
    (defun determine (str)
      (list 
      (setq pre (vl-string-right-trim "0123456789" str))
      	 (atoi (substr str (1+(strlen pre))))))
      	
      (setq tag "E_TEXT1")
    
      (if (setq *num* (cond ( (getint (strcat "\nSpecify Starting Number"  (if *num* (strcat " <" (itoa *num*) "> : ") ": ")))) ( *num* )))
        (while (setq ss1 (ssget "_+.:E:S:L" '((0 . "INSERT") (66 . 1))))
          (if
            (vl-some
              (function
                (lambda ( x )
                  (if (eq tag (vla-get-tagstring x))
                    (not (vla-put-textstring x (strcat
                               (car (setq p (determine (vla-get-textstring x))))
                                    (strcat (if (and (< 0 (cadr p) 9)
                                                     (not (eq (car p) "")))
                                                  "0" "") (itoa (+ (cadr p) *num*))))))
                  )
                )
              )
              (vlax-invoke (vlax-ename->vla-object (ssname ss1 0)) 'getattributes)
            )
            (princ (strcat tag " Attribute not found."))
          )
        )
      )
      (princ)
    )
    HTH

  9. #9
    Full Member
    Using
    Electrical 2011
    Join Date
    Apr 2011
    Posts
    88

    Default

    Thanks for the replay, but sorry PBE, its not working correct.

    When i give a starting number like 1.25, Autocad returns "Requires an integer value".
    And when give a number like "1" it gives all the blocks selected, the number "1" and it doesnt count.

    PmxCAD

  10. #10
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    Registered forum members do not see this ad.

    That is what i wanted to know from the get-go. Tell me. is the existing string on the attribute relevant to the input value?

    The modified code increments the "existing value". thats the way i saw it from you attached example.

    Are you telling me that there are times that you would input "1-25" or "1,25"?

    Quote Originally Posted by pmxcad View Post
    And when give a number like "1" it gives all the blocks selected, the number "1" and it doesnt count.
    Are you sure about this? it should work on your "test.dwg"

    It's getting pretty late here pmxcad. we'll "increment" tomorrow
    Last edited by pBe; 6th Oct 2012 at 05:44 pm.

Similar Threads

  1. Replies: 4
    Last Post: 29th Aug 2012, 01:28 pm
  2. Routine to change page numbers
    By bernie_d_au in forum AutoLISP, Visual LISP & DCL
    Replies: 9
    Last Post: 27th Aug 2012, 05:22 am
  3. Replace point with comma
    By transcad in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 18th Apr 2012, 11:49 am
  4. Convert integers numbers into real numbers, introducing decimal separator.
    By teknomatika in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 3rd Sep 2010, 04:07 pm
  5. Change group of text numbers
    By LukeCAD in forum AutoCAD Drawing Management & Output
    Replies: 5
    Last Post: 18th May 2007, 08:37 am

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