dig Posted May 22, 2010 Posted May 22, 2010 Hi !I'm not sure if that's the right section to post my issue but i'll write it anyway.I'm newbie when we are talking about AutoCad,Lisp stuff. So my problem sounds like that:I have to generate a Lisp function which interconnects all my circles from model space.That's it. Can anybody help me with this? Thank you. Quote
Lee Mac Posted May 23, 2010 Posted May 23, 2010 What do you mean by 'interconnects'? Draw a line between the centres? Quote
Tankman Posted May 23, 2010 Posted May 23, 2010 Welcome to the forums dig, enjoy and learn a bit during your visits. Where are you posting from? I think Lee Mac hit the nail on the head, "Draw a line between the centers?" I don't know of such a lisp but, if anyone is more qualified then Lee Mac I, for one, would like to see his work. I'm goin' to follow this post to see what the troops come up with. Quote
dig Posted May 23, 2010 Author Posted May 23, 2010 @Lee Mac What i need is: drawing a line that connects borders of the circles,not centers. @Tankman Thank you !I'm posting from Romania. @Alanjt The last example seems better than the first,but as i said,the lines must connect the borders not centers.Anyway giving me the code for the last exemple would be great. Thank you. Quote
alanjt Posted May 23, 2010 Posted May 23, 2010 Are you trying to connect each circle with a tangent line? FYI: A picture is worth a thousand words. Quote
ReMark Posted May 23, 2010 Posted May 23, 2010 Wouldn't connecting circles via tangent lines require the user to be more precise with their picks? I line could be tangent to a circle in any number of places right? Quote
ReMark Posted May 23, 2010 Posted May 23, 2010 It might be helpful, as you point out Alan, if the OP gave us an idea of the number and configuration of the circles. One other thing he fails to mention is if all the circles are the same size or do they vary? Quote
alanjt Posted May 23, 2010 Posted May 23, 2010 It might be helpful, as you point out Alan, if the OP gave us an idea of the number and configuration of the circles. One other thing he fails to mention is if all the circles are the same size or do they vary? Divulging useful information? You must be joking? Quote
ReMark Posted May 23, 2010 Posted May 23, 2010 Obviously I expect too much of people. I'll have to consider lowering my standards. Quote
dig Posted May 23, 2010 Author Posted May 23, 2010 I can't give you a picture because i don't have enough posts to do it. Let's see:The result should look like the one in the alanjt's 5th post,but the lines inside the circles should not be visible.That's all. Thank you. Quote
alanjt Posted May 23, 2010 Posted May 23, 2010 I can't give you a picture because i don't have enough posts to do it. Let's see:The result should look like the one in the alanjt's 5th post,but the lines inside the circles should not be visible.That's all. Thank you. 5th post? All I did was connect a group of circles (by insertion) with lines. If the lines were removed, you'd just have a bunch of random circles. Quote
alanjt Posted May 23, 2010 Posted May 23, 2010 http://www.cadtutor.net/forum/showthread.php?t=46891&page=2 http://www.cadtutor.net/forum/showthread.php?t=42954 Quote
ReMark Posted May 23, 2010 Posted May 23, 2010 Blessed are those who run in circles for they shall be called Big Wheels. Quote
Lee Mac Posted May 23, 2010 Posted May 23, 2010 Am I off the mark? (defun c:cc ( / ent cen rad gr code data d ang tan iAng tmp ) ;; © Lee Mac ~ 23.05.10 (if (setq ent (SelectifFoo (lambda ( x ) (eq "CIRCLE" (cdr (assoc 0 (entget x))))) "\nSelect First Circle: " ) ) (progn (setq cen (trans (dxf 10 ent) 0 1) rad (dxf 40 ent)) (princ "\nSelect Next Circle: ") (while (progn (setq gr (grread t 13 2) code (car gr) data (cadr gr)) (redraw) (cond ( (and (= 5 code) (listp data)) (setq d (distance cen data) ang (angle cen data)) (if (< rad d) (progn (setq tan (sqrt (- (* d d) (* rad rad))) iAng (atan tan rad)) (grvecs (cons -3 (list (polar cen (+ ang iAng) rad) data (polar cen (- ang iAng) rad) data ) ) ) ) ) t ) ( (and (= 3 code) (listp data)) (if (and (setq tmp (car (nentselp data))) (eq "CIRCLE" (cdr (assoc 0 (entget tmp)))) (CircleTangents ent tmp)) (setq ent tmp cen (trans (dxf 10 tmp) 0 1) rad (dxf 40 tmp)) ) t ) ) ) ) (redraw) ) ) (princ) ) (defun SelectifFoo ( foo str / sel ent ) ;; © Lee Mac ~ 23.05.10 (while (progn (setq sel (entsel str)) (cond ( (vl-consp sel) (if (not (foo (setq ent (car sel)))) (princ "\n** Invalid Object Selected **") ) ) ) ) ) ent ) (defun Line ( p1 p2 ) (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2) ) ) ) (defun dxf ( code e ) (cdr (assoc code (entget e))) ) (defun CircleTangents ( cir1 cir2 / c1 c2 r1 r2 d delta ang tan iAng ) ;; © Lee Mac ~ 23.05.10 (setq c1 (dxf 10 cir1) c2 (dxf 10 cir2) r1 (dxf 40 cir1) r2 (dxf 40 cir2)) (setq d (distance c1 c2) delta (- r1 r2) ang (angle c1 c2)) (if (< (abs delta) d) (progn (setq tan (sqrt (- (* d d) (* delta delta))) iAng (atan tan delta)) (Line (polar c1 (+ ang iAng) r1) (polar c2 (+ ang iAng) r2)) (Line (polar c1 (- ang iAng) r1) (polar c2 (- ang iAng) r2)) ) ) ) Quote
alanjt Posted May 23, 2010 Posted May 23, 2010 HaHa, very nice work. Two EXCELLENT uses of GrRead this weekend. http://www.cadtutor.net/forum/showpost.php?p=328770&postcount=31 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.