exporting the coordinates of the autocad parcel to autocad excel

exporting the coordinates of the autocad parcel to autocad excel

mirqalib.m
Enthusiast Enthusiast
3,126 Views
30 Replies
Message 1 of 31

exporting the coordinates of the autocad parcel to autocad excel

mirqalib.m
Enthusiast
Enthusiast

Hello. I drew the parcel in Autocad and copy the coordinates in the list command, for example
at point X=670828.0000 Y=4433484.0000 Z= 0.0000
at point X=670915.0000 Y=4433441.0000 Z= 0.0000
at point X=670879.0000 Y=4433356.0000 Z= 0.0000
With the help of a macro in excel, I get the coordinates, point numbers and intermediate distances in the excel file. Then I add my header to this excel and paste it in autocada (next to my parcel).
Is there a lisp that I can do this action in autocad excel without the help of excel and macro. Thank you in advance.

0 Likes
Accepted solutions (1)
3,127 Views
30 Replies
Replies (30)
Message 2 of 31

pendean
Community Legend
Community Legend
Civil3D variant of AutoCAD does that if this is what you need https://www.youtube.com/watch?v=FJI_c19cmNE
0 Likes
Message 3 of 31

mirqalib.m
Enthusiast
Enthusiast

Hello, I am using Autocad.

0 Likes
Message 4 of 31

komondormrex
Mentor
Mentor

hi,

is it a continuation of your previous message?

0 Likes
Message 5 of 31

mirqalib.m
Enthusiast
Enthusiast

Hello. There is a similarity. But I need the coordinates that I copied in autocad to come to autocad's excel table as I have shown in the photo. (lisp). Let it be included in the title of the toto I uploaded. It is a Lesser latin text. Thank you in advance.

 
 

 

 

0 Likes
Message 6 of 31

Sea-Haven
Mentor
Mentor

Yes is the answer Autocad can talk direct to Excel putting say co-ordinate values into Excel cell's.

 

Start with getexcel.lsp.

 

I can do something for you but a small fee.

 

 

0 Likes
Message 7 of 31

komondormrex
Mentor
Mentor

so you want to pick a pline and put an autocad  table with that pline data nearby?

0 Likes
Message 8 of 31

mirqalib.m
Enthusiast
Enthusiast

Yes. First I copy the coordinates of my autocad line. Then I open the excel file (macro). When I paste, the table is created. I add a title to this table and paste it in autocad after copying it. This takes a very long time.

0 Likes
Message 9 of 31

mirqalib.m
Enthusiast
Enthusiast

Hello. I am uploading the Excel (macro) file for you to look at. After copying the coordinates from Autocad, you paste Ctrl+Q into cell A1 of excel.

0 Likes
Message 10 of 31

Sea-Haven
Mentor
Mentor

You need to decide what method is going to work for this task, if you paste to Excel then can read the values from there and make the plines. If you have say multiple then leave a 1 line row gap. Then just read the Excel file direct and make the plines. No double handling. Given the number of posts involved and time involved a cheap payment and you would have it now.

 

Are there multiple plines involved if so post an Excel file with them in it. As I asked earlier where is the data coming from why not post the source file. Can do both make plines and fill in Excel.

0 Likes
Message 11 of 31

komondormrex
Mentor
Mentor

hi,

check the following. adds to dwg an autocad table based on picked pline data. table style used is default, text size for table data is set in the code, table size is calculated from text size. if you need to change fonts change 'em in table style. 

hope that helps.

 

 

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

;	komondormrex, jul 2023

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

(defun c:add_pline_data_table (/ entsel_data target_pline target_pline_is_open table_text_size index target_pline_data table_object row_index column_index)
	(while (and
				(if (vl-catch-all-error-p (setq entsel_data (vl-catch-all-apply 'entsel (list "\nPick land plot polyline: ")))) nil t)
				(if entsel_data (setq target_pline (car entsel_data)) t)
		    	(if target_pline
						(/= "LWPOLYLINE" (cdr (assoc 0 (entget target_pline))))
						t
				)
	       )
	)
	(if target_pline
		(progn
			(setq target_pline_is_open (zerop (getpropertyvalue target_pline "closed"))
				  table_text_size 3.5
				  index 0
				  target_pline_data (mapcar '(lambda (vertex_1 vertex_2) (list (setq index (1+ index))
				  															 (car vertex_1)
																			 (cadr vertex_1)
																			 (strcat (itoa index)
																			 		 " - "
																			 		 (cond
																							(
																								target_pline_is_open
																			 				  		(itoa (1+ index))
																							)
																							(
																								t
																									(if (/= index (vlax-curve-getendparam target_pline))
																										(itoa (1+ index))
																										"1"
																									)
																						 	)
																					 )
																			 )
																			 (distance vertex_1 vertex_2)
																	   )
											 )
				  							 (setq target_vertices (mapcar 'cdr (vl-remove-if-not '(lambda (group) (= 10 (car group))) (entget target_pline))))
											 (if target_pline_is_open
													(cdr target_vertices)
													(append (cdr target_vertices) (list (car target_vertices)))
											 )
									)
				 table_object (vla-addtable (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
										    (vlax-3d-point (getpoint "\nSet table insertion point (Left Upper Corner): "))
										    (+ 2 (length target_pline_data))
										    5
										    (* 2.6 table_text_size)
										    (* 6 table_text_size)
							  )
				 target_pline_data (cons "Vertices coordinates\nof the land plot shown in the project"
				 				   (cons (list "Ordely\nvertex\nnumber" "X" "Y" "End\nvertices" "Length")
								   		 target_pline_data)
								   )
				 row_index -1
			)
			(mapcar '(lambda (list_member)
						(vl-catch-all-apply 'vla-setcolumnwidth list_member)
					 )
					 (mapcar '(lambda (list_member)
									(cons table_object list_member)
							  )
							  (list
							    	(list 0 (* 10 table_text_size))	;width of column 0 thru 4
									(list 1 (* 10 table_text_size))
									(list 2 (* 10 table_text_size))
									(list 3 (* 8 table_text_size))
							    	(list 4 (* 10 table_text_size))
							   )
					)
			)
			(foreach row target_pline_data
				(if (listp row)
					(progn
						(setq column_index -1
							  row_index (1+ row_index)
						)
						(foreach column row
							(vla-settext table_object row_index (setq column_index (1+ column_index)) (nth column_index row))
							(vla-setcellalignment table_object row_index column_index acmiddlecenter)
							(vla-setcelltextheight table_object row_index column_index table_text_size)
							(if (and (< 1 row_index)
									 (member column_index '(1 2 4))
								)
									(vla-setcelldatatype table_object row_index column_index acdouble acunitdistance)
							)
							(if (= 1 row_index) (vla-setrowheight table_object row_index (* 6 table_text_size)))
						)
					)
					(progn
						(vla-settext table_object (setq row_index 0) 0 row)
						(vla-setcellalignment table_object row_index 0 acmiddlecenter)
						(vla-setcelltextheight table_object row_index 0 (* 1.5 table_text_size))
						(vla-setrowheight table_object row_index (* 5 (* 1.5 table_text_size)))
					)
				)
			)
		)
	)
	(princ)
)

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

 

0 Likes
Message 12 of 31

mirqalib.m
Enthusiast
Enthusiast

It is very successful. But when I change the titles in lisp, there is a problem. I use Latin language. Another problem is that the distance is too many numbers after the dot. It is enough if there is a number after the dot. For example, let the number be 62.2 instead of 62.2153. And let the number be rounded. For example, let the number be 62.3 instead of 62.25. I'm uploading a visual of the problems. Is it possible to automatically put the number of the loop points (1,2,3..n) on the line?

0 Likes
Message 13 of 31

komondormrex
Mentor
Mentor
Accepted solution

it is unicode. to display it correctly use unicode typeface. to set precision in cells invoke units command and set it to desirable value.

 

 

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

;	komondormrex, jul 2023

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

(defun c:add_pline_data_table (/ entsel_data target_pline target_pline_is_open table_text_size index target_pline_data table_object row_index column_index
								 precision_per_column string_number precision
							  )
	(while (and
				(if (vl-catch-all-error-p (setq entsel_data (vl-catch-all-apply 'entsel (list "\nPick land plot polyline: ")))) (setq target_pline nil) t)
				(if entsel_data (setq target_pline (car entsel_data)) t)
		    	(if target_pline (/= "LWPOLYLINE" (cdr (assoc 0 (entget target_pline)))) t)
	       )
	)
	(if target_pline
		(progn
			(setq target_pline_is_open (zerop (getpropertyvalue target_pline "closed"))
				  table_text_size 3.5
				  index 0
				  precision_per_column '(nil 2 2 nil 1)
				  target_pline_data (mapcar '(lambda (vertex_1 vertex_2) (list (setq index (1+ index))
				  															 (car vertex_1)
																			 (cadr vertex_1)
																			 (strcat (itoa index)
																			 		 " - "
																			 		 (cond
																							(
																								target_pline_is_open
																			 				  		(itoa (1+ index))
																							)
																							(
																								t
																									(if (/= index (vlax-curve-getendparam target_pline))
																										(itoa (1+ index))
																										"1"
																									)
																						 	)
																					 )
																			 )
																			 (distance vertex_1 vertex_2)
;																			 (- (vlax-curve-getdistatpoint target_pline vertex_2)
;																			    (vlax-curve-getdistatpoint target_pline vertex_1)
;																			 )
																	   )
											 )
				  							 (setq target_vertices (mapcar 'cdr (vl-remove-if-not '(lambda (group) (= 10 (car group))) (entget target_pline))))
											 (if target_pline_is_open
													(cdr target_vertices)
													(append (cdr target_vertices) (list (car target_vertices)))
											 )
									)
				 table_object (vla-addtable (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
;										    (vlax-3d-point (getpoint "\nSet table insertion point (Left Upper Corner): "))
										    (vlax-3d-point (getvar 'viewctr))
										    (+ 2 (length target_pline_data))
										    5
										    (* 2.6 table_text_size)
										    (* 6 table_text_size)
							  )
				 target_pline_data (cons "Layih\U+04D9d\U+04D9 g\U+00F6st\U+04D9ril\U+04D9n torpaq sah\U+04D9sinin d\U+00F6ng\U+04D9\nn\U+00F6qt\U+04D9l\U+04D9rinin koordinatlar\U+0131"
				 				   (cons (list "D\U+00F6ng\U+04D9\nn\U+00F6qt\U+04D9l\U+04D9rinin\nn\U+00F6mr\U+04D9si" "X" "Y" "D\U+00F6ng\U+04D9\nn\U+00F6qt\U+04D9l\U+04D9ri" "M\U+04D9saf\U+04D9\n(m)")
								   		 target_pline_data)
								   )
				 row_index -1
			)
			(mapcar '(lambda (list_member)
						(vl-catch-all-apply 'vla-setcolumnwidth list_member)
					 )
					 (mapcar '(lambda (list_member)
									(cons table_object list_member)
							  )
							  (list
							    	(list 0 (* 10 table_text_size))	;	width of column 0 thru 4
									(list 1 (* 10 table_text_size))
									(list 2 (* 10 table_text_size))
									(list 3 (* 8 table_text_size))
							    	(list 4 (* 8 table_text_size))
							   )
					)
			)
			(foreach row target_pline_data
				(if (listp row)
					(progn
						(setq column_index -1
							  row_index (1+ row_index)
						)
						(foreach column row
							(vla-settext table_object
										 row_index
										 (setq column_index (1+ column_index))
										 (if (and (< 1 row_index)
												  (member column_index '(1 2 4))
											 )
												(progn
													(setq precision (nth column_index precision_per_column))
													(if (vl-string-position (ascii ".") (setq string_number (rtos (/ (atof (rtos (* (nth column_index row) (* 10 precision))
																														   		 2
																														         precision
																															)
																													 )
																													 (* 10 precision)
																												  )
																												  2
																												  precision
																											)
														 								)
														)
														string_number
														(strcat string_number ".0")
													)
												)
												(nth column_index row)
										 )
							)
							(vla-setcellalignment table_object row_index column_index acmiddlecenter)
							(vla-setcelltextheight table_object row_index column_index table_text_size)
						)
						(cond
							(
								(= 1 row_index)
									(vla-setrowheight table_object row_index (* 6 table_text_size))
							)
							(
								t
									(vla-setrowheight table_object row_index (* 2.6 table_text_size))
							)
						)
					)
					(progn
						(vla-settext table_object (setq row_index 0) 0 row)
						(vla-setcellalignment table_object row_index 0 acmiddlecenter)
						(vla-setcelltextheight table_object row_index 0 (* 1.5 table_text_size))
						(vla-setrowheight table_object row_index (* 5 (* 1.5 table_text_size)))
					)
				)
			)
			(terpri)
			(setvar 'cmdecho 0)
			(command "_cutclip" (vlax-vla-object->ename table_object) "")
			(command "_pasteclip")
			(setvar 'cmdecho 1)
		)
	)
	(princ)
)

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

 

 

 

 

 

 

 

 

 

 

0 Likes
Message 14 of 31

Sea-Haven
Mentor
Mentor

Do a google for Table to Excel I wrote one and posted here.

0 Likes
Message 15 of 31

mirqalib.m
Enthusiast
Enthusiast

font worked. When changing unit command, it also changes coordinates.tabel falls too long.

0 Likes
Message 16 of 31

mirqalib.m
Enthusiast
Enthusiast

Is it possible to make the unit (0.0) only work for the fifth column?

0 Likes
Message 17 of 31

komondormrex
Mentor
Mentor

i already added setting each row height when drawing a table, is it still draw too high rows?

0 Likes
Message 18 of 31

komondormrex
Mentor
Mentor

@mirqalib.m wrote:

Is it possible to make the unit (0.0) only work for the fifth column?


i'll see

0 Likes
Message 19 of 31

komondormrex
Mentor
Mentor

check update in message 13.

precision sets per column at line 21 - precision_per_column '(nil 2 2 nil 1)

0 Likes
Message 20 of 31

mirqalib.m
Enthusiast
Enthusiast

Now it doesn't write zeros after dots in single digits. like 5.5 is it possible to have 5.0?

0 Likes