침실2_CAD

[CAD LISP] DCL 라디오 버튼으로 다른 리습 실행

다식군! 2021. 2. 21. 19:07
반응형
[CAD LISP] 라디오 버튼 DCL/LISP Auto CAD 명령어 실행
[CAD LISP] DCL 라디오 버튼으로 다른 리습 실행 CAD LISP 명령어 실행

몇년전 부터 간단한 리습을 만들기 시작 했다.

나름 내가 필요한 기능을 만들어서, 아주 나한테는 유용했다.

근데, 욕심이 생겼다.

이게 나한테만 유용하지, 다른 사람한테는 불편하다는 사실을 알았다.

음......

근데, DCL로 시각화 할 수 있다는 걸 알았다.

그래서 이렇게 만들었다.

KHS : dialog {				//dialog name
      label = "KHS Lisp" ;		//give it a label
 
       :boxed_radio_column {			//define radio column
       label = "LISP" ;				//give it a label
 
        : radio_button {			//define radion button
     	  key = "KHS1" ;				//give it a name
     	  label = "문자 스타일 지정(@Font)" ;		//give it a label
     	  value = "1" ;				//switch it on
        }					//end definition
 
     	: radio_button {			//define radio button
     	  key = "KHS2" ;				//give it a name
     	  label = "클라우드 표시/구름표시(@Cloud)" ;		//give it a label
     	}					//end definition
 
     	: radio_button {			//define radio button
     	  key = "KHS3" ;				//give it a name
     	  label = "블록 이름 바꾸기(@Bn)" ;	//give it a label
     	  }					//end definition
 
     	: radio_button {			//define radio button
     	  key = "KHS4" ;				//give it a name
     	  label = "Layer 만들기(@Layer)" ;		//give it a label
     	}					//end definition
 
     	: radio_button {			//define radio button
     	  key = "KHS5" ;				//give it a name
     	  label = "TEXT 입력(@Text)" ;	//give it a label
     	  }					//end definition
 
     	: radio_button {			//define radion button
     	  key = "KHS6" ;				//give it a name
     	  label = "TEXT 입력(2p)(@text2)" ;	//give it a label
     	}					//end definition

     	: radio_button {			//define radio button
     	  key = "KHS7" ;				//give it a name
     	  label = "출력 PLOT 설정(@P-0)" ;	//give it a label
     	  }
 
        }					//end radio column
 
     ok_cancel ;

Tip. DCL에서 "//"이후는 주석임..... 단순 설명 또는 없어도 되는거임.

 

 

DCL만으로는 아무런 작동이 안되는 관계로,

이번에, 라디오 버튼을 선택 하면, 내가 만든 리습이 작동 하는 리습을 만들기로 했다.

근데, 이게 쉽지 않았다....

리습도 구글 검색과 유튜브를 보며 만들었는데, 쉬울 리가......

그리소 다시 1년이 넘는 시간이 흐르고, 다시 구글 검색.....

희안 하게 이제 작동 한다. 

작동 안하는 걸 너무 많이 봐서 그런지 작동 하는게 더 신기함.

(defun C:@KHS()
	(setq dcl_id (load_dialog "KHS.dcl"))
  
	(if(not (new_dialog "KHS" dcl_id))
	(exit)
	);if


	(action_tile "KHS1" "(setq cmd \"@Font\")")
 	(action_tile "KHS2" "(setq cmd \"@Cloud\")")
  	(action_tile "KHS3" "(setq cmd \"@Bn\")")
  	(action_tile "KHS4" "(setq cmd \"@Layer\")")
	(action_tile "KHS5" "(setq cmd \"@text\")")
	(action_tile "KHS6" "(setq cmd \"@text2\")")
	(action_tile "KHS7" "(setq cmd \"@P-0\")")
	(action_tile "KHS8" "(setq cmd \"polygon\")")
	(action_tile "KHS9" "(setq cmd \"polygon\")")
  	(action_tile "KHS10" "(setq cmd \"polygon\")")
  
	(action_tile "accept" "(done_dialog)(setq userclick T)")
	(action_tile "cancel" "(done_dialog) (setq userclick nil)")
  
 	(start_dialog)

 (unload_dialog dcl_id)

(cond
	((= cmd "@Font" )	(setq doc (vla-get-activedocument (vlax-get-acad-object))) 	(vla-sendcommand doc (strcat cmd " "))		)
	((= cmd "@Cloud" )	(setq doc (vla-get-activedocument (vlax-get-acad-object))) 	(vla-sendcommand doc (strcat cmd " "))		)
	((= cmd "@Bn" )		(setq doc (vla-get-activedocument (vlax-get-acad-object))) 	(vla-sendcommand doc (strcat cmd " "))		)
	((= cmd "@Layer" )	(setq doc (vla-get-activedocument (vlax-get-acad-object))) 	(vla-sendcommand doc (strcat cmd " "))		)
	((= cmd "@text" )	(setq doc (vla-get-activedocument (vlax-get-acad-object))) 	(vla-sendcommand doc (strcat cmd " "))		)
	((= cmd "@text2" )	(setq doc (vla-get-activedocument (vlax-get-acad-object))) 	(vla-sendcommand doc (strcat cmd " "))		)
	((= cmd "@P-0" )	(setq doc (vla-get-activedocument (vlax-get-acad-object))) 	(vla-sendcommand doc (strcat cmd " "))		)
)	;cond
)	;defun

여기서 "@Font" , "@Cloud", "@Bn" 등은 내가 만들거나, 기존 리습을 수정 해서 만든 리습임....

 

LISP 내용을 요약하면,

1) KHS.DCL 파일을 로드하고,

2) 선택된 버튼에 따라, "cmd"라는 변수에 해당 명령어를 입력하고,

3) 만약(IF), "cmd" 변수와 해당 명령어가 같다면, 실행해라.... 

뭐, 이런 내용.

 

Tip. 만약 이게 캐드 자체 명령어라면,  

(vla-sendcommand doc (strcat cmd " "))  이부분이,  (command cmd)

이렇게 변하면 됨.

CAD명령어 일때 (command cmd)
LISP 일때 (vla-sendcommand doc (strcat cmd " "))

 

[CAD LISP] 라디오 버튼 DCL/LISP Auto CAD 명령어 실행
[CAD LISP] DCL 라디오 버튼으로 다른 리습 실행 CAD LISP 명령어 실행

 

반응형

'침실2_CAD' 카테고리의 다른 글

[CAD LISP] 좌표 추출 리습(수정)  (0) 2021.12.08
[Auto CAD] 불필요한 Layer 삭제(LayDel)  (0) 2021.12.05
[Auto CAD] DCL 미리보기  (0) 2021.11.21
[Auto CAD] WIPEOUT(명령)  (1) 2021.03.14
[Auto CAD] 동적 블록  (0) 2021.02.28
[CAD LISP] 라디오 버튼 DCL/LISP  (0) 2021.02.15
[Auto CAD] TASKBAR / SDI  (0) 2020.12.21
[Auto CAD 관련] 시작 탭 열리지 않게 하기  (0) 2020.12.01
[Auto CAD] 배경색 변경  (0) 2020.11.24
[Auto CAD]<LISP> ZOOM  (0) 2020.08.04