LISP to quickly label tributary/disturbed area with desired formatting

LISP to quickly label tributary/disturbed area with desired formatting

Nathan_Tigner
Advocate Advocate
556 Views
3 Replies
Message 1 of 4

LISP to quickly label tributary/disturbed area with desired formatting

Nathan_Tigner
Advocate
Advocate

Hello All,

 

I am trying to get a lisp to help easily label closed polylines areas in acres with correct formatting to save valuable time when executing 100's of labels per project.

 

The general lisp would run something like this:

1. Ask user for drainage area number (DA-1 in the posted image)
2. Ask user for TOC (10 in the posted image)
3. Ask user for CN (75 in the posted image)
4. Prompt for user to select polyline for tributary area
5. Prompt for user to select polyline for Disturbed area (could be the same polyline as tributary, could be different)
6. Ask the user for a point to place the text formatted like the image posted, using the current layer and text style (would also preferably like text to be annotative.)

 

nathantignerT6ZWV_0-1646766352966.png

 

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

hak_vz
Advisor
Advisor
Accepted solution

@Nathan_Tigner 

We had your similar sample here. Here is quick modification.

Areas of polylines is convert acres, check for accuracy.

Modify final string according to your need. For MTEXT formatting you may check this page. It is not so complicated.

(defun c:ltrib (/ *error* pickpoly name toc cn tra dis pt str)
	(vl-load-com)
	(defun *error* ( msg )
		(if (not (member msg '("Function cancelled" "quit / exit abort")))
			(princ (strcat "\nError: " msg))
		)
		(princ)
	)
	(defun pick_poly (msg)
		(setq e (car(entsel msg)))
		(if (and (not e) (= (getvar 'Errno) 7)) (pick_poly msg) e)
	)
	(while
		(setq
			name (strcase(getstring "\nDrainage area number >"))
			toc (getstring "\nTOC >")
			cn (getstring "\nCN >")
			tra (rtos (/(vlax-get (vlax-ename->vla-object(pick_poly "\nSelect polyline for Tributary area >")) 'Area) 43560.0) 2 2)
			dis (rtos (/(vlax-get (vlax-ename->vla-object(pick_poly "\n select polyline for Disturbed area >")) 'Area) 43560.0) 2 2)
			pt (getpoint "\nSelect insertion point")
			str 
				(strcat 
					"\\L" name "\\l"
					"\\P" "TRIBUTARY AREA = " tra " AC"
					"\\P" "DISTURBED AREA = " dis " AC"
					"\\P" "TOC = " TOC " MN"
					"\\P" "CN = " cn
				)
		)
		(cond 
			((and pt)
				(entmakex
					(list
						(cons 0 "MTEXT")	
						(cons 100 "AcDbEntity")
						(cons 100 "AcDbMText")
						(cons 1 str)
						(cons 10 pt)
						(cons 40 (getvar 'textsize))
						(cons 41 0.0)
						(cons 50 0.0)
						(cons 71 5)
						(cons 72 1)
					)
				)
				)
		)
	)
	(princ)
)

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 4

Nathan_Tigner
Advocate
Advocate
I can modify this to work perfectly. Thanks so much. A huge help!
Message 4 of 4

Sea-Haven
Mentor
Mentor

Are you trying to do drainage calcs ? TOC Time of concentration, I use Civil Site Design and it has this type of function built into the drainage module. Working out TOC as it progresses through the pipe network.

0 Likes