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

Thread: Adding or subtracting from attributes

  1. #1
    Active Member
    Join Date
    2004-11
    Posts
    55
    Login to Give a bone
    0

    Default Adding or subtracting from attributes

    I have a simple attributes block that is used for marking out elevations on the construction plan. My problem is at times i may miss one or have to many and delete a few and so on. then i have to go through the entire process of double clicking so the dialog box pops up and entering each number over again. I'd like to be able to just type in a command have it ask me if i want to subtract or add.. then i enter the number to add and it will add to the elevation number my specified number for each elevation marker i click so if i have 2 elevation markers 1 and 2 and i want them to be 2 and 3, with the lisp i can just enter in that i want to add one and click 1 and it turns to 2 etc.. and when i hit enter it will ask me again about adding or subtracting and this time it will add or subtract a given number from the page number or second number. is there a lisp out there or is it easy to develop or is it something im missing about attributes?

    thanks for any replies

  2. #2
    Member jrd.chapman's Avatar
    Join Date
    2000-11
    Location
    Ontario, Canada
    Posts
    49
    Login to Give a bone
    0

    Default Re: Adding or subtracting from attributes

    I wrote an application that will run calculations on attributes, as well as change almost anything else about their appearance. it is attached to this post inside a ZIP file. Give it a try and see what you think.
    Attached Files Attached Files
    Last edited by jrd.chapman; 2005-01-06 at 08:41 PM.

  3. #3
    Active Member
    Join Date
    2004-11
    Posts
    55
    Login to Give a bone
    0

    Default Re: Adding or subtracting from attributes

    Hmm, the link doesnt work....ok now it works

    hmmm, well it only seems to multiply i need addition or subtraction, and it edits both the elevaion number and sheet number at the same time... but pretty nifty indeed.
    Last edited by b_v_mc; 2005-01-06 at 08:51 PM.

  4. #4
    Member jrd.chapman's Avatar
    Join Date
    2000-11
    Location
    Ontario, Canada
    Posts
    49
    Login to Give a bone
    0

    Default Re: Adding or subtracting from attributes

    You need to use DELTA instead of multiply. It will add or subtract. (i.e. type in 1 for the delta if you want to add 1, or -1 if you want to subtract.)

    If more than one attribute in your block have the same TAG, then they will all get changed. Try using the ATTAG function to change the TAG for your elevations to something unique, then try your calculation again. If that does not work, then try redefining the block, making sure that the elevation attribute has a unique TAG value.
    Last edited by jrd.chapman; 2005-01-06 at 09:21 PM.

  5. #5
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Adding or subtracting from attributes

    Hi b_v_mc

    First of all, I do not know the name of Your block, neither the name of the attribute,
    because of that I presuppose that the block name is "MYBLOCK" and the attribute name is "VALUE", You have to change the code to match Your block name from "MYBLOCK" and the attribute tag from "VALUE".
    Code:
    (defun c:AttSum ( / 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 . "MYBLOCK" )(-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 )) "VALUE"  )
                  (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)
    )
    : ) Happy Computing !

    kennet

  6. #6
    Active Member
    Join Date
    2004-11
    Posts
    55
    Login to Give a bone
    0

    Default Re: Adding or subtracting from attributes

    Hey Thanks for the reply guys ill try these when i have some free time.

  7. #7
    Woo! Hoo! my 1st post
    Join Date
    2006-08
    Posts
    1
    Login to Give a bone
    0

    Default Re: Adding or subtracting from attributes

    I applaud you are you lisp writing skills. I do have a question of how can you modify it to subtract one attribute from the other and label the difference at a particulat location?

  8. #8
    Member
    Join Date
    2000-11
    Posts
    11
    Login to Give a bone
    0

    Default Re: Adding or subtracting from attributes

    This is nice but how can I make it work for the following?

    I have hundreds of attributed blocks as part of a multileader for my spot elevations. My task is to raise the entire site half a foot. Does anyone have a lisp routine that can drill down into the multileader find the multiple instances of attributes within it and raise the numeric value by .5. I've seen it done to a regular attributed block but not one within a multileader and I'd prefer not to have to explode all of them. Thanks.

  9. #9
    Woo! Hoo! my 1st post
    Join Date
    2016-11
    Posts
    1
    Login to Give a bone
    0

    Default Re: Adding or subtracting from attributes

    Quote Originally Posted by kennet.sjoberg View Post
    Hi b_v_mc

    First of all, I do not know the name of Your block, neither the name of the attribute,
    because of that I presuppose that the block name is "MYBLOCK" and the attribute name is "VALUE", You have to change the code to match Your block name from "MYBLOCK" and the attribute tag from "VALUE".
    Code:
    (defun c:AttSum ( / 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 . "MYBLOCK" )(-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 )) "VALUE"  )
                  (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)
    )
    : ) Happy Computing !

    kennet
    This is very useful thank you but can you create a lisp routine to accept real values instead of integer values for example 1.000 (to 3 decimal places) Your help is appreciated.

  10. #10
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Adding or subtracting from attributes

    Hi "Longname" !
    You did find a really old post, and I have not been here for a very long time.
    But I will give you some help. There is two lines to change:

    Change :
    (if (setq ToSum (getint "Enter an integer (example 5 or -5 ) to add or subtract : " ) )
    to :
    (if (setq ToSum (getreal "Enter a real (example 5.001 or -5.001 ) to add or subtract : " ) )

    And change :
    (setq AttDxf (subst (cons 1 (itoa (+ (atoi (cdr (assoc 1 AttDxf ))) ToSum ))) (assoc 1 AttDxf ) AttDxf ) )
    to :
    (setq AttDxf (subst (cons 1 (rtos (+ (atof (cdr (assoc 1 AttDxf ))) ToSum ) 2 3 )) (assoc 1 AttDxf ) AttDxf ) )

    ; ) Happy Computing !

    kennet

Page 1 of 2 12 LastLast

Similar Threads

  1. adding feilds to attributes
    By rstiles in forum AutoLISP
    Replies: 3
    Last Post: 2012-03-28, 01:33 PM
  2. Help adding attributes that are a field
    By dkochel in forum Dynamic Blocks - Technical
    Replies: 0
    Last Post: 2007-10-30, 08:20 PM
  3. Adding Attributes to Dynamic Blocks and getting them to display
    By james.126519 in forum Dynamic Blocks - Technical
    Replies: 10
    Last Post: 2007-09-19, 01:40 PM
  4. Adding Attributes
    By michael.viscetto65572 in forum AutoLISP
    Replies: 33
    Last Post: 2007-08-20, 11:10 AM
  5. Adding additional Attributes
    By sirdrumsalot in forum AutoCAD General
    Replies: 4
    Last Post: 2005-10-21, 07:18 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
  •