本帖最后由 yaojing38 于 2023-6-11 23:14 编辑
- ;测量曲线上两点间的路程长度.
- (defun C:qjcd (/ entName1 Pt1 Pt2 xLen st_pt end_pt pt_tmp l_ss PD pd1 obj)
- (vl-load-com)
- (setq entName1 (car (entselEx "\r请选择直线、圆弧、圆、多段线等曲线:" '((0 . "line,arc,circle,lwpolyline")))))
- (setq obj (vlax-ename->vla-object entName1))
- (setq PD (< (distance (vlax-curve-getStartPoint obj) (vlax-curve-getEndPoint obj)) 0.0001))
-
-
- (setq pt1 (getpoint "\n指定测量起点: ")
- pt2 (getpoint "\n指定测量终点: ")
-
- )
-
- (setq
- st_pt (vlax-curve-getStartPoint entName1)
- end_pt (vlax-curve-getEndPoint entName1)
- )
- (setq entName2 entName1)
-
-
- (if (> (vlax-curve-getParamAtPoint entName1 pt1) (vlax-curve-getParamAtPoint entName1 pt2))
- (setq pt_tmp pt2
- pt2 pt1
- pt1 pt_tmp)
- )
- (vl-cmdf "undo" "be")
- (vl-cmdf "_break" entName1 st_pt pt1)
- (vl-cmdf "_break" entName1 end_pt pt2)
- (vl-cmdf ".copy" entName1 "" '(0 0) '(0 0))
- (setq l_ss (entget (entlast)))
- (vl-cmdf "undo" "end")
- (vl-cmdf "undo" "")
- (entmake l_ss)
- (setq entName1 (entlast))
- (vla-put-Color (vlax-ename->vla-object entName1) 1)
- (redraw entName1 3)
- (initget 1 "T")
- (setq pd1 (getstring "\n[取反向距离(T)]: ") )
- (if (AND (or (= pd1 "t") (= pd1 "T")) PD)
- (setq xLen (- (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj)) (abs (- (vlax-curve-getDistAtPoint entName1 pt1)(vlax-curve-getDistAtPoint entName1 pt2)))))
- (setq xLen (abs (- (vlax-curve-getDistAtPoint entName1 pt1)(vlax-curve-getDistAtPoint entName1 pt2))))
- )
- (if (AND (or (= pd1 "t") (= pd1 "T")) PD)
- (progn
- (vl-cmdf "_erase" entName1 "")
- (if (> (vlax-curve-getParamAtPoint entName2 pt1) (vlax-curve-getParamAtPoint entName2 pt2))
- (setq pt_tmp pt2
- pt2 pt1
- pt1 pt_tmp)
- )
- (vl-cmdf "undo" "be")
- (vl-cmdf "_break" entName2 PT1 pt2 )
- ;(vl-cmdf "_break" entName1 end_pt pt1)
- (vl-cmdf ".copy" entName2 "" '(0 0) '(0 0))
- (setq l_ss (entget (entlast)))
- (vl-cmdf "undo" "end")
- (vl-cmdf "undo" "")
- (entmake l_ss)
- (setq entName2 (entlast))
- (vla-put-Color (vlax-ename->vla-object entName2) 1)
- (redraw entName2 3)
- (vl-cmdf "_erase" entName2)
- )
- )
- (vl-cmdf "_erase" entName1)
- (princ (strcat "\n测量结果:两点间曲线长度=" (rtos xLen 2 2)))
- (princ "\n路径检查:查看亮显区域,右键退出")
- (princ)
- )
你用原来命令QJCD ,提示取反不输入不取反 |