(defun c:fs_len2 (/		ept	      spt
		  ss		dist	      ldcl
		  var		lst	      nlen
		  fsxmlen2:act:get	      fsxmlen2:act:accept
		  fsxmlen2:dcl:show	      returnvar
		 )
  (setq
    ldcl '("len2"
	   (:DIALOG (initial_focus "v")
	    (LABEL "双向调节长度 @ fstl.ys168.com")
	    "spacer;"
	    (:BOXED_COLUMN
	     (LABEL "模式")
	     (:ROW
	      (:RADIO_BUTTON (KEY "de") (LABEL "差值") (VALUE "1"))
	      (:RADIO_BUTTON (KEY "p") (LABEL "百分比"))
	      (:RADIO_BUTTON (KEY "t") (LABEL "总长"))
	     )
	     "spacer;"
	    )
	    "spacer;"
	    (:ROW
	     (:EDIT_BOX (ALLOW_ACCEPT TRUE) (KEY "v") (LABEL "数值"))
	     (:BUTTON (FIXED_WIDTH TRUE) (KEY "cl") (LABEL "测量<"))
	    )
	    "spacer;"
	    "ok_cancel;"
	   )
	  )
  )
  (defun returnvar (/ md var)
    (setq var (distof (get_tile "v")))
    (foreach k '("de" "p" "t")
      (if (= "1" (get_tile k))
	(setq md k)
      )
    )
    (list md var)
  )
  (defun fsxmlen2:dcl:show ()
    (set_tile (car $fsxmlen2$) "1")
    (set_tile "v" (fsxm-number->string (cadr $fsxmlen2$)))
  )
  (defun fsxmlen2:act:accept (/ var)
    (setq var (cadr (returnvar)))
    (if	(or (null var) (= var 0))
      (alert "数值错了！")
      (return (setq $fsxmlen2$ (returnvar)))
    )
  )
  (defun fsxmlen2:act:cl ()
    (return (list "get" (returnvar)))
  )
  (setq var (fsxm-ldcl ldcl "fsxmlen2"))
  (cond	((null var))
	((= (car var) "get")
	 (setq dist (getdist "\n测量一个距离:"))
	 (or dist (fsxm-silenceexit))
	 (setq $fsxmlen2$ (list (caadr var) dist))
	 (c:fs_len2)
	)
	;;总长
	((= (car $fsxmlen2$) "t")
	 (while	(setq ss (ssget ":S" '((0 . "line,arc,ellipse"))))
	   (foreach en (fsxm-ss->enlist ss)
	     (setq nlen (- (cadr var) (fsxm-curve-length en)))
	     (command ".lengthen" "de" (* 0.5 nlen))
	     (setq spt (vlax-curve-getStartPoint en))
	     (setq ept (vlax-curve-getEndPoint en))
	     (command (list en (trans spt 0 1)))
	     (command (list en (trans ept 0 1)))
	     (command "")
	   )
	 )
	)
	;;差值
	((= (car $fsxmlen2$) "de")
	 (while	(setq ss (ssget ":S" '((0 . "line,arc,ellipse"))))
	   (command ".lengthen" "de" (cadr var))
	   (foreach en (fsxm-ss->enlist ss)
	     (setq spt (vlax-curve-getStartPoint en))
	     (setq ept (vlax-curve-getEndPoint en))
	     (command (list en (trans spt 0 1)))
	     (command (list en (trans ept 0 1)))
	   )
	   (command "")
	 )
	)
	;;百分比
	((= (car $fsxmlen2$) "p")
	 (while	(setq ss (ssget ":S" '((0 . "line,arc,ellipse"))))
	   (foreach en (fsxm-ss->enlist ss)
	     (setq nlen	(* 0.01
			   (- (cadr var) 100)
			   (fsxm-curve-length en)
			)
	     )
	     (command ".lengthen" "de" (* 0.5 nlen))
	     (setq spt (vlax-curve-getStartPoint en))
	     (setq ept (vlax-curve-getEndPoint en))
	     (command (list en (trans spt 0 1)))
	     (command (list en (trans ept 0 1)))
	     (command "")
	   )
	 )
	)
  )
  (princ)
)