114
1万
中流砥柱
使用道具 举报
8
248
245
初来乍到
(defun C:TEST (/ Dx Dy Lp List_vert_poly list_p_int P_center dist) (prompt "\nSelect Polyline: ") (setq POLY_vl (vlax-ename->vla-object (ssname (ssget ":S" '((0 . "POLYLINE,LWPOLYLINE"))) 0))) (Vert_poly) (grid_1) (Point_int) (Point_center) (repeat 3 (grid_2) (Point_center) ) (entmake (list (cons 0 "CIRCLE") (cons 8 (getvar "clayer")) (cons 10 P_center) (cons 40 dist) ) ) (princ)); Returns a list of polyline vertices(defun Vert_poly (/ n_par pt) (setq list_vert_poly nil) (setq n_par (fix (vlax-curve-getendparam POLY_vl))) (repeat n_par (setq pt (vlax-curve-getpointatparam POLY_vl (setq n_par (1- n_par)))) (setq list_vert_poly (cons pt list_vert_poly)) (if (/= (last pt) 0.0) (progn (alert (strcat "Invalid Object Selected" "\nz-coordinate vertices not = 0.0")) (exit) ) ) )); Returns a grid of points within the BoundingBox of the selected poly(defun grid_1 (/ P1_ P2_ n P> step1) (setq step1 60) (vla-getboundingbox POLY_vl 'p1 'p2) (setq P1_ (vlax-safearray->list p1)) (setq P2_ (vlax-safearray->list p2)) (setq P1_ (list (car P1_) (cadr P1_))) (setq P2_ (list (car P2_) (cadr P2_))) (setq Dx (/ (- (car P2_) (car P1_)) step1)) (setq Dy (/ (- (cadr P2_) (cadr P1_)) step1)) (setq n 0) (setq P> P1_) (setq Lp (list P1_)) (repeat (* (1+ step1) step1) (setq P> (list (+ (car P>) Dx) (cadr P>))) (setq Lp (cons P> Lp)) (setq n (1+ n)) (if (= n step1) (progn (setq n 0) (setq P1_ (list (car P1_) (+ (cadr P1_) Dy))) (setq P> P1_) (setq Lp (cons P> Lp)) ) ) )); Returns a grid of dots around the center point (provisional)(defun grid_2 (/ P1_ step2 P> n) (setq step2 30) (setq list_p_int nil) (setq P1_ (list (- (car P_center) Dx) (- (cadr P_center) Dy))) (setq Dx (/ (* 2 Dx) step2)) (setq Dy (/ (* 2 Dy) step2)) (setq n 0) (setq P> P1_) (setq list_p_int (list P1_)) (repeat (* (1+ step2) step2) (setq P> (list (+ (car P>) Dx) (cadr P>))) (setq list_p_int (cons P> list_p_int)) (setq n (1+ n)) (if (= n step2) (progn (setq n 0) (setq P1_ (list (car P1_) (+ (cadr P1_) Dy))) (setq P> P1_) (setq list_p_int (cons P> list_p_int)) ) ) )); Returns the list of points inside the polyline(defun Point_int (/ P_distant n Pr cont attr p# Pa Pa_ Pb ) (setq P_distant (polar (car Lp) 0 10000000)) (setq list_p_int nil) (repeat (setq n (length Lp)) (setq Pr (nth (setq n (1- n)) Lp)) (setq cont -1) (setq attr 0) (setq p# nil) (setq Pa (nth (setq cont (1+ cont)) list_vert_poly)) (setq Pa_ Pa) (repeat (length list_vert_poly) (setq Pb (nth (setq cont (1+ cont)) list_vert_poly)) (if (= cont (length list_vert_poly)) (setq Pb Pa_)) (setq P# (inters Pa Pb Pr P_distant)) (if (/= P# nil) (setq attr (1+ attr))) (setq Pa Pb)