View Full Version : Adding or subtracting from attributes
b_v_mc
2005-01-06, 05:01 PM
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
jrd.chapman
2005-01-06, 09:32 PM
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.
b_v_mc
2005-01-06, 09:42 PM
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.
jrd.chapman
2005-01-06, 10:16 PM
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.
kennet.sjoberg
2005-01-07, 12:59 AM
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".
(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
b_v_mc
2005-01-07, 04:26 PM
Hey Thanks for the reply guys ill try these when i have some free time.
mcook.118907
2009-05-22, 08:39 PM
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?
jhaagen
2009-10-12, 11:16 PM
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.
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.