Circle (lisp) routine in autocad

To chat about anything else.
Post Reply
Toulinash
I have made 90-100 posts
I have made 90-100 posts
Posts: 95
Joined: Thu Feb 09, 2012 3:01 pm
12
Full Name: Cornelis Kolbeek
Company Details: 3dszkennelés
Company Position Title: Scan specialist
Country: Netherlands-Hungary
Linkedin Profile: Yes
Location: NL

Circle (lisp) routine in autocad

Post by Toulinash »

Hey guys,

I'm looking for a circle routine that computes a circle through several points.
Here's the twist though: I need the circle to have a certain diameter/radius.
Preferably I'd like the routine to compute the circle, and give me an deviation towards the radius per point.

Kind regards,

CK
Oatfedgoat
Honorary Member
Honorary Member
Posts: 1047
Joined: Mon Oct 06, 2008 8:31 pm
15
Full Name: Matthew McCarter
Company Details: Costain
Company Position Title: BIM Manager
Country: England
Linkedin Profile: Yes
Has thanked: 5 times
Been thanked: 4 times

Re: Circle (lisp) routine in autocad

Post by Oatfedgoat »

I know it's not quite what you are looking for, but it is not uncommon in the rail industry (I'm assuming tunneling as well) to require a circularity check on a profile of a tunnel.
We wrote an internal macro for Excel to do this based upon data exported from our mobile scanning systems.

I wouldnt be suprised if a similar macro is not available to download somewhere online.
gareth10
I have made <0 posts
I have made <0 posts
Posts: 8
Joined: Tue Oct 12, 2010 11:18 am
13
Full Name: Gareth Edwards
Company Details: Cadplan
Company Position Title: Director
Country: UK
Linkedin Profile: No

Circle (lisp) routine in autocad

Post by gareth10 »

Not sure I fully understand. Am I right that you want to input a radius or diameter of a circle, then pick a number of points on the screen (or inputed) and then get a best fit for a drawn circle?

Cadplan
Toulinash
I have made 90-100 posts
I have made 90-100 posts
Posts: 95
Joined: Thu Feb 09, 2012 3:01 pm
12
Full Name: Cornelis Kolbeek
Company Details: 3dszkennelés
Company Position Title: Scan specialist
Country: Netherlands-Hungary
Linkedin Profile: Yes
Location: NL

Re: Circle (lisp) routine in autocad

Post by Toulinash »

Correct,
Right now I use the attached routine.
But for example with flanges, they are machined, so the radius is quite precise.
Therefore I want to eliminate the deviation, created either by the surveyor or total station, by telling Autocad what radius it should be.

Cheers!
You do not have the required permissions to view the files attached to this post.
gareth10
I have made <0 posts
I have made <0 posts
Posts: 8
Joined: Tue Oct 12, 2010 11:18 am
13
Full Name: Gareth Edwards
Company Details: Cadplan
Company Position Title: Director
Country: UK
Linkedin Profile: No

Re: Circle (lisp) routine in autocad

Post by gareth10 »

I think I see what you are trying to achieve and a routine can be made to pick all the points and to draw a circle of a certain radius/diameter. The difficulty it seems to me might be how to position the circle to create the best fit with the points.
User avatar
Phill
V.I.P Member
V.I.P Member
Posts: 653
Joined: Wed Feb 06, 2008 7:19 am
16
Full Name: Phillip Nixon
Company Details: SKM
Company Position Title: Surveyor
Country: Australia
Location: Sydney
Has thanked: 7 times
Been thanked: 45 times

Re: Circle (lisp) routine in autocad

Post by Phill »

CK

See attached. BTW least squares really messes with my brain. Please dont ask for this in 3d, I have no idea how those Cyclone gurus do a fit to cloud cyclinder. I have attached the pdf I based the calcs on and my answer matches the example data. I have got the lisp to calc the center of a nominal circle to fit the points but made the text differences from the user inputed radius (the calced best fit radius is printed as Nominal radius on the command prompt). I am assuming that the center of a best fit circle would be the same as if it were fitting a given radius to the points.

Hope this is what you were looking for. If it's useful you owe me a beer or two. If you edit it to make it better, repost so others can use it as well.

Cheers

Phill
You do not have the required permissions to view the files attached to this post.
Toulinash
I have made 90-100 posts
I have made 90-100 posts
Posts: 95
Joined: Thu Feb 09, 2012 3:01 pm
12
Full Name: Cornelis Kolbeek
Company Details: 3dszkennelés
Company Position Title: Scan specialist
Country: Netherlands-Hungary
Linkedin Profile: Yes
Location: NL

Re: Circle (lisp) routine in autocad

Post by Toulinash »

Hey Phill, thanks!
I'm in the field right now so I can't check it out.

I think by now I owe you a crate already. :D

Cheers!

CK
User avatar
FritjofS
I have made <0 posts
I have made <0 posts
Posts: 4
Joined: Tue May 21, 2013 5:54 pm
10
Full Name: Fritjof Andre Skaar
Company Details: Anko AS
Company Position Title: Engineer
Country: Norway
Skype Name: fritjofskaar
Linkedin Profile: Yes

Circle (lisp) routine in autocad

Post by FritjofS »

If you get your hands on the old Leica program calles AXYZ, you can calculate circles with a given radius. I always use this program when measuring spools and flanges. This program also include many other types of geometry calculation.
Andrew
I have made 10-20 posts
I have made 10-20 posts
Posts: 11
Joined: Mon Dec 19, 2011 1:44 pm
12
Full Name: Andrew Softley
Company Details: Laing ORourke
Company Position Title: Project Land Surveyor
Country: UK
Linkedin Profile: No

Re: Circle (lisp) routine in autocad

Post by Andrew »

Thanks Phil. This is very useful. I had a similar least squares routine that I somehow lost.

I've tweaked it slightly to draw the best-fit circle using the design radius and also output to 4dp, as that suits how I work. As it may be of use to others, here it is:

Code: Select all

(PRINC "\nFit circle to points Version 1.0, type FC2P to run")

(DEFUN C:FC2P ( /  )
  
 
(SETQ aws (SSGET  '((0 . "POINT"))))

  (SETQ POINTLIST NIL)
  (SETQ COUNT 0)
  ;CREATE POINT LIST
(REPEAT (SSLENGTH aws)
(SETQ P1 (CDR(ASSOC 10 (ENTGET (SSNAME aws COUNT)))))
  (SETQ P1 (TRANS P1 1 0))
(SETQ POINTLIST (APPEND POINTLIST P1))
(SETQ COUNT (+ COUNT 1))
); ende repeat

  ;GET SUM AND AVERAGE FOR U,V VALUES
(SETQ SUMX 0)
  (SETQ SUMY 0)
  (SETQ COUNT 0)
  (SETQ N (/ (LENGTH POINTLIST) 3))
  (REPEAT N

  (SETQ X (NTH COUNT POINTLIST))
  (SETQ COUNT (+ COUNT 1))
  (SETQ Y (NTH COUNT POINTLIST))
  (SETQ COUNT (+ COUNT 1))
  (SETQ COUNT (+ COUNT 1))
  (SETQ SUMX (+ SUMX X))
  (SETQ SUMY (+ SUMY Y))
 )

  (SETQ AVGX (/ SUMX N))
  (SETQ AVGY (/ SUMY N))

  ;CREATE UVLIST WITH MULTIPLES AND SUMS
  (SETQ UVLIST NIL)
  (SETQ SUU 0
	SVV 0
	SUV 0
	SUUU 0
	SVVV 0
	SUVV 0
	SVUU 0
	)
  

  (SETQ COUNT 0)
  (REPEAT N
    (SETQ U (- (NTH  COUNT POINTLIST) AVGX))
    (SETQ COUNT (+ COUNT 1))
    (SETQ V (- (NTH  COUNT POINTLIST) AVGY))
    (SETQ COUNT (+ COUNT 1))
    (SETQ COUNT (+ COUNT 1))
    (SETQ UU (* U U))
    (SETQ VV (* V V))
    (SETQ UV (* U V))
    (SETQ UUU (* U U U))
    (SETQ VVV (* V V V))
    (SETQ UVV (* U V V))
    (SETQ VUU (* V U U))
    (SETQ SUU (+ SUU UU))
    (SETQ SVV (+ SVV VV))
    (SETQ SUV (+ SUV UV))
    (SETQ SUUU (+ SUUU UUU))
    (SETQ SVVV (+ SVVV VVV))
    (SETQ SUVV (+ SUVV UVV))
    (SETQ SVUU (+ SVUU VUU))
    )

  

  ;CREATE A MATRIX
  (SETQ A11 SUU)
  (SETQ A12 SUV)
  (SETQ A21 SUV)
  (SETQ A22 SVV)

  ;CREATE B MATRIX
  (SETQ B1 (/ (+ SUUU SUVV) 2))
  (SETQ B2 (/ (+ SVVV SVUU) 2))

  ;CREATE ATA
  (SETQ ATA11 (+ (* A11 A11) ( * A12 A21)))
  (SETQ ATA12 (+ (* A11 A12) ( * A12 A22)))
  (SETQ ATA21 (+ (* A21 A11) ( * A22 A21)))
  (SETQ ATA22 (+ (* A21 A12) ( * A22 A22)))

  ;DETERMINE DETERMINANT
(SETQ DET (- (* ATA11 ATA22) (* ATA12 ATA21)))
  (SETQ DET (/ 1 DET))
  (SETQ INV11 (* -1 ( * DET ATA22)))
  (SETQ INV12 (* -1(* (* DET ATA12) -1)))
  (SETQ INV21 (* -1(* (* DET ATA21) -1)))
  (SETQ INV22 (* -1(* DET ATA11)))

  ;CREATE ATB
  (SETQ ATB1 (+ (* A11 B1) (* A12 B2)))
  (SETQ ATB2 (+ (* A21 B1) (* A22 B2))) 
 
  ;CREATE X

  (SETQ X1 (+ (* INV11 ATB1) (* INV12 ATB2)))
  (SETQ X2 (+ (* INV21 ATB1) (* INV22 ATB2)))

  (SETQ CX (+ (* X1 -1) AVGX))
  (SETQ CY (+ (* X2 -1) AVGY))

  (COMMAND "POINT" (LIST CX CY))
  (SETQ NRAD (SQRT (+ (* X1 X1) (* X2 X2) (/ (+ SUU SVV) N))))

	(PRINC (STRCAT "\nNominal Radius " (RTOS NRAD 2 4)))
  (SETQ RAD (GETREAL "\nDesign Radius: "))
  
  (COMMAND "CIRCLE" (LIST CX CY) RAD)
 
  (SETQ COUNT 0)
  (REPEAT (SSLENGTH aws)
(SETQ P1 (CDR(ASSOC 10 (ENTGET (SSNAME aws COUNT)))))
(SETQ DIFF (- RAD (DISTANCE P1 (LIST CX CY))))
    (COMMAND "TEXT" P1 "0.025" "90" (RTOS DIFF 2 4))
    
 
   
(SETQ COUNT (+ COUNT 1))
); ende repeat
drobzz
I have made 10-20 posts
I have made 10-20 posts
Posts: 16
Joined: Thu Mar 31, 2011 11:02 am
13
Full Name: Dobromir Balla
Company Details: Software development
Company Position Title: Geodesist-Software Developer
Country: Bulgaria
Linkedin Profile: Yes

Re: Circle (lisp) routine in autocad

Post by drobzz »

If you have Civil 3D you can use menu: Lines/Curves > Create Best Fit Entities > Create Arc
Post Reply

Return to “General Chat”