<?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: CODE correction for extract ATTRIBUTE in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796518#M69207</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code is not bad but you have to start using testing.&lt;/P&gt;&lt;P&gt;Instead using IF statements try to use COND.&lt;/P&gt;&lt;P&gt;With selection sets there is a catch. When you receive selection set always test for its existence and number of elements inside it.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(setq ss (ssget))
(cond 
       ((and ss (&amp;gt; (sslenght ss)0)
        ...... code goes here
       )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;You don't need to check if the sslength of the selection set is more than one as long as the selection set is not equal to nil.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;COND can't be BETTER than IF function nor visa versa because that depends on the situation and sometimes on the experience of the user.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 11 Oct 2020 17:49:27 GMT</pubDate>
    <dc:creator>_Tharwat</dc:creator>
    <dc:date>2020-10-11T17:49:27Z</dc:date>
    <item>
      <title>CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796359#M69194</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am writing a code to extract block ATTRIBUTE into excel file like below. I can load the lisp without any issue. While running in CAD the loop is not completed. And i put something wrong somewhere. but i could not correct that. Could you please anyone correct me and teach me where i put wrong. ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached my Lisp and CAD block file here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:ATTX()
	(setq filePath "c:\\temp\\")
	(setq fileName "P&amp;amp;ID List")
	(setq fileLoc (strcat filePath fileName ".csv"))
	(setq xcelfile(open fileLoc "w"))
	(setq blocks (ssget "_X" '((0 . "INSERT") (8 . "VALVE"))))
	(setq ctr 0)
	(setq len (sslength blocks))
	(write-line (strcat "ValveTag") xcelfile)
	(while (/= ctr len)
		
		(setq blk (ssname blocks ctr))
		(setq blks (entget blk))
		
		(setq flag T)
		(while flag
			(setq lArea (entget(entnext(cdr(assoc -1 blks)))))
			
			(setq attrib1 (cdr(assoc 0 lArea)))
			
			(if (= attrib1 "ATTRIB")
				(progn
					(setq tagnameArea (cdr(assoc 2 lArea)))
					
					(if (= tagnameArea "VALVETAG")
						(setq valveTag (cdr (assoc 1 lArea)))
						
						
					)
				)
				(setq flag nil)
			)
		)
		(write-line (valveTag) xcelfile)
		(setq ctr (1+ ctr))
	)
	(close xcelfile)
	(princ (strcat " Extraction is complete. " fileName " has been created. "))
	(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 14:50:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796359#M69194</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-11T14:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796364#M69195</link>
      <description>&lt;LI-CODE lang="general"&gt;(while (/= ctr len)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;replace with&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(while (&amp;lt; ctr len)&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 11 Oct 2020 14:54:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796364#M69195</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-10-11T14:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796374#M69196</link>
      <description>&lt;P&gt;Thanks for your fastest reply,&lt;/P&gt;&lt;P&gt;But i have no luck.&lt;/P&gt;&lt;P&gt;It is still the same model of loading when running the lisp file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The lisp file is working and its complete the process without writing anything in the excel file.&amp;nbsp;If I put the code like the below.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(while(&amp;gt; ctr len)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 15:09:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796374#M69196</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-11T15:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796376#M69197</link>
      <description>&lt;P&gt;OK. Upload&amp;nbsp; dwg the file with predefined blocks and layers for easier work.&lt;/P&gt;&lt;P&gt;I will check the code to for error.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 15:14:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796376#M69197</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-10-11T15:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796390#M69198</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:ATTX()
	(cond 
		((and (setq f (getfiled "Output .csv file:" (getvar "dwgprefix") "csv" 3)))
			(setq outstring (strcat "\nExtraction is complete. " f " has been created. "))
			(setq xcelfile (open f "w"))
			(setq blocks (ssget "_X" '((0 . "INSERT") (8 . "VALVE"))))
			(setq ctr 0)
			(setq len (sslength blocks))
			(write-line "ValveTag" xcelfile)
			(while (&amp;lt; ctr len)
			(setq blk (ssname blocks ctr))
			(setq blks (entget blk))
			(setq flag T)
			(while flag
				(setq lArea (entget(entnext(cdr(assoc -1 blks)))))
				(setq attrib1 (cdr(assoc 0 lArea)))
				(if (= attrib1 "ATTRIB")
					(progn
						(setq tagnameArea (cdr(assoc 2 lArea)))
						
						(if (= tagnameArea "VALVETAG")
							(setq valveTag (cdr (assoc 1 lArea)))
							
							
						)
					)
					(setq flag nil)
				)
			)
			(write-line valveTag xcelfile)
			(setq ctr (1+ ctr))
			)
			(close xcelfile)
			(princ outstring)
		)
	)
	(princ)
)&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 15:27:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796390#M69198</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-10-11T15:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796399#M69199</link>
      <description>&lt;LI-CODE lang="lisp"&gt;(defun c:ATTX ( / blocks filePath fileName fileLoc xcelfile ctr len valvetag blk )
  (if
    (and
        ;;	ensure that there are block objects on this layer	;;;
       (setq blocks (ssget "_X" '((0 . "INSERT")(66 . 1)(8 . "VALVE"))))
       	;; Checks if directory exist			;;
	(findfile (setq filePath "c:\\temp"))			
	(setq fileName "P&amp;amp;ID List"
		fileLoc (strcat filePath "\\" fileName ".csv"))
	(setq xcelfile(open fileLoc "w"))	
	(setq ctr 0 len (sslength blocks))
	)
       (progn
	(write-line (strcat "ValveTag") xcelfile)
	;; 	while ctr valeu is less than len	;;
	;; 	selection sets are 0 index		;;
	(while (&amp;lt; ctr len)
	(setq blk (ssname blocks ctr))
	    (while
	        (and
	            (null valveTag)
	            (setq blk (entnext blk))
	            (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk)))))
	        )
			(setq valveTag (cdr (assoc 1 (reverse enx))))
	        )
	  (write-line valveTag xcelfile)
	  (setq ctr (1+ ctr) valveTag nil)
	  )
	(close xcelfile)
	(princ (strcat " Extraction is complete. " fileName " has been created. "))
		)
    (princ "\nNo valid block(s) found")
    )
	(princ)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 11 Oct 2020 15:31:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796399#M69199</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2020-10-11T15:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796404#M69200</link>
      <description>&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;Following your way of coding but you need to localize the variables.&lt;/FONT&gt;&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;&lt;LI-CODE lang="markup"&gt;(defun c:ATTX ()
  (setq filePath "c:\\temp\\")
  (setq fileName "P&amp;amp;ID List")
  (setq fileLoc (strcat filePath fileName ".csv"))
  (setq xcelfile (open fileLoc "w"))
  (if (setq blocks (ssget "_X" '((0 . "INSERT")(66 . 1)(8 . "VALVE"))))
    (progn
      (setq len (sslength blocks))
      (write-line (strcat "ValveTag") xcelfile)
      (while (setq blk (ssname blocks (setq len (1- len))))
        (setq blks (entget blk))
        (while
          (and (setq blk (entnext blk))
               (/= (cdr (assoc 0 (setq lArea (entget blk)))) "SEQEND")
          )

           (if (= (cdr (assoc 0 lArea)) "ATTRIB")
             (progn
               (setq tagnameArea (cdr (assoc 2 lArea)))

               (if (= tagnameArea "VALVETAG")
                 (setq valveTag (cdr (assoc 1 lArea)))
               )
             )
           )
        )
        (write-line valveTag xcelfile)
      )
      (close xcelfile)
      (princ (strcat " Extraction is complete. "
                     fileName
                     " has been created. "
             )
      )
    )
  )
  (princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 15:38:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796404#M69200</guid>
      <dc:creator>_Tharwat</dc:creator>
      <dc:date>2020-10-11T15:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796413#M69201</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/564264"&gt;@pbejse&lt;/a&gt;&amp;nbsp;wrote:&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(write-line (strcat "ValveTag") xcelfile)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;What's the function &lt;FONT color="#0000FF"&gt;STRCAT&lt;/FONT&gt; for?&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 15:41:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796413#M69201</guid>
      <dc:creator>_Tharwat</dc:creator>
      <dc:date>2020-10-11T15:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796417#M69202</link>
      <description>&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;Be careful if the &lt;FONT color="#0000FF"&gt;ssget&lt;/FONT&gt;&amp;nbsp;function returns nil, then the program will throw an error and keep the file hanging in the sky without closing.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 15:44:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796417#M69202</guid>
      <dc:creator>_Tharwat</dc:creator>
      <dc:date>2020-10-11T15:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796418#M69203</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/660967"&gt;@_Tharwat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;HR /&gt;
&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;What's the function &lt;FONT color="#0000FF"&gt;STRCAT&lt;/FONT&gt; for?&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;FONT size="3"&gt;Bad case of copy and paste is what&amp;nbsp;&lt;/FONT&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 15:44:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796418#M69203</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2020-10-11T15:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796452#M69204</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/660967"&gt;@_Tharwat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;Be careful if the &lt;FONT color="#0000FF"&gt;ssget&lt;/FONT&gt;&amp;nbsp;function returns nil, then the program will throw an error and keep the file hanging in the sky without closing.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I know. But since @Anonymous&amp;nbsp; is greasing elbows to learn autolisp I would like him to start testing his code and look for potential potholes. That is best way to learn programing, and we all have gone through this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 16:29:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796452#M69204</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-10-11T16:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796475#M69205</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;That is best way to learn programing, and we all have gone through this.&lt;/BLOCKQUOTE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT size="3"&gt;Though I agree&amp;nbsp; with you about learning, but that particular error would be a tough one for a beginner to figure out on their own, would you agree? &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;Cmon &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;, be nice&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;Bet money the OP restarted CAD about 5 times by now,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 17:01:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796475#M69205</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2020-10-11T17:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796510#M69206</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code is not bad but you have to start using testing.&lt;/P&gt;&lt;P&gt;Instead using IF statements try to use COND.&lt;/P&gt;&lt;P&gt;With selection sets there is a catch. When you receive selection set always test for its existence and number of elements inside it.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(setq ss (ssget))
(cond 
       ((and ss (&amp;gt; (sslenght ss)0)
        ...... code goes here
       )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Same principle apply when you use function getfiled to select input/output file through system dialog.&lt;/P&gt;&lt;P&gt;If you hit &amp;lt;esc&amp;gt; during file selection file path string will be nill and code will present an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(cond 
    ((and (setq f (getfiled "Output .csv file:" (getvar "dwgprefix") "csv" 3)))
   .......
  )
)&lt;/LI-CODE&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 17:38:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796510#M69206</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-10-11T17:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796518#M69207</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code is not bad but you have to start using testing.&lt;/P&gt;&lt;P&gt;Instead using IF statements try to use COND.&lt;/P&gt;&lt;P&gt;With selection sets there is a catch. When you receive selection set always test for its existence and number of elements inside it.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(setq ss (ssget))
(cond 
       ((and ss (&amp;gt; (sslenght ss)0)
        ...... code goes here
       )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;You don't need to check if the sslength of the selection set is more than one as long as the selection set is not equal to nil.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;COND can't be BETTER than IF function nor visa versa because that depends on the situation and sometimes on the experience of the user.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 17:49:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796518#M69207</guid>
      <dc:creator>_Tharwat</dc:creator>
      <dc:date>2020-10-11T17:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796558#M69208</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/660967"&gt;@_Tharwat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;You don't need to check if the sslength of the selection set is more than one as long as the selection set is not equal to nil.&lt;/FONT&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Yes, but if you want to have your code bulletproof you have to add it in your code. Once selection set equals null your code will break.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;COND can't be BETTER than IF function nor visa versa because that depends on the situation and sometimes on the experience of the user.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;True and false. It is a different story when number of PROGN blocks starts to rise. Cond is than easier to handle. &lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 18:22:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796558#M69208</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-10-11T18:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796584#M69209</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;wrote:&lt;P class="1602442057599"&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="font-family: inherit;"&gt;Yes, but if you want to have your code bulletproof you have to add it in your code. Once selection set equals null your code will break.&lt;/SPAN&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;You got it the wrong way, and this is what I meant based on YOUR cond way,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;(cond (ss&amp;nbsp; ;; this is enough without checking if the length is more than zero.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;wrote:&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;True and false. It is a different story when number of PROGN blocks starts to rise. Cond is than easier to handle. &lt;/FONT&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;Also True and False, the number of times you use PROGN is less than the number of statements you might use with COND although that I did not refer to that at all.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 18:55:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796584#M69209</guid>
      <dc:creator>_Tharwat</dc:creator>
      <dc:date>2020-10-11T18:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796797#M69210</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hak_z and Tharwat My $0.05 when writing code I do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(if (setq ss ....&lt;/P&gt;&lt;P&gt;(progn&lt;/P&gt;&lt;P&gt;hit enter a few times&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then go back in and add code that way know IF is balanced. Same with REPEAT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is something I should do more often stopping selection errors and admit to that.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 00:11:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796797#M69210</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2020-10-12T00:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796981#M69211</link>
      <description>&lt;P&gt;I have tried with the selection set by manual way, its has a proper contents successful.&lt;/P&gt;&lt;P&gt;But only thing the loop is getting issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the suggestion.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 04:12:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796981#M69211</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-12T04:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796995#M69212</link>
      <description>&lt;P&gt;1 st Positive response from your code,&lt;/P&gt;&lt;P&gt;Its running and the excel file is creating successfully.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for this.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 04:57:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9796995#M69212</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-12T04:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: CODE correction for extract ATTRIBUTE</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9797102#M69213</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;1 st Positive response from your code,&lt;/P&gt;&lt;P&gt;Its running and the excel file is creating successfully.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for this.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="4"&gt;You're welcome anytime.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 07:01:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/code-correction-for-extract-attribute/m-p/9797102#M69213</guid>
      <dc:creator>_Tharwat</dc:creator>
      <dc:date>2020-10-12T07:01:58Z</dc:date>
    </item>
  </channel>
</rss>

