我有一个多年前写的基本代码。它根据用户输入绘制平面2d血管。我想修改代码,因此在开始时,当它要求用户以英寸为单位输入接缝到接缝的长度时,用户可以只输入以英寸为单位的尺寸,并正常运行代码,或者询问用户是否在(F)eet中。类似于“输入接缝到接缝的长度,单位为英寸或(F)eet”。非常感谢您的帮助。
- (defun c:vv ()
- (input)
- (compute)
- (draw)
- (whatif)(princ))
-
- (defun input ()
- (setvar "cmdecho" 0)
- (command "-units" "4" "" "" "" "" "")
- (setq vc (getdist "Enter vessel seam to seam length in inches..."))
- (setq vd (getreal "Enter vessel diameter in inches..."))
- (initget 1 "H V")(setq vo (getkword "Enter vessel orientation...(H or V) "))
- (setq vb (getint "How many shellbelts? "))
- (setq vs (getpoint "Select starting point..."))
- (princ))
- ;;;compute
- (defun compute ()
- (setq vc1 (/ vc 2))
- (setq vc2 (+ vc1 2))
- (setq vcc (rtos vc 4 4))
- (setq vcc1 (rtos vc1 4 4))
- (setq vcc2 (rtos vc2 4 4))
- ;shellbelts
- (setq vc3 (- vc 12))
- (setq vb1 (- vb 1))
- (setq vc4 (/ vc3 vb1))
- (princ))
-
-
- ;;;draw
- (defun draw ()
- (setq vss (strcat "@" vcc ",0"))
- (command "layer" "n" "vessel" "s" "vessel" "")
- (command "line" vs vss "")
- ;;offset
- (setq os (ssget "l"))
- (command "offset" vd os vs "")
- (command "insert" "vcap" vs vd "" "")
-
- ;;;mirror
- (setq mc (ssget "l"))
- (setq vss1 (strcat "@" vcc1 ",0"))
- (setq vss2 (strcat "@" "0," vcc2))
- (command "mirror" mc "" vss1 vss2 "n")
- (command "layer" "n" "shellbelt" "s" "shellbelt" "")
- (command "insert" "shellbelt" vs vd "" "")
- (command "array" "l" "" "r" "" vb vc4)
- (setq lay_name2 "shellbelt")
- (setq ss1 (ssget "X" (list (cons 8 lay_name2))))
- (command "move" ss1 "" "0,0" "@6,0")
- (setq lay_name1 "vessel")
- (command "-units" "2" "" "" "" "" "")
- (setq ss2 (ssget "X" (list (cons 8 lay_name1))))
- (princ))
- (defun whatif ()
- (if (= "V" vo)
- (command "rotate" ss1 ss2 "" vs "90"))
- (princ))
|