Jump to content

Converting multiple line segments to a single circle


Squirltech

Recommended Posts

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 comment
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 comment
Share on other sites

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 comment
Share on other sites

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