16
506
6
中流砥柱
本帖以下内容被隐藏保护;需要你回复后,才能看到!
使用道具 举报
0
13
5
初来乍到
8
9
3
;; *************************************************************** ;; pline path finder.lsp ;; Charles Alan Butler 07/08/2004 ;; Modified routine to find a path from picked start entity ;; to picked end entity. ;; ;; Returns the first path if it exist else nil, not the shortest path ;; Selects & highlites the path also ;; *************************************************************** ;shortcut (defun c:plp () (c:PlinePath)) ;;; *************************************************************** ;;; Original Routine ;;; ;;; ;; based on Inline.lsp by John Uhden ;;; ;; modified Joe Burke 5/15/03 ;;; ;; pick a line, arc or lwpline ;;; ;; creates a selection set of objects which meet end to end ;;; ;; only selects objects on the same layer as picked object ;;; ;; pass selection set to pedit join... ;;; ;;; *************************************************************** ;;=================================== ;; -==- ;;=================================== ;; Return (ename Startpt Endpt) (defun @arc (ent / e rp r ba ea p1 p2) (setq e (cdr (assoc -1 ent)) rp (cdr (assoc 10 ent)) r (cdr (assoc 40 ent)) ba (cdr (assoc 50 ent)) ea (cdr (assoc 51 ent)) p1 (trans (polar rp ba r) e 0) p2 (trans (polar rp ea r) e 0) ) (list e p1 p2) ) ;end ;; Return (ename Startpt Endpt) (defun @line (ent) (list (cdr (assoc -1 ent)) (cdr (assoc 10 ent)) (cdr (assoc 11 ent)) ) ) ;end ;; Return (ename Startpt Endpt) (defun @pline (ent / e) (setq e (cdr (assoc -1 ent))) (list e (car (getends e)) (cadr (getends e)) ) ) ;end ;; Add ent-> (ename Startpt Endpt) to list (defun @list (e / ent) (setq ent (entget e)) (cond ((= (cdr (assoc 0 ent)) "LINE") (setq sslist (cons (@line ent) sslist)) ) ((= (cdr (assoc 0 ent)) "ARC") (setq sslist (cons (@arc ent) sslist)) ) ((= (cdr (assoc 0 ent)) "LWPOLYLINE") (setq sslist (cons (@pline ent) sslist)) ) ) ) ;end ;;argument: an ename - returns: Start and End points as a list (defun getends (vobj / name stpt endpt) (if (= (type vobj) 'ename) (setq vobj (vlax-ename->vla-object vobj)) ) (and (setq name (vla-get-objectname vobj)) (cond ((vl-position name '("AcDbArc" "AcDbLine" "AcDbEllipse" "AcDbSpline" "AcDbPolyline" "AcDb2dPolyline" "AcDb3dPolyline" ) ) (setq stpt (vlax-curve-getstartpoint vobj)) (setq endpt (vlax-curve-getendpoint vobj)) ) ) ;cond ) ;and (list stpt endpt) ) ;end ;; get list of (ename startpt endpt) for picked ent (defun get:elst(ent) (cond ((= (cdr (assoc 0 ent)) "ARC") (setq ent (@arc ent)) ) ((= (cdr (assoc 0 ent)) "LINE") (setq ent (@line ent)) ) ((= (cdr (assoc 0 ent)) "LWPOLYLINE") (setq ent (@pline ent)) ) ) ent ); end defun ;; *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* ;; main function ;; *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* (defun c:plinepath (/ sslist elist ss ssres i e e2 found ent ent2 ok start end start2 end2 fuzz layer ssex typlst ) ;; Get the start object (if ; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv (and (cadr (ssgetfirst)) ;objects are selected