(defun test(/ z gd fw zz hmx hmn phmx phmn)
(setq fw (entsel "\n选择多段线:")) (setq fw (car fw))
(setq zz (entnext fw) hmx 0.0 hmn 9999999999.9) (while (/= (cdr (assoc 0 (entget zz))) "SEQEND") (setq gd (cdr(assoc 10 (entget zz))))
(setq z (nth 2 gd)
(if(> z hmx)(setq hmx z phmx gd))
(if(< z hmn)(setq hmn z phmn gd))
(setq zz (entnext zz)) )
(setq hmx (nth 2 phmx) phmx (vl-remove hmx phmx))
(setq hmn (nth 2 phmn) phmn (vl-remove hmn phmn))
(setq zz (distance phmn phmx) z (- hmx hmn))
(setq zz (/ z zz))
(princ "\n坡度=")(princ zz) )
看这样行吗? |