Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Looking for LISP to explode ellipses, splines

307 views
Skip to first unread message

Ben Maki

unread,
Aug 8, 2001, 12:29:44 PM8/8/01
to
Eva,

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
>


scj.schulz

unread,
Aug 8, 2001, 12:15:13 PM8/8/01
to
I wrote a PEDIT3D.LSP to convert even 3DSplines and 3D-elliptical arcs to
3DPOLY`s.
see www.black-cad.de.
The download will work next week - the program was published in the
AutoCAD-Magazin 04/01 (German).
regards
Jochen

"Eva Schillace" <eschi...@nospam.henneman.com> schrieb im Newsbeitrag

Ben Maki

unread,
Aug 8, 2001, 12:36:50 PM8/8/01
to
Well, curiosity got the best of me and it works with splines too. So I
added splines to the entity type check and changed the name to a more
appropiate one. Here's the new version. Hope it helps.

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

Cliff Middleton

unread,
Aug 8, 2001, 12:31:24 PM8/8/01
to
http://vnestr.tripod.com/ you may find something here.
--
Cliff

Chris

unread,
Aug 8, 2001, 1:00:00 PM8/8/01
to
I have had the same need in the past and thought your lisp would be useful,
however, how does a ludite like myself actually initialise the lisp file
after loading it into a drawing?
i.e. Command line entry?

Chris

"Ben Maki" <bm...@ndcinc.net> wrote in message
news:4AB2094E949C767C...@in.WebX.maYIadrTaRb...

Eva Schillace

unread,
Aug 8, 2001, 11:50:46 AM8/8/01
to

Eva Schillace

unread,
Aug 8, 2001, 5:16:54 PM8/8/01
to
Ben, you're my hero! This is what I was looking for--with just one snag. It
will not process an ellipse. It'll do a spline just beautifully, but for an
ellipse I get
"Density is too high, cannot convert ellipse to polyline.error : quit / exit
abort"
regardless of the value I enter for the density.

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

Ben Maki

unread,
Aug 13, 2001, 7:44:11 PM8/13/01
to
Vladimir,

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

Bobby Jones

unread,
Aug 14, 2001, 10:14:40 AM8/14/01
to
Vladimir, the curve-man, Nesterovsky <g> I always appreciate your
willingness to share with those of us who are not so gifted in the gray
matter.
--
Bobby C. Jones

Ben Maki

unread,
Aug 16, 2001, 1:19:53 PM8/16/01
to
Ahhh, clear as mud ;)

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!

Vladimir Nesterovsky

unread,
Aug 18, 2001, 12:11:19 AM8/18/01
to
Right, it's an angle on a circle before
it gets squashed into an ellipse.

--
Have fun, :-)
Vlad http://vnestr.tripod.com/
(define (list . args) args)

Ben Maki <bm...@ndcinc.net> wrote in message

news:A85C710E91406211...@in.WebX.maYIadrTaRb...

0 new messages