I just had the same need and put this together. It basically takes an
ellipse and traces it with a polyline of arcs, then deletes the ellipse. I
haven't tried it on a spline, but think it would work there too (with a
little tweaking). The benefit of doing it this way is that you end up with
a curve that is very close to the actual elliptical curve. Ellipses drawn
with PEllipse set to 1 are really quite poor renditions of an arc,
especially the less like a circle the ellipse gets. The drawback of course
is that you end up with a polyline that's not very easy to fudge with, but
it looks a lot better in the end.
Pass it the entity name of the ellipse (and maybe the spline) and the
density factor (this determines the distance between vertices on the
polyline):
;;;
;;; Ellipse -> Polyline convertor
;;;
(defun Ellipse->Polyline (ename density / polyName)
(setq entdata (entget ename))
(if (/= "ELLIPSE" (cdr (assoc 0 entdata)))
(progn
(princ
"\nObject is not an ellipse, cannot convert ellipse to polyline."
)
(exit)
)
)
(setq TotLength (vlax-curve-GetDistAtPoint
ename
(vlax-curve-GetEndPoint ename)
)
CurLen density
)
(if (> density TotLength)
(progn (princ
"\nDensity is too high, cannot convert ellipse to polyline."
)
(exit)
)
)
;;First point of polyline
(command "_.pline"
"_non"
(trans (vlax-curve-getStartPoint ename) 0 1)
)
;;Second point of first arc of polyline
(setq CurLen (+ CurLen density))
(command "arc"
"second"
"_non"
(trans (vlax-curve-getpointatdist ename CurLen) 0 1)
)
(setq CurLen (+ CurLen density))
;;All the rest of the points
(while (< CurLen TotLength)
(command "_non"
(trans (vlax-curve-getpointatdist ename CurLen) 0 1)
)
(setq CurLen (+ CurLen density))
(command "second"
"_non"
(trans (vlax-curve-getpointatdist ename CurLen) 0 1)
)
(setq CurLen (+ CurLen density))
)
(command)
(command "_non"
(trans (vlax-curve-GetEndPoint ename) 0 1)
""
)
(setq polyName (entlast))
(command "_.erase" ename "")
polyName
)
--
Ben Maki
NDC Inc.
"Eva Schillace" <eschi...@nospam.henneman.com> wrote in message
news:3B715FD6...@nospam.henneman.com...
> Hi folks,
>
> I am in need of a Lisp routine that will explode true ellipses and
> splines.
> Ellipses drawn with PEllipse=1 and splined Plines can be exploded, so
> alternatively I need to be able to convert them into those types of
> objects instead.
>
> Please forgive me if the question's been answered before, but the
> newsgroup search engine isn't working at the moment.
>
> TIA!
> -Eva
>
"Eva Schillace" <eschi...@nospam.henneman.com> schrieb im Newsbeitrag
;;;
;;; Curve -> Polyline convertor
;;;
(defun Curve->Polyline (ename density / polyName)
(setq entdata (entget ename))
(if (not (or (= "ELLIPSE" (cdr (assoc 0 entdata)))
(= "SPLINE" (cdr (assoc 0 entdata)))
))
(progn
(princ
"\nObject is not an ellipse or spline, cannot convert ellipse to polyline."
Chris
"Ben Maki" <bm...@ndcinc.net> wrote in message
news:4AB2094E949C767C...@in.WebX.maYIadrTaRb...
I think it's having trouble setting the "TotLength" variable, possibly since an
ellipse has no endpoint. But I don't understand the vlax-curve-* functions well
enough to know how to fix it.
-Eva
Ben Maki wrote:
> That would be useful, wouldn't it?
>
> It was originally part of a larger lisp program, so it didn't need a
> command-line front-end. Put this little bit in the same file and load it
> all. Then you can start the command by typing CurveToPolyline
>
> (defun c:CurveToPolyline (/ entName density)
> (setq entName (car (entsel "\nSelect ellipse or spline: "))
> density (progn (initget 7) (getreal "\nIncrement to draw vertices:
> "))
> )
> (Curve->Polyline entName density)
> (princ)
> )
>
> --
> Ben Maki
> NDC Inc.
> "Chris" <chris...@camerontaylor.co.uk> wrote in message
> news:98EB13943A43CFA0...@in.WebX.maYIadrTaRb...
Good point. For what I use it for here that's not too much of an issue
because like Eva, we don't have any tolerance limits and we have a minimum
radius/ratio caused by the limits of the actual construction machinery. But
you're right, when the ellipse becomes more squashed, it starts to get a
little bumpy.
>As an improvement, it is better to work by incrementing
>a parameter, not a distance on the spline.
To be honest, I've avoided the parameter commands because I'm not really
sure what a parameter is or how it's figured. Is there an easy explanation
or good site I can refer to? (or should I just go sign up for calculus at
the local JC?)
Ben
Actually, that helped a lot. While I don't understand it fully yet, at
least I can use them. One thing I noticed (correct me if I'm wrong) and
found useful: The parameter on any point of an ellipse is the same as the
angle from the center to that point would be if it were a circle (in
radians). Very handy info when drawing isometricaly or need to know the
included angle of an elliptical arc.
Thanks for your help!
--
Have fun, :-)
Vlad http://vnestr.tripod.com/
(define (list . args) args)
Ben Maki <bm...@ndcinc.net> wrote in message
news:A85C710E91406211...@in.WebX.maYIadrTaRb...