Originally Posted by
ReachAndre
OK everyone I have fixed my code so that it does the following:
adds "makes" layer "Duct" to prevent bombing.
Also Allows me to rotate all of my new object.
Thanks to everyone for all your help.
Great Andre, I just added some secure lines to your code
Code:
(defun c:reduct (/ currlay redpt1 sz1 sz2 SelSet )
(if ; adding a check to find out if some indata is missing
(and
(setq currlay (getvar "CLAYER" ) )
(setq redpt1 (getpoint "\nSelect insertion point of reducer: " ) )
(setq sz1 (getdist "\nEnter width of old duct: " ) )
(setq sz2 (getdist "\nEnter width of new duct: " ) )
)
(progn ; no indata is missing, run the progn
(setq SelSet (ssadd) )
(if (not (tblsearch "LAYER" "duct" )) ; check if layer duct is present
(command "-layer" "make" "duct" "color" "blue" "duct" "") ; if not create the layer
( ) ; the layer exist, do nothing
)
(setvar "CLAYER" "0" )
(command "line" redpt1 (strcat "@0," (rtos sz1 )) "" )
(setq SelSet (ssadd (entlast) SelSet ) )
(setvar "CLAYER" "Duct" )
(command "line" "" (strcat "@" (rtos (* sz1 1.10 ) ) "," (rtos(- sz2 sz1 ))) "" )
(setq SelSet (ssadd (entlast) SelSet ) )
(setvar "CLAYER" "0" )
(command "line" "" (strcat "@0," (rtos (* sz2 -1 ))) "" )
(setq SelSet (ssadd (entlast) SelSet ) )
(setvar "CLAYER" "Duct" )
(command "pline" "" redpt1 "" )
(setq SelSet (ssadd (entlast) SelSet ) )
(command "line" redpt1 (strcat "@" (rtos (* sz1 1.10 ) ) ",0") "")
(command "erase" (entlast) "") ; <-- WHY create then erase ? ? ?
(setvar "clayer" "duct" )
(command "line" "" (strcat "@" (rtos (/ sz1 2 )) ",0" ) "" )
(setq SelSet (ssadd (entlast) SelSet ) )
(command "copy" (entlast) "" redpt1 (strcat "@0," (rtos sz2 )) )
(setq SelSet (ssadd (entlast) SelSet ) )
;;; (command "select" SelSet "" ) ; I suppose you do not need this line anymore
(command "rotate" SelSet "" redpt1 pause )
)
(princ ". .missing indata" ) ; some indata is missing
)
(princ)
)
: ) Happy Computing !
everyone