Results 1 to 8 of 8

Thread: Need help fixing lisp routine that bumps up number in an attribute

  1. #1
    Member
    Join Date
    2017-08
    Posts
    4
    Login to Give a bone
    0

    Default Need help fixing lisp routine that bumps up number in an attribute

    I found a lisp quite some time ago on here that add/subtracts to an attribute number within a drawing. However, it gives you an option to add/subtract a number between -5 and 5, I need it to not ask that and just add 1 to the existing number in the attribute without any prompts. I'm quite new to actually dissecting lisps as well but I'm trying to figure it out!

    I have to add +1 to the revision number in 100+ drawings frequently and this would be super helpful. Below is the existing lisp, I think I can figure it out to how to make it batch open and save multiple drawings in a selected folder, but some input on that is also welcome, thanks!

    Block Name: TAD15
    Tag: REV

    Code:
    (defun c:RevPurge ( / ToSum SelSet Items Index BlkName AttName AttDxf )
      (initget 3 )
      (if (setq ToSum (getint "Enter an integer (example 5 or -5 ) to add or subtract : " ) )
        (progn
          (while (setq SelSet (ssget '((-4 . "<and" )(0 . "INSERT" )(2 . "TAD15" )(-4 . "and>" ))) )
            (setq Items (sslength SelSet ) )
            (setq Index -1 )
            (repeat Items
              (setq Index (1+ Index ) )
              (setq BlkName (ssname SelSet Index ) )
              (setq AttName (entnext BlkName ) )
              (while AttName
                (setq AttDxf (entget AttName ) )
                (if (=(cdr (assoc 2 AttDxf )) "REV"  )
                  (progn
                    (setq AttDxf (subst (cons 1 (itoa (+ (atoi (cdr (assoc 1 AttDxf ))) ToSum ))) (assoc 1 AttDxf ) AttDxf ) )
                    (entmod AttDxf )
                    (entupd BlkName )
                  )
                  ( )
                )
                (if (= (cdr (assoc 0 (entget AttName ))) "SEQEND" ) (setq AttName nil ) (setq AttName (entnext AttName )) )
              )
            )
          )
        )
        ( )
      )
      (princ)
    )

  2. #2
    I could stop if I wanted to
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    275
    Login to Give a bone
    0

    Default Re: Need help fixing lisp routine that bumps up number in an attribute

    Try it

    Code:
      (if
        ;(setq ToSum (getint "Enter an integer (example 5 or -5 ) to add or subtract : " ) )
        (setq ToSum 1)
    the semi colon coment the line , or override

    then it set tosum to be 1

    As I dont have your DWG , I cant test.

  3. #3
    Member
    Join Date
    2017-08
    Posts
    4
    Login to Give a bone
    0

    Default Re: Need help fixing lisp routine that bumps up number in an attribute

    Thanks for your input! Unfortunately I cannot seem to get that to work, I'll attach a similar dwg with the block in which I'm asking.

    ACAD-TITLEBLOCK.dwg

    All I need is the code to establish the current number in the revision tag of the block, then add +1 to the value. Ideally I could then locate a folder and have it batch open, lisp command, then save all dwg files within the folder.

  4. #4
    I could stop if I wanted to
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    275
    Login to Give a bone
    0

    Default Re: Need help fixing lisp routine that bumps up number in an attribute

    I can not see the TAD15 block

    no tad15 block.PNG

  5. #5
    Member
    Join Date
    2017-08
    Posts
    4
    Login to Give a bone
    0

    Default Re: Need help fixing lisp routine that bumps up number in an attribute

    Sorry,

    the block name in the attached drawing has changed to "TITLEBLOCK", the tag is still "REV"

  6. #6
    I could stop if I wanted to
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    275
    Login to Give a bone
    0

    Default Re: Need help fixing lisp routine that bumps up number in an attribute

    Hi try it please


    Code:
    ;; Arranged  by Gabo CALOS DE VIT from CORDOBA ARGENTINA
    ;;;    Copyleft 1995-2017 by Gabriel Calos De Vit 
    ;; DEVITG@GMAIL.COM    
    
    ;;*************************************************************************************************************************
    
    ;; it is not mine , 
    (defun GetAllAttributes (objSelection /)
     (if (= (type objSelection) 'ename)
      (setq objSelection (vlax-ename->vla-object objSelection))
     )
     (if (vlax-property-available-p objSelection "hasattributes")  
      (if (= (vla-get-hasattributes objSelection) :vlax-true)  
       (vlax-safearray->list 
        (variant-value 
         (vla-getattributes objSelection)
        )
       ) 
      )
     )
    )
    ;;************************************************************************************
    ;; some changes 
    (DEFUN C:ATT-ADD-1  (/ ATT-LIST BLKNAME SELSET TAG-NAME TAG-VALUE TOSUM)
    (vl-load-com)
    
      (SETQ TOSUM 1)
      (IF (SETQ SELSET (SSGET "_x" '((0 . "INSERT") (2 . "TITLEBLOCK"))))
        (PROGN
          (SETQ BLKNAME (SSNAME SELSET 0))
          (SETQ ATT-LIST (GETALLATTRIBUTES BLKNAME))
          (FOREACH ATT  ATT-LIST
            (IF (= "REV" (SETQ TAG-NAME (VLA-GET-TAGSTRING ATT)))
              (PROGN
                (SETQ TAG-VALUE (VLA-GET-TEXTSTRING ATT))
                (VLA-PUT-TEXTSTRING ATT (ITOA (+ TOSUM (ATOI (VLA-GET-TEXTSTRING ATT)))))
                ) ;progn
              ) ; if
            ) ; foreach
          ) ;progn
        ) ;if
      )
    ;; end C:ATT-ADD-1
    
    
    ;|«Visual LISP© Format Options»
    (180 2 1 0 nil "end of " 100 20 2 2 nil nil T nil T)
    ;*** DO NOT add text below the comment! ***|;
    Attached Files Attached Files
    Last edited by devitg.89838; 2017-08-31 at 01:27 AM. Reason: lost (vl-load-com)

  7. #7
    Member
    Join Date
    2017-08
    Posts
    4
    Login to Give a bone
    0

    Default Re: Need help fixing lisp routine that bumps up number in an attribute

    That works PERFECTLY! Thank you so much!

  8. #8
    I could stop if I wanted to
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    275
    Login to Give a bone
    0

    Default Re: Need help fixing lisp routine that bumps up number in an attribute

    Glad to know , you can change the TOSUM variable , the block name and the TAG NAME , to suit for other need

    Code:
    (SETQ TOSUM 1)
    1

    Code:
    (2 . "TITLEBLOCK")
    TITLEBLOCK



    Code:
    (= "REV" (SETQ TAG-NAME (VLA-GET-TAGSTRING ATT))
    REV

Similar Threads

  1. Replies: 13
    Last Post: 2018-10-08, 08:03 AM
  2. Set file name from block attribute with lisp routine
    By email.dnewton396831 in forum AutoLISP
    Replies: 0
    Last Post: 2013-07-03, 08:51 PM
  3. Auto number attribute lisp fix
    By Zuke in forum AutoLISP
    Replies: 71
    Last Post: 2011-10-11, 04:26 PM
  4. Help with number placing LISP routine
    By Heather_W in forum AutoLISP
    Replies: 10
    Last Post: 2007-02-15, 02:03 PM
  5. Replies: 9
    Last Post: 2006-07-11, 11:09 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
  •