Problem with ellipse

Discussion in 'AutoCAD' started by Xolo, Jul 1, 2004.

  1. Xolo

    Xolo Guest

    Hey all,

    I'm running into a problem with my LISP when creating an elliptical arc. I
    first off can't seem to initiate the elliptical arc command, which is
    probably why I can't get anywhere with this routine.

    I have my routine set so that my pellipse variable is set to 1.

    Here's the line that I'm having problems with;

    (command "_ELLIPSE" "_A" p5 p3 p4 "0" "180")

    It's pretty straight forward, but for some reason it will not envoke the arc
    command within the ellipse command. Is there another way around this?

    Thanks in advance,

    Xolo
     
    Xolo, Jul 1, 2004
    #1
  2. Xolo

    Paul Turvill Guest

    The ARC option is only available with PELLIPSE=1.
    ___
     
    Paul Turvill, Jul 1, 2004
    #2
  3. Xolo

    Paul Turvill Guest

    Sorry, I meant to say "The ARC option is NOT available with PELLIPSE=1."

    It *is* available with PELLIPSE=0.
    ___
     
    Paul Turvill, Jul 1, 2004
    #3
  4. Xolo

    Xolo Guest

    So, how do I get it to create an elliptical arc?

    Do I have to create a full ellipse and trim it down somehow?

    Xolo

    Sorry, I meant to say "The ARC option is NOT available with PELLIPSE=1."

    It *is* available with PELLIPSE=0.
    ___
     
    Xolo, Jul 1, 2004
    #4
  5. Xolo

    Paul Turvill Guest

    Set PELLIPSE to 0. Then draw the elliptical arc.
    ___
     
    Paul Turvill, Jul 1, 2004
    #5
  6. Xolo

    Xolo Guest

    Paul,

    But I still want the ellipse to be drawn with pellipse set to 1. That way I
    can join it to other pollylines and create a 3D model from it.

    I really do need to be able to create it as a pollyline entity.

    Xolo
    Set PELLIPSE to 0. Then draw the elliptical arc.
    ___
     
    Xolo, Jul 1, 2004
    #6
  7. Xolo

    Paul Turvill Guest

    In that case, you'll have to first draw the ellipse, then TRIM it.

    However, joined polylines aren't the only way to create 3D objects. You
    might try "joining" a "true" elliptical arc to other objects by creating a
    Region, and using that instead of polylines.
    ___
     
    Paul Turvill, Jul 1, 2004
    #7
  8. Let me guess -- "Xolo" wants to make it a polyline, so it can be given
    width, or so it can be offset without the result being a
    gazillion-definition-point Spline. Maybe there are other possible reasons.

    If so, making it a full ellipse and trimming it is one option, but hard to
    do with something like a lisp routine, because you need the trimming
    edge(s). You could probably come up with a lisp routine that would draw one
    and then break it. It could use prompts similar to Ellipse's Arc option
    when PELLIPSE = 0. But notice that there, the definition of the starting
    and ending directions of the elliptical arc is relative to an axis of the
    ellipse (it seems that zero degrees is at the opposite end of the major axis
    from the side where you designated that axis), not relative to the
    coordinate system. So to make it work similarly, you'd have to save some
    directions in the process of making the polyline ellipse.

    Kent Cooper, AIA
     
    Kent Cooper, AIA, Jul 1, 2004
    #8
  9. Xolo

    Xolo Guest

    Paul,

    I'm not sure that I follow you.....create a region from lines and elliptical
    arcs (with pellipse set to 0) and then I can revolve the entity?

    Just want to know if I'm following your information correctly.

    Thanks,
    Xolo

    In that case, you'll have to first draw the ellipse, then TRIM it.

    However, joined polylines aren't the only way to create 3D objects. You
    might try "joining" a "true" elliptical arc to other objects by creating a
    Region, and using that instead of polylines.
    ___
     
    Xolo, Jul 1, 2004
    #9
  10. Xolo

    Scrutch Guest

    Hi Xolo,
    I'm thinking we are working on the same kind of project. If you would be willing to post your mailing address I've got some routines that we could bang back and forth without clutter up the board here. I did have a routine that I was trimming the ellipse but abounded that if favor of just doing an arc ellipse. I've got another that I'm working on at the moment that does the outside, offsets it all for the inside and places either the skirt or a skirt and base plate. Just a routine in progress with a DCL...

    Regards,
    Scrutch
     
    Scrutch, Jul 1, 2004
    #10
  11. Xolo

    Paul Turvill Guest

    Yes.
    ___
     
    Paul Turvill, Jul 1, 2004
    #11
  12. Xolo

    Scrutch Guest

    Thanks for the nudge about regions even though it wasn't pointed at me... :~)

    Thanks Paul,
    Scrutch
     
    Scrutch, Jul 1, 2004
    #12
  13. Xolo

    molokaiboy Guest

    I am working on something similar also. I want to prompt the user to select a start point (p1) and end point (p2). I want the quadrant of the ellipse to be .5" from the p1 and p2 points selected. How can this be done?

    TIA

    Collin
     
    molokaiboy, Jul 1, 2004
    #13
  14. Xolo

    Scrutch Guest

    Collin,

    Since no one else has taken a shot at this here's my attempt. Keep in mind that I'm not a hard core lisper and I'm sure there are a lot of different ways to do this. Probably some with a lot less code than I've used but I'm still learning the language.

    (defun C:Elip (/ eco osm 9o p1 p2 px py pm pa p3)
    (setq eco (getvar "CMDECHO");//save cmdecho
    osm (getvar "OSMODE");//save osmode
    );//end setq
    (setvar "CMDECHO" 0);//set cmdecho
    (setvar "OSMODE" 0);//set osmode
    (setq 9o (* pi (/ 90 180.0) ) );//get 90 deg
    (setq p1 (getpoint "\n Pick first point of ellipse: ") )
    (setq p2 (getpoint "\n Pick first point of ellipse: ") )
    (setq px (/ (+ (car p1) (car p2) ) 2) );//x midpoint
    (setq py (/ (+ (cadr p1) (cadr p2) ) 2) );//y midpoint
    (setq pm (list px py) );//midpoint of line
    (setq pa (angle p1 p2) );//points angle
    (setq ra (+ pa 9o) );//rotated angle
    (setq p3 (polar pm ra 0.5) );//ellipse quadrant
    (command "ELLIPSE" p1 p2 p3);//just do it...
    (setvar "CMDECHO" eco);//reset cmdecho
    (setvar "OSMODE" osm);//reset osmode
    (princ);//quiet finish
    );//end elip
    (princ);//quiet load

    Cheers,
    Scrutch
     
    Scrutch, Jul 2, 2004
    #14
  15. Xolo

    Scrutch Guest

    Collin,

    To be on the safe side you probably should insert the following in the above routine. This will assure that you are in Architectural mode while drawing the ellipse giving you the inches setting.

    Insert in the beginning setq list...
    lun (getvar "LUNITS");//save units
    lup (getvar "LUPREC");//save angles
    Insert in the upper setvar list...
    (setvar "LUNITS" 4);//set units
    (setvar "LUPREC" 4);//set angles
    Insert in the lower setvar list...
    (setvar "LUNITS" lun);//reset lunits
    (setvar "LUPREC" lup);//reset angles

    Don't forget to define the lun and lup in the defun variables list. Hope this is what you're looking for. I wasn't sure if you wanted the quadrant perpendicular to the midpoint or not.

    Cheers,
    Scrutch
     
    Scrutch, Jul 2, 2004
    #15
  16. Xolo

    Xolo Guest

    Scruth,

    Here's my e-mail address.



    Yes, I think we're working on exactly the same type of LISPS too. I'm trying
    to get an entire vessel drawn, but need to allow the user to make as many
    choices as possible. I was toying with trying to create a 3D vessel too,
    that's why I wanted to be able to revolve the ellipse after having drawn it.

    Xolo

    willing to post your mailing address I've got some routines that we could
    bang back and forth without clutter up the board here. I did have a routine
    that I was trimming the ellipse but abounded that if favor of just doing an
    arc ellipse. I've got another that I'm working on at the moment that does
    the outside, offsets it all for the inside and places either the skirt or a
    skirt and base plate. Just a routine in progress with a DCL...
     
    Xolo, Jul 2, 2004
    #16
  17. Xolo

    Scrutch Guest

    Files are coming at ya...<g>
    I haven't been working on any of the 3D stuff with this project because I have a third party program that does all that stuffins for me. Just a bit hard to quickly produce a 2D drawing so that's why I'm into this routine.
    Scrutch
     
    Scrutch, Jul 2, 2004
    #17
  18. There's ODDBALL STUFF GOING ON HERE! Even though I agree that the true
    elliptical arc and region approach is probably better, I couldn't help
    experimenting (in A2K4 if it makes any difference) with a way of duplicating
    the effect with a polyline partial ellipse, which has to start with a full
    ellipse and then be trimmed or broken to leave the elliptical arc. But
    FASTEN YOUR SEAT BELTS.

    The original posted problem line was:
    (command "_ELLIPSE" "_A" p5 p3 p4 "0" "180")
    which doesn't work with PELLIPSE set to 1, because the A option is not
    allowed then.

    Points p5, p3, p4 would obviously already be defined here. Whatever the
    PELLIPSE setting, the defining of the starting ellipse is the same. So to
    make a (complete) polyline ellipse with PELLIPSE set to 1:

    (command "_ELLIPSE" p5 p3 p4)
    gives you the same ellipse (within the polyline approximating limits) as the
    true ellipse that it would be starting with when PELLIPSE is 0. Simple
    enough.

    Since the original post has a predetermined arc range making an exact
    half-ellipse, we should be able to just break the polyline ellipse from one
    quadrant point to the opposite one, right? It turns out to be REALLY HARD
    to figure out how to do that with predictable results.

    The nominal zero-degree direction in a TRUE elliptical arc is at one end of
    the major axis, but WHICH end depends on the relationship between the three
    points. It seems that if p5-to-p3 is the major axis, the zero-degree
    direction is toward p5 (the first point given). But if p4 is farther from
    the p5-to-p3 midpoint (the center of the ellipse) than p5 & p3 are, then p4
    is what defines the major axis, but zero degrees is determined somehow not
    by p4 alone, but by how it relates to p5 & p3: it's hard to describe except
    to say that it seems the 90-degree direction is toward p3. The zero-degree
    direction can be at or near P4, or it can be at the opposite end.

    So depending on the relationship between those three points, if you were
    making a partial true-elliptical arc, you might want to do it between p5 &
    p3, or you might want to do it between the at-or-near-p4 quadrant point and
    opposite that. For the same end-result ellipse, zero degrees will be at one
    of the major-axis quadrant points, but which one will depend on the sequence
    of the three points and their relative distances from each other.

    That all determines where zero degrees is in relation to starting and ending
    angles for an elliptical arc when PELLIPSE is 0. But if you BREAK a true
    ellipse, it removes part of it from the first point you give it, in the
    counterclockwise direction around to the second, as it does with circles, no
    matter how it was defined.

    It's WEIRDER, but different, in breaking POLYLINE ellipses (made with
    PELLIPSE = 1). It took some experimenting and comparisons, but I think I
    figured it out. It seems to consider the first point given as sort of like
    zero degrees (similar to the way true ellipses work IF the first two points
    make the major axis), whether or not that ends up being on the major or
    minor axis (which is UNlike true ellipses), and no matter in what kind of
    relationship the other defining points fall. And it DOESN'T CARE in which
    order you give it two break points, or in which direction they're closer to
    each other -- it breaks out the same part no matter what. It seems to get
    both break points before it decides anything, then works its way around from
    its nominal zero-degree first point, counterclockwise until it finds either
    of the break points (including if either of them happens to be ON that first
    point), and then it breaks out the portion of the polyline ellipse
    continuing counterclockwise from there until it finds the other break point.
    If either break point is AT that first defining point, it breaks
    counterclockwise from there. If neither is at that point, the portion of
    the ellipse containing that point is what stays, and the rest is broken out,
    AND that first point becomes the common endpoint of TWO SEPARATE
    partial-ellipse polylines.

    Suppose you want to be left with the top half of an ellipse with its major
    axis horizontal. Suppose its major axis is 4 units and its minor axis 2 (or
    the half-ellipse is 1 unit high in the middle), and its left end is at 0,0.
    Suppose that p4 is ON a quadrant point (equidistant from p5 & p3).

    If p5 is (0,0), p3 is (4,0) and p4 is (2,1), you can do either
    (command "_ELLIPSE" p5 p3 p4 "_BREAK" p5 p3)
    or
    (command "_ELLIPSE" p5 p3 p4 "_BREAK" p3 p5)
    [The same is true if p4 is (2,-1).]

    But if p5 & p3 are reversed, either of those would leave you with the BOTTOM
    half instead. Apparently the only way to have the top half remain would
    then depend on whether p4 is (2,1) or (2,-1). If the former, you'd need to
    calculate the bottom quadrant point, which in this case would be (2,-1) and
    call it, say, p6; if the latter, you'd have that location already. Then you
    can Break from p3 to that bottom quadrant point. After that, the remaining
    lower right quadrant of the original ellipse is now a different polyline
    from the upper half (the two meet at p5), so you'd have to erase it.

    If conditions are the same but the first two points define the vertical
    axis, it's different. If p5 is (2,1), p3 is (2,-1), and p4 is (0,0) or
    (4,0), you could break between p4 and its opposite quadrant point (which
    you'd have to calculate). If p5 & p3 were reversed, you have to do a
    similar breaking out of a quarter of it, from p5 to the right quadrant
    point. But in this case it isn't like the one with p5-to-p3 horizontal --
    since the break started at the first-point nominal zero-degree direction,
    the remainder is now ONE 3/4-ellipse polyline, so instead of erasing a
    leftover quadrant, you'd break between p5 and the left quadrant point.

    It could get even more complicated if p4 isn't actually ON the ellipse
    (which it doesn't have to be), because calculating its opposite quadrant
    would be much more involved, and p4's effect as a break point could be
    different.

    I think LOTS of comparisons and analysis would be required to make all of
    that act predictably under any possible combination of point sequence and
    relationship. If the earlier routine (or part of one) that defines the
    three points always does them in the SAME kind of relationship, it would be
    simple enough to make something that would work with that particular
    combination.

    But maybe the better way would be to draw the ellipse, draw a temporary line
    through the middle, and use that as a trim edge to cut half of the ellipse
    off (then erase the line), because you can do that without worrying about
    what direction the ellipse considers to be like zero degrees.

    Kent Cooper, AIA
     
    Kent Cooper, AIA, Jul 2, 2004
    #18
  19. Xolo

    Xolo Guest

    Kent,

    Thanks for taking the time to investigate this. I think I also understand
    most of it too. :)

    Anyways, to create the ellipse, I only need 1/4 of it to remain once it's
    created, so breaking it at p5 and p3 should give me what I want. I can then
    try erasing the remainder from p4 and see if it works out.

    Again, thanks a lot of all of this information,

    Xolo

    There's ODDBALL STUFF GOING ON HERE! Even though I agree that the true
    elliptical arc and region approach is probably better, I couldn't help
    experimenting (in A2K4 if it makes any difference) with a way of duplicating
    the effect with a polyline partial ellipse, which has to start with a full
    ellipse and then be trimmed or broken to leave the elliptical arc. But
    FASTEN YOUR SEAT BELTS.

    The original posted problem line was:
    (command "_ELLIPSE" "_A" p5 p3 p4 "0" "180")
    which doesn't work with PELLIPSE set to 1, because the A option is not
    allowed then.

    Points p5, p3, p4 would obviously already be defined here. Whatever the
    PELLIPSE setting, the defining of the starting ellipse is the same. So to
    make a (complete) polyline ellipse with PELLIPSE set to 1:

    (command "_ELLIPSE" p5 p3 p4)
    gives you the same ellipse (within the polyline approximating limits) as the
    true ellipse that it would be starting with when PELLIPSE is 0. Simple
    enough.

    Since the original post has a predetermined arc range making an exact
    half-ellipse, we should be able to just break the polyline ellipse from one
    quadrant point to the opposite one, right? It turns out to be REALLY HARD
    to figure out how to do that with predictable results.

    The nominal zero-degree direction in a TRUE elliptical arc is at one end of
    the major axis, but WHICH end depends on the relationship between the three
    points. It seems that if p5-to-p3 is the major axis, the zero-degree
    direction is toward p5 (the first point given). But if p4 is farther from
    the p5-to-p3 midpoint (the center of the ellipse) than p5 & p3 are, then p4
    is what defines the major axis, but zero degrees is determined somehow not
    by p4 alone, but by how it relates to p5 & p3: it's hard to describe except
    to say that it seems the 90-degree direction is toward p3. The zero-degree
    direction can be at or near P4, or it can be at the opposite end.

    So depending on the relationship between those three points, if you were
    making a partial true-elliptical arc, you might want to do it between p5 &
    p3, or you might want to do it between the at-or-near-p4 quadrant point and
    opposite that. For the same end-result ellipse, zero degrees will be at one
    of the major-axis quadrant points, but which one will depend on the sequence
    of the three points and their relative distances from each other.

    That all determines where zero degrees is in relation to starting and ending
    angles for an elliptical arc when PELLIPSE is 0. But if you BREAK a true
    ellipse, it removes part of it from the first point you give it, in the
    counterclockwise direction around to the second, as it does with circles, no
    matter how it was defined.

    It's WEIRDER, but different, in breaking POLYLINE ellipses (made with
    PELLIPSE = 1). It took some experimenting and comparisons, but I think I
    figured it out. It seems to consider the first point given as sort of like
    zero degrees (similar to the way true ellipses work IF the first two points
    make the major axis), whether or not that ends up being on the major or
    minor axis (which is UNlike true ellipses), and no matter in what kind of
    relationship the other defining points fall. And it DOESN'T CARE in which
    order you give it two break points, or in which direction they're closer to
    each other -- it breaks out the same part no matter what. It seems to get
    both break points before it decides anything, then works its way around from
    its nominal zero-degree first point, counterclockwise until it finds either
    of the break points (including if either of them happens to be ON that first
    point), and then it breaks out the portion of the polyline ellipse
    continuing counterclockwise from there until it finds the other break point.
    If either break point is AT that first defining point, it breaks
    counterclockwise from there. If neither is at that point, the portion of
    the ellipse containing that point is what stays, and the rest is broken out,
    AND that first point becomes the common endpoint of TWO SEPARATE
    partial-ellipse polylines.

    Suppose you want to be left with the top half of an ellipse with its major
    axis horizontal. Suppose its major axis is 4 units and its minor axis 2 (or
    the half-ellipse is 1 unit high in the middle), and its left end is at 0,0.
    Suppose that p4 is ON a quadrant point (equidistant from p5 & p3).

    If p5 is (0,0), p3 is (4,0) and p4 is (2,1), you can do either
    (command "_ELLIPSE" p5 p3 p4 "_BREAK" p5 p3)
    or
    (command "_ELLIPSE" p5 p3 p4 "_BREAK" p3 p5)
    [The same is true if p4 is (2,-1).]

    But if p5 & p3 are reversed, either of those would leave you with the BOTTOM
    half instead. Apparently the only way to have the top half remain would
    then depend on whether p4 is (2,1) or (2,-1). If the former, you'd need to
    calculate the bottom quadrant point, which in this case would be (2,-1) and
    call it, say, p6; if the latter, you'd have that location already. Then you
    can Break from p3 to that bottom quadrant point. After that, the remaining
    lower right quadrant of the original ellipse is now a different polyline
    from the upper half (the two meet at p5), so you'd have to erase it.

    If conditions are the same but the first two points define the vertical
    axis, it's different. If p5 is (2,1), p3 is (2,-1), and p4 is (0,0) or
    (4,0), you could break between p4 and its opposite quadrant point (which
    you'd have to calculate). If p5 & p3 were reversed, you have to do a
    similar breaking out of a quarter of it, from p5 to the right quadrant
    point. But in this case it isn't like the one with p5-to-p3 horizontal --
    since the break started at the first-point nominal zero-degree direction,
    the remainder is now ONE 3/4-ellipse polyline, so instead of erasing a
    leftover quadrant, you'd break between p5 and the left quadrant point.

    It could get even more complicated if p4 isn't actually ON the ellipse
    (which it doesn't have to be), because calculating its opposite quadrant
    would be much more involved, and p4's effect as a break point could be
    different.

    I think LOTS of comparisons and analysis would be required to make all of
    that act predictably under any possible combination of point sequence and
    relationship. If the earlier routine (or part of one) that defines the
    three points always does them in the SAME kind of relationship, it would be
    simple enough to make something that would work with that particular
    combination.

    But maybe the better way would be to draw the ellipse, draw a temporary line
    through the middle, and use that as a trim edge to cut half of the ellipse
    off (then erase the line), because you can do that without worrying about
    what direction the ellipse considers to be like zero degrees.

    Kent Cooper, AIA
     
    Xolo, Jul 5, 2004
    #19
  20. Given the point sequence in your original code, breaking between p5 and p3
    would appear to be cutting the ellipse in half, rather than leaving a
    quarter of it, since those two points will be the opposite ends of one of
    the axes. Point p4 may or may not be on the remaining part, anyway,
    depending on the relationship. I assumed a half-ellipse because your
    original code would make an arc from 0 to 180 degrees (if it were making a
    true elliptical arc with PELLIPSE = 0).

    If p4 is actually ON a quadrant point, you can break between p4 and one of
    the others, but I think you'll still have to be careful about how you define
    that, depending on the relationship of the points and which quadrant you
    want to have left. Some varieties of break between p4 and another point
    will leave you with a quarter-ellipse, but some will leave you with
    three-quarters; some of the latter will leave you two partial ellipses, and
    some of them one. That's why I hope the earlier part of your routine
    defines those three points always in the same relationship, so you can
    tailor the breaking (and erasing, if appropriate) to that particular way of
    building the ellipse.

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Jul 6, 2004
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.