<?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: Yet Another Cond Statement Issue in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11824699#M33057</link>
    <description>&lt;P&gt;You'll also need to change your delete layout code because in order for the foreach function to work you have to define the list first. But since you're defining the list inside the conditions, then you'll have to place the foreach function inside the condition also like this:&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;				(setq FloorLayouts '("E2_AL" "M2_AL" "P2_AL" "E3_AL" "M3_AL" "P3_AL" "E4_AL" "M4_AL" "P4_AL"))
                              (foreach x FloorLayouts
				(command "-LAYOUT" "_d" x)
                              ) ; foreach&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Mar 2023 02:01:24 GMT</pubDate>
    <dc:creator>paullimapa</dc:creator>
    <dc:date>2023-03-16T02:01:24Z</dc:date>
    <item>
      <title>Yet Another Cond Statement Issue</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11824380#M33054</link>
      <description>&lt;P&gt;Hello All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know there is tons of posts on this topic, and I have done my best to format according to the examples that I see, but I am not getting anything when I run my code snippet below. What I am trying to do is removing layouts according the amount of floors a model home has. The variable "Floor_Count" is set by another function prior to this one running. But, when I run the code below, it does not remove any of the layouts. The options available are 1, 2, 3, and 4. If 1, 2, or 3 are selected, then it will remove the appropriate sheets. If 4 is selected, then no sheets will be removed. I have tried using "(and (= Floor_Count 1))..." but I get the same results as well.&amp;nbsp;Any insight on what I am missing?&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;LI-CODE lang="general"&gt;(defun DeleteFloorLayouts ( / cmd FloorLayouts x)

 ;Remove Floor Layouts
	(foreach x FloorLayouts
		(vl-catch-all-apply
			'vla-add
			(list (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) x)
		)
		(cond 
			((/= Floor_Count 1)
				(setq FloorLayouts '("E2_AL" "M2_AL" "P2_AL" "E3_AL" "M3_AL" "P3_AL" "E4_AL" "M4_AL" "P4_AL"))
				(command "-LAYOUT" "_d" x)
				(princ "\nExcess floor layouts for the 2nd-4th floors removed\n")
			)
			((/= Floor_Count 2)
				(setq FloorLayouts '("E3_AL" "M3_AL" "P3_AL" "E4_AL" "M4_AL" "P4_AL"))
				(command "-LAYOUT" "_d" x)
				(princ "\nExcess floor layouts for the 3rd And 4th floors removed\n")
			)
			((/= Floor_Count 3)
				(setq FloorLayouts '("E4_AL" "M4_AL" "P4_AL"))
				(command "-LAYOUT" "_d" x)
				(princ "\nExcess floor layouts for the 4th floor removed\n")
			)
			;if 4 floors, remove nothing
			(princ "\nNO floor layouts removed!\n")
		)
	)
  (princ)
);defun&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 Mar 2023 21:07:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11824380#M33054</guid>
      <dc:creator>The_CADalyst</dc:creator>
      <dc:date>2023-03-16T21:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: Yet Another Cond Statement Issue</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11824608#M33055</link>
      <description>&lt;P&gt;assuming your floor_count is a number &amp;amp; not a string, modify the last section of your cond statement with:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;			;if 4 floors, remove nothing
                 (t
			(princ "\nAutoLot&amp;gt; NO floor layouts removed!\n")
                 ) ; else&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 Mar 2023 00:17:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11824608#M33055</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2023-03-16T00:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Yet Another Cond Statement Issue</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11824618#M33056</link>
      <description>&lt;P&gt;also I think you need to check the conditions based on the actual number like:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;((= Floor_Count 1)
)
((= Floor_Count 2)
)
((= Floor_Count 3)
)
(t
)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 Mar 2023 00:23:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11824618#M33056</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2023-03-16T00:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Yet Another Cond Statement Issue</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11824699#M33057</link>
      <description>&lt;P&gt;You'll also need to change your delete layout code because in order for the foreach function to work you have to define the list first. But since you're defining the list inside the conditions, then you'll have to place the foreach function inside the condition also like this:&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;				(setq FloorLayouts '("E2_AL" "M2_AL" "P2_AL" "E3_AL" "M3_AL" "P3_AL" "E4_AL" "M4_AL" "P4_AL"))
                              (foreach x FloorLayouts
				(command "-LAYOUT" "_d" x)
                              ) ; foreach&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 02:01:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11824699#M33057</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2023-03-16T02:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Yet Another Cond Statement Issue</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11825629#M33058</link>
      <description>&lt;P&gt;In addition to what &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1137264"&gt;@paullimapa&lt;/a&gt;&amp;nbsp;has pointed out:&amp;nbsp; With only &lt;EM&gt;one&lt;/EM&gt; thing to do in the fallback [4] condition, you don't even need the T "test."&amp;nbsp; You can just do it, but it still needs to be wrapped into another pair of parentheses for the condition:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;;if 4 floors, remove nothing&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;&lt;FONT size="4" color="#0000FF"&gt;(&lt;/FONT&gt;(&lt;FONT color="#008000"&gt;prompt&lt;/FONT&gt; "\nAutoLot&amp;gt; NO floor layouts removed!\n")&lt;FONT size="4" color="#0000FF"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[And I would use&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#008000"&gt; (prompt)&lt;/FONT&gt; &lt;/STRONG&gt;&lt;/FONT&gt;rather than&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#993300"&gt; (princ)&lt;/FONT&gt; &lt;/STRONG&gt;&lt;/FONT&gt;-- that's what you're doing, and the&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt; (prinX)&lt;/FONT&gt; &lt;/STRONG&gt;&lt;/FONT&gt;functions include capabilities like writing to external files that you don't need.]&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 11:27:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11825629#M33058</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2023-03-16T11:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Yet Another Cond Statement Issue</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11827166#M33059</link>
      <description>&lt;P&gt;Thank you both&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1137264"&gt;@paullimapa&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;. I made the updates suggested above, set my floor count to just 1 to test if it would remove floors 2-4 using (setq Floor_Count "1") , and now I only get a "NO floor layouts removed!" as though my floor count is 4. So, it appears to be working halfway, but not reading my floor count variable. Does the code below need further adjustments or did I mess something up?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun DeleteFloorLayouts ( / cmd FloorLayouts x)

 ;Remove Floor Layouts
	(vl-catch-all-apply
		'vla-add
		(list (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) x)
	)
	(cond 
		((= Floor_Count 1)
			(setq FloorLayouts '("E2_AL" "M2_AL" "P2_AL" "E3_AL" "M3_AL" "P3_AL" "E4_AL" "M4_AL" "P4_AL"))
				(foreach x FloorLayouts
					(command "-LAYOUT" "_d" x)
				) ; foreach
			(prompt "\nExcess floor layouts for the 2nd-4th floors removed\n")
		)
		((= Floor_Count 2)
			(setq FloorLayouts '("E3_AL" "M3_AL" "P3_AL" "E4_AL" "M4_AL" "P4_AL"))
				(foreach x FloorLayouts
					(command "-LAYOUT" "_d" x)
				) ; foreach
			(prompt "\nExcess floor layouts for the 3rd And 4th floors removed\n")
		)
		((= Floor_Count 3)
			(setq FloorLayouts '("E4_AL" "M4_AL" "P4_AL"))
				(foreach x FloorLayouts
					(command "-LAYOUT" "_d" x)
				) ; foreach
			(prompt "\nExcess floor layouts for the 4th floor removed\n")
		)
		;if 4 floors, remove nothing
		((prompt "\nNO floor layouts removed!\n"))
	) ; cond
  (princ)
);defun&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 21:43:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11827166#M33059</guid>
      <dc:creator>The_CADalyst</dc:creator>
      <dc:date>2023-03-16T21:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Yet Another Cond Statement Issue</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11827178#M33060</link>
      <description>&lt;P&gt;try this instead:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(setq Floor_Count 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(setq Floor_Count 2)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(setq Floor_Count 3)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(setq Floor_Count 4)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But if&amp;nbsp;Floor_Count really is a string = "1" or "2" or "3" or "4", then you'll need to convert it to an integer then use atoi function to convert it from ascii to integer like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(setq Floor_Count (atoi "1"))&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 21:47:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11827178#M33060</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2023-03-16T21:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Yet Another Cond Statement Issue</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11827204#M33061</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4926608"&gt;@The_CADalyst&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's another way to do this using &lt;A href="https://help.autodesk.com/view/ACD/2023/ENU/?guid=GUID-EC257AF7-72D4-4B38-99B6-9B09952A53AD" target="_blank" rel="noopener"&gt;WCMATCH&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="lisp"&gt;(defun c:foo (/ f i r)
  ;; RJP » 2023-03-16
  ;; Removes 'floor' tabs above a certain input
  (cond	((and (setq i (getint "\nEnter Floors: ")) (&amp;lt;= 1 i 3))
	 (repeat (- 4 i) (setq r (cons (setq i (1+ i)) r)))
	 (foreach n (setq r (mapcar 'itoa (reverse r)))
	   (vlax-for l (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
	     (if (wcmatch (vla-get-name l) (strcat "[E M P]" n "_AL"))
	       (vla-delete l)
	     )
	   )
	 )
	 (princ (strcat "\nFLOORS " (vl-princ-to-string r) " REMOVED!"))
	)
	((princ "\nINPUT RANGE 1-3 !!"))
  )
  (princ)
)
(vl-load-com)&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;</description>
      <pubDate>Thu, 16 Mar 2023 22:35:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11827204#M33061</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2023-03-16T22:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Yet Another Cond Statement Issue</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11828899#M33062</link>
      <description>&lt;P&gt;hey, keeping stylistics, but slightly reshuffled, without adding layouts.&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;&lt;LI-CODE lang="lisp"&gt;(defun DeleteFloorLayouts ()
 ;Remove Floor Layouts
	(foreach x 
			(cond 
				((= Floor_Count 1)
					(princ "\nExcess floor layouts for the 2nd-4th floors removed\n")
					'("E2_AL" "M2_AL" "P2_AL" "E3_AL" "M3_AL" "P3_AL" "E4_AL" "M4_AL" "P4_AL")
				)
				((= Floor_Count 2)
					(princ "\nExcess floor layouts for the 3rd And 4th floors removed\n")
					'("E3_AL" "M3_AL" "P3_AL" "E4_AL" "M4_AL" "P4_AL")
				)
				((= Floor_Count 3)
					(princ "\nExcess floor layouts for the 4th floor removed\n")
					'("E4_AL" "M4_AL" "P4_AL")
				)
				;if 4 floors, remove nothing
				( t
					(princ "\nNO floor layouts removed!\n")
					nil
				)
			)
			(command "-LAYOUT" "_d" x)
	)
  (princ)
);defun&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 17 Mar 2023 14:23:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/yet-another-cond-statement-issue/m-p/11828899#M33062</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2023-03-17T14:23:49Z</dc:date>
    </item>
  </channel>
</rss>

