本帖最后由 夏生生 于 2022-4-9 22:10 编辑
大概是这么个意思,根据自己需求去改吧
- (defun c:tt (/ xty-sys-makeFbylst do_bt1
- do_bt2 area3 callback dcllst
- dcl_id en tmpf
- )
- (defun xty-sys-makeFbylst (filename strlst / f n)
- (setq f (open filename "w"))
- (foreach n strlst
- (if (eq (type n) 'STR)
- (write-line n f)
- (write-line (vl-princ-to-string n) f)
- )
- )
- (close f)
- filename
- )
- (defun do_bt1 ()
- (setq en (ssget ":e:s"'((0 . "REGION"))))
- (if en
- (setq *area1* (vla-get-area (vlax-ename->vla-object (ssname en 0)))
- area3 (rtos (/ *area1* (atof *area2*)) 2 6)
- *area1* (rtos *area1* 2 3)
- )
- )
- )
- (defun do_bt2 ()
- (setq en (ssget":e:s" '((0 . "REGION"))))
- (if en
- (setq *area2* (vla-get-area (vlax-ename->vla-object (ssname en 0)))
- area3 (rtos (/ (atof *area1*) *area2*) 2 6)
- *area2* (rtos *area2* 2 3)
- )
- )
- )
- (setq dcllst (list
- "ExtrusionRatio:dialog{label=\"ExtrusionRatio\";"
- ":row{:edit_box{key=\"eb1\";label=\"锭坯截面积(mm^2):\";}"
- ":button{key=\"bt1\";label = \"拾取面域>\";}}"
- ":row{:edit_box{key=\"eb2\";label=\"型材截面积(mm^2):\";}"
- ":button{key=\"bt2\";label = \"拾取面域>\";}}"
- ":row{:edit_box{key=\"eb3\";label=\"挤压比:\";}ok_cancel;}}")
- tmpf (xty-sys-makeFbylst
- (vl-filename-mktemp nil nil ".dcl")
- dcllst
- )
- dcl_id (load_dialog tmpf)
- *area1* (if (not *area1*)
- "201."
- *area1*
- )
- *area2* (if (not *area2*)
- "101."
- *area2*
- )
- area3 (rtos (/ (atof *area1*) (atof *area2*)) 2 6)
- callback 2
- )
- (vl-file-delete tmpf)
- (while (> callback 1)
- (new_dialog "ExtrusionRatio" dcl_id)
- (set_tile "eb1" *area1*)
- (set_tile "eb2" *area2*)
- (set_tile "eb3" area3)
- (action_tile "bt1" "(done_dialog 2)")
- (action_tile "bt2" "(done_dialog 3)")
- (setq callback (start_dialog))
- (cond ((= 2 callback) (do_bt1))
- ((= 3 callback) (do_bt2))
- )
- )
- (unload_dialog dcl_id)
- )
|