Page 1 of 1

Cond help

Posted: Tue Jan 09, 2024 1:58 am
by sln8458
Having trouble setting a cond statement.
When the value of 'eit' is anything above '0' I want to create the insulation entities. [within the (progn....)]
If 'eit' is zero I want to skip this step and go to (INS_MB)
The following code does not work & I can't see my error(s)

Code: Select all

(defun DRAW_INS () 
;----------
; Draw Insulation recangle
	(cond (/= eit 0)
	(progn	
	(command "_Rectangle";
						  (strcat (rtos EIXOO#) "," (rtos EIYOO#) ",0" )
						  (strcat "@" (rtos eitx#) "," (rtos eity#) ",0" ) "")
	(command "_fillet" "R" eit# "")
	(command "_fillet" "P" "L" "")
		(setq ENTZ1 (entlast))
;Extrude Insulation Shell	
	(command "_extrude" ENTZ1 "" dis "")
		(setq ENTZ3 (entlast))
	(command "_extrude" ENTZ2 "" dis "")
		(setq ENTZ4 (entlast))	
	(command "_subtract" ENTZ3 "" ENTZ4 "")
		(setq ENTZ5 (entlast))
	(command "_change" ENTZ5 "" "P"	"la" "Insulation" "")	
		(ssadd ENTZ5 SS)							; ADD TO SELECTION SET
	);end progn
	);END COND
	(INS_MB)
) ;end DRAW_INS	

Re: Cond help

Posted: Tue Jan 09, 2024 3:17 am
by QuanNguyen
Hi Steve,
The "(cond (/= eit 0)" should be "(cond ( (/= eit 0)"

Please refer this :

Code: Select all

(defun DRAW_INS () 
;----------
; Draw Insulation recangle
 (cond
   ((/= eit 0)
    (progn	
          ; do something
      ) ;end progn
    ) ; end (/= eit 0)
   );END COND

  (INS_MB)
) ;end DRAW_INS	

Re: Cond help

Posted: Tue Jan 09, 2024 3:22 am
by sln8458
Thanks Quan,
However if I add the '(' as you suggest I am missing the closing ')' ??

edit:
scrap that, I just noticed the ' ) ; end (/= eit 0)'

SteveN

Re: Cond help

Posted: Tue Jan 09, 2024 4:12 am
by sln8458
Sorry Quan, but your change has not improved things :(

I'm trying to create a section of Rectangular ductwork, complete with flanges at both ends.
In some cases the user will require insulation and in others they will not.
So by filtering via the External Insulation Thickness (eit), I want to either create the insulation or skip that section
I've attached the full code below.
rduct.zip
(3.31 KiB) Downloaded 362 times

Re: Cond help

Posted: Tue Jan 09, 2024 8:59 am
by sln8458
I think I've craked it:

Changed this:

Code: Select all

((/= eit 0)
to this:

Code: Select all

((/= eit "0")
Now working as expected :)