114
1万
中流砥柱
(defun c:int_dist (/ *error* isCurveObj ss->list vlax-list->3D-point SortFromPt SortbyParam DIST ENT ILST LANG MA MI MPT OBJ PT SS TOBJ UFLAG X Y ) (vl-load-com) ;; Lee Mac ~ 04.03.10 (setq *doc (cond (*doc) ((vla-get-ActiveDocument (vlax-get-acad-object))))) (defun *error* (msg) (and uFlag (vla-EndUndoMark *doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")) ) ;_ or (princ) ) ;_ defun (defun isCurveObj (ent) (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-curve-getEndParam ) ;_ function (list ent) ) ;_ vl-catch-all-apply ) ;_ vl-catch-all-error-p ) ;_ not ) ;_ defun (defun ss->list (ss / i ent ObjLst) (setq i -1) (while (setq ent (ssname ss (setq i (1+ i)))) (setq ObjLst (cons (vlax-ename->vla-object ent) Objlst ) ;_ cons ) ;_ setq ) ;_ while ObjLst ) ;_ defun (defun vlax-list->3D-point (lst) (if lst (cons (list (car lst) (cadr lst) (caddr lst)) (vlax-list->3D-point (cdddr lst)) ) ;_ cons ) ;_ if ) ;_ defun (defun SortFromPt (pt lst) (vl-sort lst (function (lambda (a b) (< (distance a pt) (distance b pt) ) ;_ < ) ;_ lambda ) ;_ function ) ;_ vl-sort ) ;_ defun (defun SortByParam (ent lst) (vl-sort lst (function (lambda (a b) (< (vlax-curve-getParamatPoint ent a ) ;_ vlax-curve-getParamatPoint (vlax-curve-getParamatPoint ent b ) ;_ vlax-curve-getParamatPoint ) ;_ < ) ;_ lambda ) ;_ function ) ;_ vl-sort ) ;_ defun (while (progn (setq ent (car (entsel))) (cond ((eq 'ENAME (type ent)) (if (isCurveObj ent) (progn (vla-getBoundingBox (setq obj (vlax-ename->vla-object ent) ) ;_ setq 'Mi 'Ma ) ;_ vla-getBoundingBox (mapcar (function set) '(Mi Ma) (mapcar (function vlax-safearray->list ) ;_ function (list Mi Ma) ) ;_ mapcar