Lisp: how to select all circle
I'd like to know a code in LISP for selecting all circles inside a polygon I made and center them in the centre of the same polygon. Try this and let me know .(defun c:Test (/ s sn l i d lst p a b j k ss) ;; Tharwat 15. may. 2014 ;; (princ "\n Select a 2Dpolyline ...") (if (setq s (ssget "_+.:S:E" '((0 . "LWPOLYLINE")))) (progn (setq l (vlax-curve-getdistatparam (setq sn (ssname s 0)) (fix (vlax-curve-getendparam sn))) i (/ l 1000.) d i ) (repeat 1000 (setq lst (cons (vlax-curve-getpointatdist sn i) lst) i (+ i d) ) ) (setq p (mapcar 'cdr (vl-remove-if-not '(lambda (x) (eq (car x) 10)) (entget sn))) a (mapcar 'car p) b (mapcar 'cadr p) j (/ (apply '+ a) (length a)) k (/ (apply '+ b) (length b)) ) (if (setq ss (ssget "_CP" lst '((0 . "CIRCLE")))) ((lambda (x / n e) (while (setq n (ssname ss (setq x (1+ x)))) (if (vlax-write-enabled-p (vlax-ename->vla-object n)) (entmod (subst (cons 10 (list j k 0.)) (assoc 10 (setq e (entget n))) e)) ) ) ) -1 ) ) ) ) (princ))(vl-load-com) works great thank you but can you write after each code line what you did there so i can understand it? You're welcome .
It is hard to explain everything in the routine but if you have any specific question , I can explain it for you . Well i cant really understand much, i was thinking to say like
: here you check if the centre of circle is in polygon
; here you move the centre to the centre of polygon ...
a few comentaries would make the understanding of the code way more easy also the meaning of each charater: s sn l i d lst p a b j k ss
What are they Okay ,
First we select a polyline then write the codes to make a list of point along the selected polyline so after that we can a selection set with the help with these point to select only circle as shown in the feed code for the ssget function , so if circles found we get the centeriod point of the polyline then update the center of each circle to that point .
That's it These called local variables . yeah i'd like to know which each local variable means....
Read THIS about variables .
页:
[1]
2