Hello,
I have drawings with many circular polylines that I transfer to ProNest 8 and then feed it to a machine to cut holes.
The problem is there are too many nodes on the polylines that Pronest 8 cant compute.
I tried searching the forums myself and tried the LISP that are given but none of them work. Is there any better way to solve this problem rather than redrawing the drawing I have ?
Anyhelp would be greatly appreciated.
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Hi,
>> Convert Polyline Circle made of many short line segments to normal Circle.
I'm afraid that it's NOT applicable .
I tried applying PolygonToCircle.lsp with its Pg2C command, >here<, but it didn't work. I found that your polygon has coincident vertices, with a zero-length segment at the end, which would make most such routines fail. I fixed that, but Pg2C still didn't work. I tried loosening up its test on how precisely regular the polygon is, but it still didn't. So there must be something just far-enough off from regular about that polygon.
So I made a modification of the code >here<, to draw a 3Point Circle, using the start vertex, one about 1/3 of the way around, and one about 2/3 of the way around:
(defun C:Pg2C ; = PolyGon-[to]-Circle conversion
(/ pl verts)
(setq pl (car (entsel "\nSelect at-least-3-sided Polyline to convert to Circle: ")))
(if (> (setq verts (cdr (assoc 90 (entget pl)))) 2)
(progn
(command "_.circle" "_3P"
"_none" (vlax-curve-getPointAtParam pl 0)
"_none" (vlax-curve-getPointAtParam pl (/ verts 3))
"_none" (vlax-curve-getPointAtParam pl (* (/ verts 3) 2))
)
(entdel pl)
)
)
)
(prompt "\nType Pg2C to convert PolyGon(s) to Circle(s).")
It could use all the usual enhancements, but it worked on the one in your sample drawing, even without fixing the coincident vertices problem.
Another approach
(DEFUN c:test (/ es pt ext dia)
(SETQ es (ENTSEL)) ;Select the polyline
(SETQ pt (OSNAP (CADR es) "GCE")) ;assume the center should be at the geometric center
(SETQ ext (ACET-ENT-GEOMEXTENTS (CAR es))) ;find the extents)
(SETQ
dia (APPLY 'MIN
(CDR (REVERSE (APPLY 'MAPCAR (CONS '- (REVERSE ext)))))
)
) ;return the minimum of the width or height
(COMMAND "_.circle" pt "dia" dia) ;draw the circle.
(COMMAND "_.erase" es "") ;delete the polyline (optional
; other enhancements: copy properties of polyline to circle.
(PRINC)
)
As if you need another approach, here's one that finds the bounding box, and draws a Circle centered in it, with the radius calculated from its diagonal in a way that suits this kind of polygon. It can be used on any kind of object. For anything with equal extents in the X and Y directions, the Circle is inscribed in the bounding box. For things of different proportions, it will be larger than the bounding box in one direction and smaller in the other.
(defun C:O2C-BB ; = Object {to} Circle based on Bounding Box
(/ ent LL UR)
(setq ent (car (entsel "\nSelect object to convert to Circle: ")))
(vla-getboundingbox (vlax-ename->vla-object ent) 'minpt 'maxpt)
(setq
LL (vlax-safearray->list minpt)
UR (vlax-safearray->list maxpt)
)
(command "_.circle"
"_none" (mapcar '/ (mapcar '+ LL UR) '(2 2 2)); center
(/ (distance LL UR) (sqrt 2) 2); radius
)
(entdel ent)
(princ)
)
(prompt "\nType O2C-BB to convert an object to a Circle based on its Bounding Box.")
FYI - I just tested this (the PG2C routine) with an equilateral triangle (2d polyline created with POLYGON) and it does nothing:
Command: PG2C
Select at-least-3-sided Polyline to convert to Circle: nil
?
@dmfrazier wrote:
... I just tested this (the PG2C routine) with an equilateral triangle (2d polyline created with POLYGON) and it does nothing:
....
It works for me. Do you have PLINETYPE set to 0, so it makes "heavy" Polylines instead of "lightweight" ones? The (assoc 90) entry in entity data for the number of vertices will be there only for LWPolylines, not "heavy" ones. The LW ones will be called "Polyline" in the top of the Properties palette, compared to "2D Polyline" for "heavy" ones.
[EDIT: For any who would need to do this with "heavy" Polyline polygons, it could be adjusted to look at the end VLA Parameter value, rather than the number of vertices, because a "heavy" Polyline will have that, whereas it doesn't have the (assoc 90) entry for the number of vertices that a "lightweight" one has.]
"Do you have PLINETYPE set to make "heavy" Polylines instead of "lightweight" ones?"
Yup (PLINETYPE = 0):
(-1 . <Entity name: 218b5126160>)
(0 . "POLYLINE")
(330 . <Entity name: 218c73a79f0>)
(5 . "246")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDb2dPolyline")
(66 . 1)
(10 0.0 0.0 0.0)
(70 . 1)
(40 . 0.0)
(41 . 0.0)
(210 0.0 0.0 1.0)
(71 . 0)
(72 . 0)
(73 . 0)
(74 . 0)
(75 . 0)
It works fine when set to 1.
Thank you Very Much for the help.
The alternative "O2C-BB" worked for me, but the "Pg2C" I could not wrapped my head around where to place the modification you mentioned.
Is there a way to select multiple objects and then apply the command ?
Again Thank you for the reply's guys.
@jyong717 wrote:
....The alternative "O2C-BB" worked for me, but the "Pg2C" I could not wrapped my head around where to place the modification you mentioned.
Is there a way to select multiple objects and then apply the command ?
....
Message 3 wasn't suggesting a modification that would need to be placed somewhere, but its Pg2C command is the modification of the code in the link just above it -- it should work as is.
Here are versions of both that will work on multiple Polylines / multiple objects, including with pre-selection [minimally tested]:
(defun C:Pg2C ; = PolyGon-{to}-Circle conversion
(/ ss n pl verts)
(if (setq ss (ssget '((0 . "*POLYLINE"))))
(repeat (setq n (sslength ss)); then
(setq pl (ssname ss (setq n (1- n))))
(if (> (setq verts (fix (vlax-curve-getEndParam pl))) 2)
(progn
(command "_.circle" "_3P"
"_none" (vlax-curve-getPointAtParam pl 0)
"_none" (vlax-curve-getPointAtParam pl (/ verts 3))
"_none" (vlax-curve-getPointAtParam pl (* (/ verts 3) 2))
); command
(entdel pl)
); progn
); if
); repeat
); if
(princ)
); defun
(defun C:O2C-BB ; = Object {to} Circle based on Bounding Box
(/ ss n ent LL UR)
(if (setq ss (ssget))
(repeat (setq n (sslength ss)); then
(setq ent (ssname ss (setq n (1- n))))
(vla-getboundingbox (vlax-ename->vla-object ent) 'minpt 'maxpt)
(setq
LL (vlax-safearray->list minpt)
UR (vlax-safearray->list maxpt)
); setq
(command "_.circle"
"_none" (mapcar '/ (mapcar '+ LL UR) '(2 2 2)); center
(/ (distance LL UR) (sqrt 2) 2); radius
); command
(entdel ent)
); repeat
); if
(princ)
); defun
Thank You Good Sir.
You helped me save time from individually redrawing a lot of circles.
Is there anyway I can repay you ?