Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Lisp routine to add value 'x' to existing attribute values of a block

  1. #1
    Join Date
    Jul 2015
    Posts
    3

    Lisp routine to add value 'x' to existing attribute values of a block

    Hi All,

    I've a tricky one here - I'd like to add a value 'x' (eg. 3900) to the various existing values of a block I have in my drawings here. Would this actually be possible does anybody out there know??!

    It would be very useful and very time saving!!

    Thanks,
    Dave.

  2. #2
    Join Date
    Jul 2015
    Posts
    3
    Multiple occurrences of 1 block containing 1 attribute. Various values have been entered to that attribute and I would like to add an amount to each of those values....

  3. #3
    Join Date
    Jan 2010
    Location
    East coast; 2hrs. outside of NYC
    Posts
    3,836
    I suppose it might be possible using a custom lisp routine but I don't know of one off hand that would do the trick. It would involve some research.
    I'm Reese. Sergeant Tech-Com, DN38416. Assigned to protect you. You've been targeted for termination.

  4. #4
    Join Date
    Jul 2015
    Posts
    3
    Thanks Kyle - I've seen a few of your responses and if you don't know then I think it could well be beyond my capabilities just now at least. That said, I like a challenge so I'll let you know if I ever uncover anything... Cheers for response.
    Dave.

  5. #5
    Join Date
    Jan 2010
    Location
    East coast; 2hrs. outside of NYC
    Posts
    3,836
    So far this is the only thing I've found. I have NOT tested it. That's your job. Good luck.

    http://www.cadforum.cz/cadforum_en/a...blocks-tip7226
    I'm Reese. Sergeant Tech-Com, DN38416. Assigned to protect you. You've been targeted for termination.

  6. #6
    Join Date
    Jan 2011
    Posts
    26
    Something like this ?

    Code:
    (defun c:Test (/ s)
      ;;	Tharwat 22.7.2015	;;
      (princ "\nSelect Attributed Blocks")
      (if (setq s (ssget "_:L" '((0 . "INSERT")(66 . 1))))
        ((lambda (i / sn)
           (while (setq sn (ssname s (setq i (1+ i))))
           (mapcar '(lambda (u) (vla-put-textstring u (strcat "x" (vla-get-textstring u))))
                  (vlax-invoke (vlax-ename->vla-object sn) 'getattributes)
                  )
             ))
          -1)
        )
      (princ)
      ) (vl-load-com)

  7. #7
    Join Date
    Nov 2019
    Posts
    5
    its perfect
    can u help me to change it that it would change specific tag and not all
    the other thing is that i need to select only one block because im using it in another lisp

    thx ahead

    Quote Originally Posted by Tharwat View Post
    Something like this ?

    Code:
    (defun c:Test (/ s)
      ;;	Tharwat 22.7.2015	;;
      (princ "\nSelect Attributed Blocks")
      (if (setq s (ssget "_:L" '((0 . "INSERT")(66 . 1))))
        ((lambda (i / sn)
           (while (setq sn (ssname s (setq i (1+ i))))
           (mapcar '(lambda (u) (vla-put-textstring u (strcat "x" (vla-get-textstring u))))
                  (vlax-invoke (vlax-ename->vla-object sn) 'getattributes)
                  )
             ))
          -1)
        )
      (princ)
      ) (vl-load-com)

  8. #8
    Join Date
    Jan 2011
    Posts
    26
    Quote Originally Posted by MPD View Post
    its perfect
    can u help me to change it that it would change specific tag and not all
    the other thing is that i need to select only one block because im using it in another lisp

    thx ahead
    Please try the following and change the tag & block name that suits yours.
    NOTE: Block must be regular and not dynamic in this case.

    Code:
    (defun c:Test (/ tag bkn s)
      ;;	Tharwat 22.7.2015	;;
      (setq tag "Tag1"        ;; Tag name to match
            bkn "MyBlockName" ;; Block name to be selected <None Dynamic block>
      )
      (princ "\nSelect Attributed Blocks")
      (if (setq s (ssget "_:L" (list '(0 . "INSERT")(cons 2 bkn) '(66 . 1))))
        ((lambda (i / sn)
           (while (setq sn (ssname s (setq i (1+ i))))
           (mapcar '(lambda (u)
                      (and (vla-get-tagstring u tag)
                           (vla-put-textstring u (strcat "x" (vla-get-textstring u))))
                      )
                  (vlax-invoke (vlax-ename->vla-object sn) 'getattributes)
                  )
             ))
          -1)
        )
      (princ)
      ) (vl-load-com)

  9. #9
    Join Date
    Jan 2011
    Posts
    26
    Quote Originally Posted by MPD View Post
    its perfect
    can u help me to change it that it would change specific tag and not all
    the other thing is that i need to select only one block because im using it in another lisp

    thx ahead
    Please try the following and change the tag & block name that suits yours.
    NOTE: Block must be regular and not dynamic in this case.


    Code:
    (defun c:Test (/ tag bkn s)
      ;;	Tharwat 22.7.2015	;;
      (setq tag "Tag1"        ;; Tag name to match
            bkn "MyBlockName" ;; Block name to be selected <None Dynamic block>
      )
      (princ "\nSelect Attributed Blocks")
      (if (setq s (ssget "_:L" (list '(0 . "INSERT")(cons 2 bkn) '(66 . 1))))
        ((lambda (i / sn)
           (while (setq sn (ssname s (setq i (1+ i))))
           (mapcar '(lambda (u)
                      (and (vla-get-tagstring u tag)
                           (vla-put-textstring u (strcat "x" (vla-get-textstring u))))
                      )
                  (vlax-invoke (vlax-ename->vla-object sn) 'getattributes)
                  )
             ))
          -1)
        )
      (princ)
      ) (vl-load-com)

  10. #10
    Join Date
    Nov 2019
    Posts
    5
    hi
    i recieve a massege "Error: Too many actual parameters"

    Quote Originally Posted by Tharwat View Post
    Please try the following and change the tag & block name that suits yours.
    NOTE: Block must be regular and not dynamic in this case.


    Code:
    (defun c:Test (/ tag bkn s)
      ;;	Tharwat 22.7.2015	;;
      (setq tag "Tag1"        ;; Tag name to match
            bkn "MyBlockName" ;; Block name to be selected <None Dynamic block>
      )
      (princ "\nSelect Attributed Blocks")
      (if (setq s (ssget "_:L" (list '(0 . "INSERT")(cons 2 bkn) '(66 . 1))))
        ((lambda (i / sn)
           (while (setq sn (ssname s (setq i (1+ i))))
           (mapcar '(lambda (u)
                      (and (vla-get-tagstring u tag)
                           (vla-put-textstring u (strcat "x" (vla-get-textstring u))))
                      )
                  (vlax-invoke (vlax-ename->vla-object sn) 'getattributes)
                  )
             ))
          -1)
        )
      (princ)
      ) (vl-load-com)

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 7
    Last Post: 29-03-2014, 04:45 PM
  2. 2010 Hide Block During Plotting Lisp Routine
    By Ozdesigner62 in forum LISP Routines
    Replies: 0
    Last Post: 18-07-2012, 09:28 PM
  3. added new attribute to existing block
    By charslo in forum AutoCAD 2011 Help
    Replies: 2
    Last Post: 26-11-2011, 05:04 AM
  4. lisp routine for changing the block
    By kusha bhaskara in forum LISP Routines
    Replies: 0
    Last Post: 06-01-2009, 06:45 AM

Posting Permissions

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