Requested, a lisp for numbering intersection point of polylines.

Requested, a lisp for numbering intersection point of polylines.

paliwal222
Advocate Advocate
710 Views
5 Replies
Message 1 of 6

Requested, a lisp for numbering intersection point of polylines.

paliwal222
Advocate
Advocate

With respect to all.

Requested, a lisp for increasing numbering, at intersection point of polylines. No need of any continuity, just randomly.

I have to use three no of lisp to mark at intersection point.

(mark intersection by lisp, insert block on all them by another lisp, and numbering them by another lisp.)

But i want to make it more easy.

Please, give me if some idea to make it easy.

I have attach all three lisp I use.

Thanks.

 

0 Likes
Accepted solutions (2)
711 Views
5 Replies
Replies (5)
Message 2 of 6

hak_vz
Advisor
Advisor
Accepted solution

@paliwal222 

 

Here is your lisp. I hoped that you'll try to write down some code. Option with command TCOUNT is in my opinion more versatile.

 

 

(defun c:textAtPolylinesIntersection ( / take pointlist3d get_intersections textheight ss i in int_pts lst eo fo) 
	(defun take (amount lst / ret)(repeat amount (setq ret (cons (car lst) (take (1- amount) (cdr lst))))))
	(defun pointlist3d (lst / ret) (while lst (setq	ret (cons (take 3 lst) ret) lst (cdddr lst))) (reverse ret))
	(defun get_intersections	(obj1 obj2 / var)
		(setq var (vlax-variant-value (vla-intersectwith obj1 obj2 acExtendNone)))
		(if (< 0 (vlax-safearray-get-u-bound var 1))(vlax-safearray->list var))
	)
	(setq textheight (getreal "\nText height > "))
	(setq ss (ssget '((0 . "LWPOLYLINE"))) i -1 int_pts nil lst nil)
	(while (< (setq i (1+ i)) (sslength ss))(setq lst (cons (vlax-ename->vla-object (ssname ss i)) lst)))
	(while (and lst (> (length lst) 1))
		(setq eo (car lst) lst (cdr lst))
		(foreach fo lst
			(setq in (get_intersections eo fo))
			(if(and in) (setq int_pts (cons (pointlist3d in) int_pts)))
		)
	)
	(setq int_pts (vl-sort (apply 'append int_pts) '(lambda (x y)(< (car x)(car y)))))
	(setq i -1)
	(while (< (setq i (1+ i)) (length int_pts))
		(entmake
			(list
				(cons 0 "TEXT")
				(cons 100 "AcDbText")
				(cons 10 (nth i int_pts))
				(cons 40 textheight)
				(cons 1 (itoa (1+ i)))
				(cons 50 0)
			)
		)
	)
	(princ)
)

 

 

Here is how to use command TCOUNT that I proposed in Autocad forum. It gives you option to select desired direction, prefix,suffix.... After using lisp you steel have to realign text entities away so they don't intersect with polylines and other entities in your drawing.

Untitled.png

 

 

Command: TCOUNT
Initializing...
Select objects: Specify opposite corner: 11 found
Select objects:
Sort selected objects by [X/Y/Select-order] <Select-order>: x
Specify starting number and increment (Start,increment) <1,1>:
Placement of numbers in text [Overwrite/Prefix/Suffix/Find&replace..] <Prefix>: o

 

 

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.
Message 3 of 6

paliwal222
Advocate
Advocate
Accepted solution

Dear,

Sir Miljenko Hatlak

Thanks very much for all this.

its completely solve my task.  "textAtPolylinesIntersection" lisp work completely very well.

TCOUNT is very good and I will see all option of TCOUNT.

what i have to say,

again thanks very much.

 

 

Message 4 of 6

Sea-Haven
Mentor
Mentor

I had a think about this and use a different method the numbers end up in sequence, works on test dwg so give it a try.

 

(defun convxyz (co-ords / )
(setq I 0)
(repeat (/ (length co-ords) 3)
(setq xyz (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))
(setq intptxyz (cons xyz intptxyz))
(setq I (+ I 3))
)
(princ)
)


(defun dotext (int_pts / tpt )
(foreach tpt int_pts
(entmakex
			(list
				(cons 0 "TEXT")
				(cons 100 "AcDbText")
				(cons 10 tpt)
				(cons 40 textheight)
				(cons 1 (rtos x 2 0))
				(cons 50 0)
			)
		)
(setq X (1+ x))
)
(princ)
)


(defun c:intpts ( / ss intptxyz x i obj1 obj2 intpt e1 e2)
(setq textheight (getreal "\nText height > "))
(setq x (getint "Enter last number 0 for 1st number "))
(setq ss (ssget '((0 . "LWPOLYLINE"))))
(setq intpt nil)
(setq i (sslength ss))
(while (or (/= ss nil)(> (sslength ss) 1))
(setq obj1 (vlax-ename->vla-object (ssname ss (- i 1))))
(while(= intpt nil)
(setq i (- i 1))
(setq obj2 (vlax-ename->vla-object (ssname ss (- i 1))))
(setq intpt (vlax-invoke obj2 'intersectWith obj1 acExtendnone))
)
(setq intptxyz '())
(convxyz intpt)
(setq X (1+ x))
(dotext intptxyz)
(setq e1 (vlax-vla-object->ename obj1) e2 (vlax-vla-object->ename obj2))
(setq ss (ssdel e1 ss))
(setq ss (ssdel e2 ss))
(if (= (sslength ss) nil)
(princ)
(setq i (sslength ss))
)
(setq intpt nil)
)
(princ)
)

(c:intpts )

 

0 Likes
Message 5 of 6

paliwal222
Advocate
Advocate

Dear,

Sir,

please tell me how can I apply this.

some time its show odd number only and some time its show even number.

and its doesn't work on all intersection, its left many intersection unnumbered, on every time I apply when.

 

Thanks for all this.

0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor
Post a test dwg so I can see what is going on, its hard sometimes when there is no sample dwg, works great on my tests.