Jump to content

Converting multiple line segments to a single circle


Recommended Posts

Squirltech

Hello all! It's been a while since I've posted but I'm looking for a way to convert multiple single line segments (drawn to represent a circle) into an actual single circle. I've attached a dwg file showing what I'm working with. Let me know if you have any questions. Thanks in advance for any help.

BLOCK-SegmentedCircle.dwg

Link to post
Share on other sites

My first reaction would be to do it manually by drawing a circle with the option Three points (3P) using the osnap Endpoint, and pick any three points roughly at the third points.

Link to post
Share on other sites
Squirltech
8 minutes ago, eldon said:

My first reaction would be to do it manually by drawing a circle with the option Three points (3P) using the osnap Endpoint, and pick any three points roughly at the third points.

 

This is exactly what I did but then...

 

I can do it globally using Overkill, Pedit, Join and Fit. Works like a charm too.

Link to post
Share on other sites

Indeed that is also a good solution.

 

But I thought you wanted actual circles, and that method gives polylines.

  • Like 1
Link to post
Share on other sites
Squirltech
10 minutes ago, eldon said:

But I thought you wanted actual circles, and that method gives polylines.

 

Actual circles was the goal but this will suffice

Link to post
Share on other sites

Something like this.

(defun c:pl-c ( / ss ent k x y)

(setq ss (ssget))

(setq lst '())

(repeat (setq x (sslength ss))
(setq ent (vlax-ename->vla-object  (ssname ss (setq x (1- x)))))
(cond
((= (vla-get-objectname ent) "AcDbLwpolyline")(setq pt (vlax-curve-getstartpoint ent)))
((= (vla-get-objectname ent) "AcDbLine")(setq pt (vlax-get ent 'StartPoint)))
)
(setq lst (cons pt lst))
)

(setq x 0.0 y 0.0)

(repeat (setq K (length lst))
(setq pt (nth (setq k (1- k)) lst))
(setq x (+ (car pt) x))
(setq y (+ (cadr pt) y))
)

(setq pt (list (/ x (length lst))(/ y (length lst))))
(setq rad (distance pt (nth 0 lst)))
(command "circle" pt rad)

(princ)
)

 

  • Like 1
Link to post
Share on other sites

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