Copy text to attribute while subtracting a value

Copy text to attribute while subtracting a value

akark
Participant Participant
928 Views
3 Replies
Message 1 of 4

Copy text to attribute while subtracting a value

akark
Participant
Participant

Hello,

 

Basically what I've been looking for and failed to find is this; I have tons of raw site elevation data in a drawing and I want to enter the datum into attribute blocks. While doing that I want to subtract my building's raw 0.00 value to find the relative elevation on a specific point with relation to my building. I have found numerous lisp routines to copy text into attributes but found none that adds/subtracts value while copying. 

 

 

0 Likes
Accepted solutions (1)
929 Views
3 Replies
Replies (3)
Message 2 of 4

pbejse
Mentor
Mentor

@akark wrote:

Hello,

 

Basically what I've been looking for and failed to find is this; I have tons of raw site elevation data in a drawing and I want to enter the datum into attribute blocks. 


 

What or where in the drawing is the source for the raw site elevation? 

The left side of the image does not have the 929 | 67 raw elevation data, is it part of the block?

 

 

0 Likes
Message 3 of 4

dbhunia
Advisor
Advisor
Accepted solution

 

Hi,

 

What I got from your description & attached Image -

 

1   You should enter the datum value (say 929.00) into attribute blocks (that will be fixed value for the building).

2   At the time of Inserting Block you should select raw site elevation data (say 929.67) & pick Block Insertion Point.

3   After that Block will placed with the relative elevation of raw site elevation with relation to datum value.

 

If I an right then try the attached code.....

 

Only one thing you have to consider that, when you enter the datum value into attribute blocks that always keep integer/ float value (say 929 or 929.67), do not place any special character there (say + - ( )..etc.). otherwise code can not calculate the relative value.

It will give you your desired result (say 929.67(+0.67) or 929.67(+29.67) or 500.75(-399.25) etc.)

 

 

(defun c:CAT()
(setq Blk (getstring "\nEnter Block Name: "))
(while (setq entt (car (entsel "\nSelect Raw Elevation:")))
(setq enttx (entget entt))
(setq txt (cdr (assoc 1 enttx)))
(setq Ins (getpoint "\nPick/Enter Insertion Point: "))
(command "_.insert" blk ins "" "" "")
(setq elst1 (setq elst1 (entget (entnext (entlast)))))
(setq ff1 (assoc 1 elst1))
(setq Dat_Val (atof (cdr ff1)))
(if (> (- (atof txt) Dat_Val) 0)
(setq Att_text (strcat txt "(+" (rtos (- (atof txt) Dat_Val) 2 2) ")"))
(setq Att_text (strcat txt "(" (rtos (- (atof txt) Dat_Val) 2 2) ")"))
)
(setq xx (cons 1 Att_text))
(entmod (subst xx ff1 elst1))
(command "regen")
)
)


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 4 of 4

akark
Participant
Participant

Works like a charm, thanks a lot. 

 

Note for others using the code; the fixed elevation value is entered in the "default" line in attribute definition. 

0 Likes