Looking for lisp that can draw line at co-ordinate values mentioned in selected text

Looking for lisp that can draw line at co-ordinate values mentioned in selected text

ash19854
Participant Participant
2,371 Views
13 Replies
Message 1 of 14

Looking for lisp that can draw line at co-ordinate values mentioned in selected text

ash19854
Participant
Participant

Thank you for help, I have a drawing file wherein many X, Y Co-ordinate value labels are there which I have to check if it is correct. Usually i use ID command and read the co-ordinate value and compare which takes more time. I am looking for lisp which can draw line / circle by selecting those XY Text values. so I can check easily and without errors. Thank you.

Example:

ash19854_0-1676901125989.png

In the above snapshot, The X,Y Co-ordinates mentioned E (Easting) xxx xxx, N (Nothing) X XXX XXX. If  I use ID Command to verify the mentioned co-ordinates are right or wrong, I have to read  number one by one and verify the co-ordinate value mentioned which is time taking and very difficult when i get drawings in bulk. I need a lisp which draws line automatically when i select the 2 text values together, or complete mtext. Lisp program shall automatically read the text and consider the number which follows E as "X Co-ordinate" & N as "Y Co-ordinate". 

0 Likes
Accepted solutions (2)
2,372 Views
13 Replies
Replies (13)
Message 2 of 14

ВeekeeCZ
Consultant
Consultant

Post a dwg of few samples.

0 Likes
Message 3 of 14

cadffm
Consultant
Consultant

If Text is placed at this x/y, select all text and start command: LIST

[F2]

 

Or DATAEXTRACTION

 

Sebastian

Message 4 of 14

Patchy
Mentor
Mentor

You extract value of a piece of text on X and Y and point to that coordinate?

I have never seen it can be done.

If they are attribute may be.

0 Likes
Message 5 of 14

ash19854
Participant
Participant

ash19854_1-1676900308822.png

See X co-ordinate here mentioned as E XXXXXX & Y as N XXXXX, I just wanted to verify the co-ordinates mentioned is right or wrong, If i use ID command I have to read all the characters and verify one by one which is tiring when i get the drawings in bulk. I need a lisp when i select those text together and the line automatically starts from that X,Y Co-ordinates. 

0 Likes
Message 6 of 14

Patchy
Mentor
Mentor

Put a point at all the coodinates you want to check then use dataextraction as mentioned.

Or post your drawing.

(What you're asking will have errors, if the coordinate from your text is a few tenth of a foot how do you know the line pointing to is at correct position?)

0 Likes
Message 7 of 14

ash19854
Participant
Participant

anyone can please help me with lisp for this ?

0 Likes
Message 8 of 14

cadffm
Consultant
Consultant

[Quote]post your drawing.[/Quote]

Sebastian

0 Likes
Message 9 of 14

komondormrex
Mentor
Mentor

hi, sort of?

 

;**********************************************************************************************************

(defun check_coordinates (/ text_1 text_1 point)

	;******************************************************************************************************

	(defun parse_texts (text_1 text_2)
		(if (= "E" (substr text_1 1 1))
			(setq x_coordinate (atof (vl-list->string (vl-remove 32 (vl-string->list (substr text_1 2))))))
			(if (= "N" (substr text_1 1 1))
				(setq y_coordinate (atof (vl-list->string (vl-remove 32 (vl-string->list (substr text_1 2))))))
			)
		)
		(if (= "E" (substr text_2 1 1))
			(setq x_coordinate (atof (vl-list->string (vl-remove 32 (vl-string->list (substr text_2 2))))))
			(if (= "N" (substr text_2 1 1))
				(setq y_coordinate (atof (vl-list->string (vl-remove 32 (vl-string->list (substr text_2 2))))))
			)
		)
		(list x_coordinate y_coordinate)
	)

	;******************************************************************************************************

	(setq text_1 (car (entsel "\nSelect 1st coordinate text"))
		  text_2 (car (entsel "\nSelect 2nd coordinate text"))
		  point (parse_texts text_1 text_2)
	)
	(command "_line" point pause "")
	(princ)
)

;**********************************************************************************************************

 

0 Likes
Message 10 of 14

Sea-Haven
Mentor
Mentor

You can get objects at that point using various SSGET methods, then compare points.

 

The main issue is with plines as you get vertices so need to check multiple points. 

 

It would be pretty easy to make a list of pointsfound  end, start, vertice then look at a list of these points do in 2 steps, 1st is it within tolerance say 0.1 then do a double check and compare with full decimal place you may get 0.xxx-xxxxxxxx as answer.

 

Post a dwg only way to work out something do once.

0 Likes
Message 11 of 14

ash19854
Participant
Participant

Drawing posted, since the drawing is in Meters, tolerance of +/- 20mm is allowed, Thank you for your help

0 Likes
Message 12 of 14

komondormrex
Mentor
Mentor
Accepted solution

the drawing posted is in inches.

komondormrex_0-1679553155672.png

 

 

 

;**********************************************************************************************************

(defun c:check_coordinates (/ mtext_point) ;text_1 text_1 point)

	;******************************************************************************************************

;	(defun parse_texts (text_1 text_2)
;		(if (= "E" (substr text_1 1 1))
;			(setq x_coordinate (atof (vl-list->string (vl-remove 32 (vl-string->list (substr text_1 2))))))
;			(if (= "N" (substr text_1 1 1))
;				(setq y_coordinate (atof (vl-list->string (vl-remove 32 (vl-string->list (substr text_1 2))))))
;			)
;		)
;		(if (= "E" (substr text_2 1 1))
;			(setq x_coordinate (atof (vl-list->string (vl-remove 32 (vl-string->list (substr text_2 2))))))
;			(if (= "N" (substr text_2 1 1))
;				(setq y_coordinate (atof (vl-list->string (vl-remove 32 (vl-string->list (substr text_2 2))))))
;			)
;		)
;		(list x_coordinate y_coordinate)
;	)

	;******************************************************************************************************

	(defun parse_mtext (mtext / mtext_string e_pos x_coordinate y_coordinate)
		(setq mtext_string (cdr (assoc 1 (entget mtext)))
			  e_pos (vl-string-search "E" mtext_string)
			  n_pos (vl-string-search "N" mtext_string)
			  x_coordinate (atof (vl-list->string (vl-remove 32 (vl-string->list (substr mtext_string (+ 2 e_pos) (- n_pos e_pos 1))))))
			  y_coordinate (atof (vl-list->string (vl-remove 32 (vl-string->list (substr mtext_string (+ 2 n_pos))))))
		) 
		(list x_coordinate y_coordinate)
	)

	;******************************************************************************************************

	(while t
		(setq ;text_1 (car (entsel "\nSelect 1st coordinate text: "))
			  ;text_2 (car (entsel "\nSelect 2nd coordinate text: "))
			  mtext (car (entsel "\nSelect 2nd coordinates mtext: ")) 
;			  leader (car (entsel "\nSelect pointing to point leader: "))
			  actual_point (osnap (getpoint "\nPick poit closer to target vertex:") "_endp")
;			  leader_org_point (cdr (assoc 10 (entget leader))) 
	;		  text_point (parse_texts text_1 text_2)
			  mtext_point (parse_mtext mtext)
		)
		(alert (strcat "Deviation from written coordinates is " (vl-princ-to-string (distance actual_point mtext_point)) " units")) 
	;	(command "_line" "_non" point pause "")
	)
	(princ)
)

;**********************************************************************************************************

 

0 Likes
Message 13 of 14

ash19854
Participant
Participant

@komondormrex, That worked somehow in that drawing which was having mtext with Mleader. If the mtext is independent of the leader line attached to it then it shows error(Please see attached drawing).. Thank you

 

0 Likes
Message 14 of 14

komondormrex
Mentor
Mentor
Accepted solution

check update above.