<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Lisp to export polyline area and length from Autocad to excel in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12734906#M14820</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Re order&lt;/STRONG&gt; look at this&amp;nbsp;("HANDLE" "ROOM_NAME" "ROOM_FLOOR" "ROOM_PERIMETER" "ROOM_AREA") I have not tested but changing the order should change export to excel. Occurs twice in code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This calls excel and should be done out side of the Room_data_out and rename defun to not have the C :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:roomout ( / )
(setq xls (vlax-get-or-create-object "Excel.Application"))
(defun room_data_out ( / 
...............
)
(room_data_out)
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So need a short defun at start that calls the new room out. The defun itself has a "ADD" a sheet so it should work whilst you have Excel open. &lt;STRONG&gt;NOT TESTED&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Changing dwg's or closing and reopen same with Excel will not work needs all together lots more if's and but's.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do this task in a different way not using Ldata.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Apr 2024 02:47:38 GMT</pubDate>
    <dc:creator>Sea-Haven</dc:creator>
    <dc:date>2024-04-26T02:47:38Z</dc:date>
    <item>
      <title>Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12732355#M14818</link>
      <description>&lt;P&gt;With the help of friends in this Forum, i have got lisp to get area and length from Autocad drawings and export to excel in xlsx. format. But i still need some modifications in the lisp to suit my needs. So i would like to request if anybody can help with the following concerns-&lt;/P&gt;&lt;P&gt;1) Once a polyline is selected, its color should change, so as to avoid duplication.&lt;/P&gt;&lt;P&gt;2) In the excel sheet, Room area should be displayed before the Room perimeter.&lt;/P&gt;&lt;P&gt;3) Once the selection of polylines is done and exported to excel sheet using Room_Data_Out.lsp, and then when i make another new selection of polylines in the same drawing, the results are exported to a new excel file. So each time a new excel file is created. I would like to have all the areas and perimeters for the same drawing in &lt;STRONG&gt;ONE&lt;/STRONG&gt; excel file.&lt;/P&gt;&lt;P&gt;Lisps can be found in attachment for your kind review and modification.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2024 06:15:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12732355#M14818</guid>
      <dc:creator>sajid727</dc:creator>
      <dc:date>2024-09-08T06:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12733450#M14819</link>
      <description>&lt;P&gt;I only have a solution for your first question. Here is a line I've used in my lisps for a similar purpose.&amp;nbsp; You can delete lt and the following input if you don't want to change the linetype scale.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;(command "chprop" ent "" "c" "INPUTDESIREDCOLOR" "lt" "ByLayer" "La" "DESIREDLAYER" "")&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 14:29:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12733450#M14819</guid>
      <dc:creator>guzman748</dc:creator>
      <dc:date>2024-04-25T14:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12734906#M14820</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Re order&lt;/STRONG&gt; look at this&amp;nbsp;("HANDLE" "ROOM_NAME" "ROOM_FLOOR" "ROOM_PERIMETER" "ROOM_AREA") I have not tested but changing the order should change export to excel. Occurs twice in code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This calls excel and should be done out side of the Room_data_out and rename defun to not have the C :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:roomout ( / )
(setq xls (vlax-get-or-create-object "Excel.Application"))
(defun room_data_out ( / 
...............
)
(room_data_out)
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So need a short defun at start that calls the new room out. The defun itself has a "ADD" a sheet so it should work whilst you have Excel open. &lt;STRONG&gt;NOT TESTED&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Changing dwg's or closing and reopen same with Excel will not work needs all together lots more if's and but's.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do this task in a different way not using Ldata.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 02:47:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12734906#M14820</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2024-04-26T02:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12737762#M14821</link>
      <description>&lt;P&gt;Thanks guzman748 for your reply. I am new to lisp. Could you please make changes in the lisps I had attached in my my original post and repost it.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2024 07:57:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12737762#M14821</guid>
      <dc:creator>sajid727</dc:creator>
      <dc:date>2024-04-27T07:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12737767#M14822</link>
      <description>&lt;P&gt;Thanks Sea-Heaven for yours reply.&amp;nbsp; I am new to lisp. Could you please modify lisp I posted and repost it.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2024 08:01:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12737767#M14822</guid>
      <dc:creator>sajid727</dc:creator>
      <dc:date>2024-04-27T08:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12737922#M14823</link>
      <description>&lt;P&gt;This is not tested as need a real dwg. But give it a try.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun ROOM_DATA_OUT (file_output / sel file_output doc xls wks column count nb ename k_list)
	(setq
		sel (ssget "_X" '((0 . "*POLYLINE") (8 . "AREA_ROOM") (-4 . "&amp;lt;NOT") (-4 . "&amp;amp;") (70 . 120) (-4 . "NOT&amp;gt;")))
	)

	(cond
		((and sel file_output)
			(setq doc (vla-get-activedocument (vlax-get-acad-object)))
			(vla-startundomark doc)
			
			(vlax-invoke (vlax-get xls 'workbooks) 'Add)
			(vlax-put xls 'Visible :vlax-true)
			(setq
				wks (vlax-get xls 'ActiveSheet)
				column 65
				count 1
			)
			(vlax-put (vlax-get-property wks 'range (strcat "A1:E" (itoa (sslength sel)))) 'Cells "")
			(foreach el '("HANDLE" "ROOM_NAME" "ROOM_FLOOR" "ROOM_PERIMETER" "ROOM_AREA")
				(vlax-put (vlax-get-property wks 'range (strcat (chr column) (itoa count))) 'value el)
				(setq column (1+ column))
			)
			(repeat (setq nb (sslength sel))
				(setq
					ename (ssname sel (setq nb (1- nb)))
					k_list (list (cons "HANDLE" (strcat "'" (cdr (assoc 5 (entget ename))))))
				)
				(foreach el '("ROOM_NAME" "ROOM_FLOOR" "ROOM_PERIMETER" "ROOM_AREA")
					(setq k_list (cons (cons el (vlax-ldata-get ename el)) k_list))
				)
				(setq
					count (1+ count)
					column 65
				)
				(foreach el (reverse (mapcar 'cdr k_list))
					(vlax-put (vlax-get-property wks 'range (strcat (chr column) (itoa count))) 'value el)
					(setq
						column (1+ column)
					)
				)
				(setq k_list nil)
			)
			(mapcar 'vlax-release-object (list wks xls))
			(gc)
			(vla-endundomark doc)
		)
	)
	(prin1)
)

(defun c:roomout ( / xls)
(setq xls (vlax-get-or-create-object "Excel.Application"))
(setq fname (strcat (getvar "DWGPREFIX") (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4)) ".xlsm")

(ROOM_DATA_OUT fname)
(if (not (vlax-object-released-p XLS))(progn(vlax-release-object XLS)(setq XLS nil)))
(princ)
)

&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 27 Apr 2024 11:26:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12737922#M14823</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2024-04-27T11:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12737950#M14824</link>
      <description>&lt;P&gt;try&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;(vl-load-com)
(defun c:ROOM_DATA ( / AcDoc Space old_lay pt sel ent vla_obj)
	(setq
		AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
		Space
		(if (= 1 (getvar "CVPORT"))
			(vla-get-PaperSpace AcDoc)
			(vla-get-ModelSpace AcDoc)
		)
	)
	(cond
		((null (tblsearch "LAYER" "AREA_ROOM"))
			(vlax-put (vla-add (vla-get-layers AcDoc) "AREA_ROOM") 'color 3)
		)
	)
	(setq old_lay (getvar "CLAYER"))
	(setvar "CLAYER" "AREA_ROOM")
	(setq pt (getpoint "\nFirst point of polyline or enter for select one: "))
	(if pt
		(command "_.pline" pt
			(while (not (zerop (getvar "cmdactive")))
				(command pause)
			)
		)
		(while (not (setq sel (ssget "_+.:E:S" '((0 . "*POLYLINE") (-4 . "&amp;lt;NOT") (-4 . "&amp;amp;") (70 . 120) (-4 . "NOT&amp;gt;"))))))
	)
	(cond
		(sel
			(setq
				ent (ssname sel 0)
				vla_obj (vlax-ename-&amp;gt;vla-object ent)
			)
			(vlax-put-property vla_obj "Layer" "AREA_ROOM")
		)
		(T
		 (setq ent (entlast) vla_obj (vlax-ename-&amp;gt;vla-object ent))
		 (vlax-put-property vla_obj "color" 1)
		 )
	)
	(vlax-ldata-put vla_obj "ROOM_NAME" (getstring T "\nName of room : "))
	(vlax-ldata-put vla_obj "ROOM_AREA" (vlax-get-property vla_obj "Area"))
	(vlax-ldata-put vla_obj "ROOM_PERIMETER" (vlax-get-property vla_obj "Length"))
	(vlax-ldata-put vla_obj "ROOM_FLOOR" (getstring T "\nFloor of room : "))
	(setvar "CLAYER" old_lay)
	(princ "\nPolyline have this data:")
	(print (vlax-ldata-list vla_obj))
	(prin1)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="c1.JPG" style="width: 949px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1355602i794AD7E84638BEB9/image-size/large?v=v2&amp;amp;px=999" role="button" title="c1.JPG" alt="c1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2024 11:55:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12737950#M14824</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2024-04-27T11:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12737953#M14825</link>
      <description>&lt;P&gt;try&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;(defun c:ROOM_DATA_OUT ( / sel file_output doc xls wks column count nb ename k_list)
	(setq
		sel (ssget "_X" '((0 . "*POLYLINE") (8 . "AREA_ROOM") (-4 . "&amp;lt;NOT") (-4 . "&amp;amp;") (70 . 120) (-4 . "NOT&amp;gt;")))
		file_output (strcat (getvar "DWGPREFIX") (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4))(rtos (getvar "CDATE") 2 6) ".xlsm")
		)
	(cond
		((and sel file_output)
			(setq doc (vla-get-activedocument (vlax-get-acad-object)))
			(vla-startundomark doc)
			(setq xls (vlax-get-or-create-object "Excel.Application"))
			(vlax-invoke (vlax-get xls 'workbooks) 'Add)
			(vlax-put xls 'Visible :vlax-true)
			(setq
				wks (vlax-get xls 'ActiveSheet)
				column 65
				count 1
			)
			(vlax-put (vlax-get-property wks 'range (strcat "A1:E" (itoa (sslength sel)))) 'Cells "")
			(foreach el '("HANDLE" "ROOM_NAME" "ROOM_FLOOR" "ROOM_AREA" "ROOM_PERIMETER" )
				(vlax-put (vlax-get-property wks 'range (strcat (chr column) (itoa count))) 'value el)
				(setq column (1+ column))
			)
			(repeat (setq nb (sslength sel))
				(setq
					ename (ssname sel (setq nb (1- nb)))
					k_list (list (cons "HANDLE" (strcat "'" (cdr (assoc 5 (entget ename))))))
				)
				(foreach el '("ROOM_NAME" "ROOM_FLOOR" "ROOM_AREA" "ROOM_PERIMETER" )
					(setq k_list (cons (cons el (vlax-ldata-get ename el)) k_list))
				)
				(setq
					count (1+ count)
					column 65
				)
				(foreach el (reverse (mapcar 'cdr k_list))
					(vlax-put (vlax-get-property wks 'range (strcat (chr column) (itoa count))) 'value el)
					(setq
						column (1+ column)
					)
				)
				(setq k_list nil)
			)
			(mapcar 'vlax-release-object (list wks xls))
			(gc)
			(vla-endundomark doc)
		)
	)
	(prin1)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="c2.JPG" style="width: 552px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1355604i50C3D5DEEE035EDE/image-size/large?v=v2&amp;amp;px=999" role="button" title="c2.JPG" alt="c2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2024 11:56:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12737953#M14825</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2024-04-27T11:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12738902#M14826</link>
      <description>&lt;P&gt;Thank you very much hosneyalaa for your lisp. I just have a request if it possible to &lt;STRONG&gt;change color of polyline&lt;/STRONG&gt; when it is selected, so as to avoid duplication in selection. Can you please include this in your lisp and post your lisp again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One more thing i would like to mention in the ROOM_DATA_OUT lisp, the last room selected appears on the top and the first room selected appears at the last. I would like first room selection to be first and the last room selected to be at last. Please see attached excel sheet, I selected room No-1 at first and room No-4 at last.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Apr 2024 07:25:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12738902#M14826</guid>
      <dc:creator>sajid727</dc:creator>
      <dc:date>2024-04-28T07:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12739149#M14827</link>
      <description>&lt;P&gt;try&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;(vl-load-com)
(defun c:ROOM_DATAr (/ AcDoc Space old_lay pt sel ent vla_obj)
  (setq
    AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
    Space
	  (if (= 1 (getvar "CVPORT"))
	    (vla-get-PaperSpace AcDoc)
	    (vla-get-ModelSpace AcDoc)
	  )
  )
  (cond
    ((null (tblsearch "LAYER" "AREA_ROOM"))
     (vlax-put (vla-add (vla-get-layers AcDoc) "AREA_ROOM")
	       'color
	       3
     )
    )
  )
  (setq old_lay (getvar "CLAYER"))
  (setvar "CLAYER" "AREA_ROOM")
  (setq	pt (getpoint
	     "\nFirst point of polyline or enter for select one: "
	   )
  )
  (if pt
    (command "_.pline"
	     pt
	     (while (not (zerop (getvar "cmdactive")))
	       (command pause)
	     )
    )
    (while (not	(setq sel (ssget "_+.:E:S"
				 '((0 . "*POLYLINE")
				   (-4 . "&amp;lt;NOT")
				   (-4 . "&amp;amp;")
				   (70 . 120)
				   (-4 . "NOT&amp;gt;")
				  )
			  )
		)
	   )
    )
  )
  (cond
    (sel
     (setq
       ent     (ssname sel 0)
       vla_obj (vlax-ename-&amp;gt;vla-object ent)
     )
     (vlax-put-property vla_obj "Layer" "AREA_ROOM")
     (vlax-put-property vla_obj "color" 1)
    )
    (T
     (setq ent	   (entlast)
	   vla_obj (vlax-ename-&amp;gt;vla-object ent)
     )
     (vlax-put-property vla_obj "color" 1)
    )
  )
  (vlax-ldata-put
    vla_obj
    "ROOM_NAME"
    (getstring T "\nName of room : ")
  )
  (vlax-ldata-put
    vla_obj
    "ROOM_AREA"
    (vlax-get-property vla_obj "Area")
  )
  (vlax-ldata-put
    vla_obj
    "ROOM_PERIMETER"
    (vlax-get-property vla_obj "Length")
  )
  (vlax-ldata-put
    vla_obj
    "ROOM_FLOOR"
    (getstring T "\nFloor of room : ")
  )
  (setvar "CLAYER" old_lay)
  (princ "\nPolyline have this data:")
  (print (vlax-ldata-list vla_obj))
  (prin1)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 28 Apr 2024 12:42:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12739149#M14827</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2024-04-28T12:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12739197#M14828</link>
      <description>&lt;P&gt;try&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;(defun c:ROOM_DATA_OUTs
       (/ sel file_output doc xls wks column count nb ename k_list)
  (setq
    sel		(ssget "_X"
		       '((0 . "*POLYLINE")
			 (8 . "AREA_ROOM")
			 (-4 . "&amp;lt;NOT")
			 (-4 . "&amp;amp;")
			 (70 . 120)
			 (-4 . "NOT&amp;gt;")
			)
		)
    file_output	(strcat	(getvar "DWGPREFIX")
			(substr	(getvar "DWGNAME")
				1
				(- (strlen (getvar "DWGNAME")) 4)
			)
			(rtos (getvar "CDATE") 2 6)
			".xlsm"
		)
  )
  (cond
    ((and sel file_output)
     (setq doc (vla-get-activedocument (vlax-get-acad-object)))
     (vla-startundomark doc)
     (setq xls (vlax-get-or-create-object "Excel.Application"))
     (vlax-invoke (vlax-get xls 'workbooks) 'Add)
     (vlax-put xls 'Visible :vlax-true)
     (setq
       wks    (vlax-get xls 'ActiveSheet)
       column 65
       count  1
     )
     (vlax-put (vlax-get-property
		 wks
		 'range
		 (strcat "A1:E" (itoa (sslength sel)))
	       )
	       'Cells
	       ""
     )
     (foreach el '("HANDLE"	     "ROOM_NAME"
		   "ROOM_FLOOR"	     "ROOM_AREA"
		   "ROOM_PERIMETER"
		  )
       (vlax-put (vlax-get-property
		   wks
		   'range
		   (strcat (chr column) (itoa count))
		 )
		 'value
		 el
       )
       (setq column (1+ column))
     )







     (setq
       ptLst (reverse
	       (mapcar
		 'cdr
		 (vl-sort
		   (mapcar '(lambda (x)
			      (cons (vlax-ldata-get x "ROOM_NAME") x)
			    )

			   (mapcar 'cadr (ssnamex sel))
		   )
		   '(lambda (a b) (&amp;lt; (car a) (car b)))
		 )
	       )
	     )
     )



     (repeat (setq nb (length ptLst))
       (setq
	 ename	(nth (setq nb (1- nb)) ptLst)
	 k_list	(list (cons "HANDLE"
			    (strcat "'" (cdr (assoc 5 (entget ename))))
		      )
		)
       )
       (foreach	el
		'("ROOM_NAME" "ROOM_FLOOR" "ROOM_AREA" "ROOM_PERIMETER")
	 (setq k_list (cons (cons el (vlax-ldata-get ename el)) k_list))
       )
       (setq
	 count	(1+ count)
	 column	65
       )
       (foreach	el (reverse (mapcar 'cdr k_list))
	 (vlax-put (vlax-get-property
		     wks
		     'range
		     (strcat (chr column) (itoa count))
		   )
		   'value
		   el
	 )
	 (setq
	   column (1+ column)
	 )
       )
       (setq k_list nil)
     )
     (mapcar 'vlax-release-object (list wks xls))
     (gc)
     (vla-endundomark doc)
    )
  )
  (prin1)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="c1.JPG" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1355779i3953C71556FF4621/image-size/large?v=v2&amp;amp;px=999" role="button" title="c1.JPG" alt="c1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Apr 2024 13:41:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12739197#M14828</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2024-04-28T13:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12740753#M14829</link>
      <description>&lt;P&gt;Thanks hosneyalaa ! you are an expert. This is what i wanted. Just want to ask you one more thing- if it is possible to get the result area and perimeter in 1 excel sheet, because when i get area and perimeter using ROOM_DATA_OUTs command and then make another new selection of polylines, it opens another new excel sheet. So every time new selection of polylines is made, a new excel sheet is created.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 11:50:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12740753#M14829</guid>
      <dc:creator>sajid727</dc:creator>
      <dc:date>2024-04-29T11:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12742546#M14830</link>
      <description>&lt;P&gt;This line adds a new worksheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(vlax-invoke (vlax-get xls 'workbooks) 'Add)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need to use possibly something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(setq myxl (vlax-get-object "Excel.Application"))
; it will fail if Excel is not open so can then check again
(if (= myxl nil)
(progn
(setq myxl (vlax-get-or-create-object "excel.Application"))
;this will open myxl wether itexists or will start a new session and needs the "ADD"
(vlax-invoke-method (vlax-get-property myXL 'WorkBooks) 'Add) ; opens a new xl
)
)
(vla-put-visible myXL :vlax-true)
(vlax-put-property myxl 'ScreenUpdating :vlax-true)
(vlax-put-property myXL 'DisplayAlerts :vlax-true)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 04:31:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12742546#M14830</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2024-04-30T04:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12742687#M14831</link>
      <description>&lt;P&gt;Hello Sea-Haven. Thanks for your advice, can you please update the lisp with the changes you suggested and repost it.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 06:14:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12742687#M14831</guid>
      <dc:creator>sajid727</dc:creator>
      <dc:date>2024-04-30T06:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12743431#M14832</link>
      <description>&lt;P&gt;TRY&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;(defun c:ROOM_DATA_OUTsS
       (/ COLUMN COUNT DOC ENAME FILE_OUTPUT K_LIST NB PTLST SEL WKS X XLBOOK XLRANGE XLS)
  (setq
    sel		(ssget "_X"
		       '((0 . "*POLYLINE")
			 (8 . "AREA_ROOM")
			 (-4 . "&amp;lt;NOT")
			 (-4 . "&amp;amp;")
			 (70 . 120)
			 (-4 . "NOT&amp;gt;")
			)
		)
    file_output	(getfiled "Select Excel file :"
			  (getvar "dwgprefix")
			  "xlsx;xls"
			  16
		)
  )
  (cond
    ((and sel file_output)
     (setq doc (vla-get-activedocument (vlax-get-acad-object)))
     (vla-startundomark doc)
     (setq xls (vlax-get-or-create-object "Excel.Application"))

     (vlax-put xls 'Visible :vlax-true)

     (not
       (vl-catch-all-error-p
	 (vl-catch-all-apply
	   (function (lambda ()
		       (setq
			 xlBook	(vlax-invoke-method
				  (vlax-get-property xls 'WorkBooks)
				  "Open"
				  file_output
				)
		       )
		     )
	   )
	 )
       )
     )
     (setq
       wks    (vlax-get xls 'ActiveSheet)
       column 65
       count  1
     )
     (vlax-put (vlax-get-property
		 wks
		 'range
		 (strcat "A1:E" (itoa (sslength sel)))
	       )
	       'Cells
	       ""
     )
     (foreach el '("HANDLE"	     "ROOM_NAME"
		   "ROOM_FLOOR"	     "ROOM_AREA"
		   "ROOM_PERIMETER"
		  )
       (vlax-put (vlax-get-property
		   wks
		   'range
		   (strcat (chr column) (itoa count))
		 )
		 'value
		 el
       )
       (setq column (1+ column))
     )







     (setq
       ptLst (reverse
	       (mapcar
		 'cdr
		 (vl-sort
		   (mapcar '(lambda (x)
			      (cons (vlax-ldata-get x "ROOM_NAME") x)
			    )

			   (mapcar 'cadr (ssnamex sel))
		   )
		   '(lambda (a b) (&amp;lt; (car a) (car b)))
		 )
	       )
	     )
     )



     (repeat (setq nb (length ptLst))
       (setq
	 ename	(nth (setq nb (1- nb)) ptLst)
	 k_list	(list (cons "HANDLE"
			    (strcat "'" (cdr (assoc 5 (entget ename))))
		      )
		)
       )
       (foreach	el
		'("ROOM_NAME" "ROOM_FLOOR" "ROOM_AREA" "ROOM_PERIMETER")
	 (setq k_list (cons (cons el (vlax-ldata-get ename el)) k_list))
       )
       (setq
	 count	(1+ count)
	 column	65
       )
       (foreach	el (reverse (mapcar 'cdr k_list))
	 (vlax-put (vlax-get-property
		     wks
		     'range
		     (strcat (chr column) (itoa count))
		   )
		   'value
		   el
	 )
	 (setq
	   column (1+ column)
	 )
       )
       (setq k_list nil)
     )
     (mapcar 'vlax-release-object (list wks xls))
     (gc)
     (vla-endundomark doc)
    )
  )
  (prin1)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 30 Apr 2024 12:31:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12743431#M14832</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2024-04-30T12:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12745039#M14833</link>
      <description>&lt;P&gt;In your code "Getfile" the file does not exist what then ? This is the case when making a new file. May need a open or check is file already open. I know looked at this before and need to do like 3 checks before proceeding. Maybe 1st step is as suggested is Excel open, if so check what is current file name. If correct use it else open a new or open a existing file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I admit I went around in circles and never finished the checking in my Excel code. These may be helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun openexist ( / )
(setq aH:ex "T")
(setq mySheet (vl-catch-all-apply 'vlax-get-property (list (vlax-get-property myxl "Sheets") "Item" sheetName)))
(vlax-invoke-method mySheet "Activate")
)


(defun openexcel-sheetname (filename sheetname / )
(setq myBook (vl-catch-all-apply 'vla-open (list (vlax-get-property myXL "WorkBooks") fileName)))
(setq mySheet (vl-catch-all-apply 'vlax-get-property (list (vlax-get-property myBook "Sheets") "Item" sheetName)))
(vlax-invoke-method mySheet "Activate")
)

(defun newexcelname (newname / )
(vlax-invoke-method (vlax-get-property myXL 'WorkBooks) 'Add) ; opens a new xl
(vlax-put-property  (vlax-get-property (VLAX-get-property myxl "ActiveWorkbook") 'name) newname)
)

; set current worksheet  needs work
(defun setsheet ( sheetname / )
(setq xlSheets (vlax-get-property myxl "Worksheets"))
(setq curSheet (vlax-get-property xlSheets "Item" 1))  ; 1 is 1st sheet need names of sheets somehow.
; (vlax-get cursheet 'Name) returns name 
(vlax-invoke-method curSheet "Activate")
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 01:18:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12745039#M14833</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2024-05-01T01:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12745178#M14834</link>
      <description>&lt;P&gt;Thank you&lt;BR /&gt;The user must close the Excel file , Before starting the lisp&lt;/P&gt;&lt;P&gt;There are many ideas that can be combined with lisps , But there is no time&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 04:02:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12745178#M14834</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2024-05-01T04:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12747393#M14835</link>
      <description>&lt;P&gt;I tried, but it is not working.&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 04:34:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12747393#M14835</guid>
      <dc:creator>sajid727</dc:creator>
      <dc:date>2024-05-02T04:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to export polyline area and length from Autocad to excel</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12993898#M14836</link>
      <description>&lt;P&gt;I need help to get the length of polylines (walls) on point-to-point selection such that the color of polyline changes on selection and then export it to excel. Drawing attached.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Sep 2024 07:37:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-export-polyline-area-and-length-from-autocad-to-excel/m-p/12993898#M14836</guid>
      <dc:creator>sajid727</dc:creator>
      <dc:date>2024-09-01T07:37:31Z</dc:date>
    </item>
  </channel>
</rss>

