- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am trying to get AutoCAD to draw a great many circles of differing radii with the centre point of the circles at a common foci point along the semi-major axis of an ellipse. The radius of all the circles are such that they will intersect the ellipse at some point.
The XYZ coordinates of these intersections are ultimately what I want to extract using AutoCADs data extraction utility.
I have successfully used Lee Macs intersections Lisp routine to draw ‘points’ at these intersections however it doesn’t like it when I have thousands of circles….it just crashes.
;; Intersections in Set - Lee Mac ;; Returns a list of all points of intersection between all objects in a supplied selection set. ;; sel - [sel] Selection Set (defun LM:intersectionsinset ( sel / id1 id2 ob1 ob2 rtn ) (repeat (setq id1 (sslength sel)) (setq ob1 (vlax-ename->vla-object (ssname sel (setq id1 (1- id1))))) (repeat (setq id2 id1) (setq ob2 (vlax-ename->vla-object (ssname sel (setq id2 (1- id2)))) rtn (cons (LM:intersections ob1 ob2 acextendnone) rtn) ) ) ) (apply 'append (reverse rtn)) ) (defun LM:intersections ( ob1 ob2 mod / lst rtn ) (if (and (vlax-method-applicable-p ob1 'intersectwith) (vlax-method-applicable-p ob2 'intersectwith) (setq lst (vlax-invoke ob1 'intersectwith ob2 mod)) ) (repeat (/ (length lst) 3) (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn) lst (cdddr lst) ) ) ) (reverse rtn) ) (defun c:interset ( / sel ) (if (setq sel (ssget)) (foreach pnt (LM:intersectionsinset sel) (entmake (list '(0 . "POINT") (cons 10 pnt))) ) ) (princ) ) (vl-load-com) (princ)
Since I don’t ultimately need the circles (only the intersection points they make with the ellipse) I thought I would try using the lisp below to delete the last circle drawn (actually the second to last entity after the ‘point’) which seems to work if I run it manually. This way, the first lisp routine only needs to find one intersection each time.
(defun countback(steps / ms) (vl-load-com) (setq ms (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (vlax-vla-object->ename (vla-item ms (- (vla-get-count ms) steps))) ) (command ".erase" (countback 2) "") (princ)
The trouble is I am using a copy paste method from excel to the command line to draw the circles. I thought I would try and also call the above routines from the spreadsheet but I can’t seem to get it to work, it will draw the points at the intersections but then won’t delete the last circle drawn.
Since I’m no expert in Lisp and I found both of these routines on the web, can someone possibly a) help me combine them into 1 lisp adding the erase command to delete the 2nd to last entity (countback 2) or b) suggest a better way of doing this whole process?
Thanks in advance
Rob
Solved! Go to Solution.