Jump to content

Recommended Posts

Posted

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.

  • Replies 34
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    11

  • alanjt

    9

  • dig

    9

  • ReMark

    4

Top Posters In This Topic

Posted Images

Posted

What do you mean by 'interconnects'? Draw a line between the centres?

Posted

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.

Posted

@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.

Posted

Are you trying to connect each circle with a tangent line?

 

FYI: A picture is worth a thousand words. :roll:

Posted

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?

Posted

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?

Posted
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? :lol:

Posted

Obviously I expect too much of people. I'll have to consider lowering my standards.:lol:

Posted

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.

Posted
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.

Posted

Blessed are those who run in circles for they shall be called Big Wheels.o:)

Posted

Am I off the mark?

 

TanTan.gif

 

 

(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))
   )
 )
)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...