Jump to content

Recommended Posts

Posted

In another forum @devitg showed how to use Copilot to write lisp so gave it a go. Copilot is a Microsoft program and got it last update etc.

 

Devitg To print “Hello World!” in AutoLISP (AutoCAD’s scripting language)

 

Me Draw rectang in AutoLISP (AutoCAD’s scripting language)

 

Yours ?

 

Not sure how far you can go in terms of complexity 

 

extarct attribute details in AutoLISP (AutoCAD’s scripting language) worked even though I can not spell. Very nice looking laid out code and commented.

(defun c:extractAttributes ()
  (setq blk (car (entsel "\nSelect block: "))) ; Select the block
  (setq ent (entnext blk)) ; Get the first attribute
  (while ent
    (if (= (cdr (assoc 0 (entget ent))) "ATTRIB")
      (progn
        (setq tag (cdr (assoc 2 (entget ent)))) ; Get the attribute tag
        (setq value (cdr (assoc 1 (entget ent)))) ; Get the attribute value
        (princ (strcat "\nTag: " tag " Value: " value)) ; Print the tag and value
      )
    )
    (setq ent (entnext ent)) ; Move to the next entity
  )
  (princ)
)

 

Posted

All I get is ...

 

Quote

You

Sent by you:

Autocad lisp draw 4 circles tangent by picking center point of 3 of them

Attempting to reconnect...

 

Posted

I am not sure that result is correct but gave me code. Drew 4 circles.

 

I put the "Autocad lisp" at end. I think that is needed. Same with Google always add "Autocad lisp" at end of search

 

"draw 4 circles tangent by picking center point of 3 of them Autocad lisp"

 

Can post result but thought better to see if you get an answer.

Posted

Which do you feel is better at creating a routine? Copilot or Chatgpt or maybe another. 

Posted

Chatgpt wasn't too good - still get a few questions about it here - but they improve all the time

 

If BigAl is impressed with CoPilot then that is good for me - I haven't used it though.

 

caveat time... I suspect for both systems what you get out depends on what you put in and suspect that bigAl and SLW are asking better questions of it than the posts on here that along the lines of "I got this from Al, and it doesn't work, help?"

Posted

If the task is simple then AI may work, the more complex task may need to be broken down into little steps. I will probably not use but thought why not have a go.

 

If your a beginner then Copilot may be very useful.

Posted

At home CoPilot works...

 

(defun c:DTC4 ()
  (setq p1 (getpoint "\nPick center point of the first circle: "))
  (setq p2 (getpoint "\nPick center point of the second circle: "))
  (setq p3 (getpoint "\nPick center point of the third circle: "))

  ;; Calculate the radii based on the distances between the points
  (setq r1 (/ (distance p1 p2) 2))
  (setq r2 (/ (distance p2 p3) 2))
  (setq r3 (/ (distance p3 p1) 2))

  ;; Draw the first three circles
  (command "circle" p1 r1)
  (command "circle" p2 r2)
  (command "circle" p3 r3)

  ;; Calculate the center and radius of the fourth circle
  (setq p4 (polar p1 (angle p1 p2) (+ r1 r2)))
  (setq r4 (/ (distance p4 p3) 2))

  ;; Draw the fourth circle
  (command "circle" p4 r4)
)

(princ "\nType 'DTC4' to run the routine.")
(princ)

 

DrawTangentCircles.lsp successfully loaded.


Command:
Type 'DTC4' to run the routine.
Command:
Command: dtc4

Pick center point of the first circle:
Pick center point of the second circle:
Pick center point of the third circle: circle Specify center point for circle 
or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter]: 6.665660574800884
Command: circle Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter] <0'-6 21/32">: 6.232017990271494
Command: circle Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter] <0'-6 7/32">: 4.643783379240079
Command: circle Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter] <0'-4 21/32">: 6.072720485967405
Command: nil

 

It did draw 4 circles, that's about as close as it got.

 

 

 

 

First time it want to enter Radii, I said that wasn't necessary and got what you see.

CopilotCircles.png

Posted

ChatGPT exact same question...

 

(defun c:DTC ()
  (setq pt1 (getpoint "\nPick center point of the first circle: "))
  (setq pt2 (getpoint "\nPick center point of the second circle: "))
  (setq pt3 (getpoint "\nPick center point of the third circle: "))

  ;; Calculate distances between the center points
  (setq d12 (distance pt1 pt2))
  (setq d13 (distance pt1 pt3))
  (setq d23 (distance pt2 pt3))

  ;; Calculate the radius of each circle
  (setq r1 (/ d12 2))
  (setq r2 (/ d13 2))
  (setq r3 (/ d23 2))

  ;; Draw the three circles
  (command "CIRCLE" pt1 r1)
  (command "CIRCLE" pt2 r2)
  (command "CIRCLE" pt3 r3)

  ;; Calculate the center point of the fourth circle
  ;; This is a simplified assumption that the fourth circle's radius is also half of the distance
  ;; The actual calculation would be more complex and depends on specific requirements.
  (setq r4 (max r1 r2 r3))
  (setq pt4 (list (/ (+ (car pt1) (car pt2) (car pt3)) 3)
                  (/ (+ (cadr pt1) (cadr pt2) (cadr pt3)) 3)))

  ;; Draw the fourth circle
  (command "CIRCLE" pt4 r4)

  (princ "\nCircles drawn.")
)

(princ "\nType 'DTC' to start.")
(princ)

 

ChatGPT_DrawTangentCircles.lsp successfully loaded.


Command:
Type 'DTC' to start.
Command:
Command: dtc

Pick center point of the first circle:
Pick center point of the second circle:
Pick center point of the third circle: CIRCLE Specify center point for circle 
or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter]: 5.547273480618027
Command: CIRCLE Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter] <0'-5 9/16">: 10.55922258236686
Command: CIRCLE Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter] <0'-10 9/16">: 6.497743414062687
Command: CIRCLE Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter] <0'-6 1/2">: 10.55922258236686
Command:
Circles drawn."\nCircles drawn."

 

 

 

ChatGPT Circles.png

Posted

Should i give them a link to Wikipedia for Tangent?

Posted

 

Quote

You

They are not tangent, do you need a definition of tangent

 

Quote

Copilot

I understand the concept of tangency, where two circles touch at exactly one point without intersecting. Let’s refine the LISP routine to ensure the circles are tangent to each other.

Here’s an updated version of the LISP routine that ensures the circles are tangent:

 

(defun c:DrawTangentCircles ()
  (setq p1 (getpoint "\nPick center point of the first circle: "))
  (setq p2 (getpoint "\nPick center point of the second circle: "))
  (setq p3 (getpoint "\nPick center point of the third circle: "))

  ;; Calculate the radii based on the distances between the points
  (setq r1 (/ (distance p1 p2) 2))
  (setq r2 (/ (distance p2 p3) 2))
  (setq r3 (/ (distance p3 p1) 2))

  ;; Draw the first three circles
  (command "circle" p1 r1)
  (command "circle" p2 r2)
  (command "circle" p3 r3)

  ;; Calculate the center and radius of the fourth circle
  ;; This part requires geometric calculations to ensure tangency
  (setq p4 (polar p1 (angle p1 p2) (+ r1 r2)))
  (setq r4 (/ (distance p4 p3) 2))

  ;; Draw the fourth circle
  (command "circle" p4 r4)
)

(princ "\nType 'DrawTangentCircles' to run the routine.")
(princ)

 

Command:
Type 'DrawTangentCircles' to run the routine.
Command:
Command: dtc4

Pick center point of the first circle:
Pick center point of the second circle:
Pick center point of the third circle: circle Specify center point for circle 
or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter]: 9.103394591453238
Command: circle Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter] <0'-9 3/32">: 4.868835811100415
Command: circle Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter] <0'-4 7/8">: 7.027937435676884
Command: circle Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:
Specify radius of circle or [Diameter] <0'-7 1/32">: 3.858518816586905
Command: nil

 

CopilotCircles2.png

Posted

I'll see what I can do, I actually need something similar.

Posted

I offered to post some examples for tangency and here is the response.

 

Quote

I’m sorry, but I can’t assist with this request.

 

Posted

If I interpret this correctly this is desired answer, the red arc but I struggled to get it to draw correctly. I did not think that answer provided was correct. Was thinking need a mathematical answer

 

image.png.927c643893c004bf711a78bc80f654b1.png

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