The Acad Offset Function, And A Couple Of Vegetables

Discussion in 'AutoCAD' started by FrozenLips, Feb 4, 2005.

  1. FrozenLips

    FrozenLips Guest

    I am currently working on a certain AutoCad VBA task -

    Given a couple of closed Polylines (One is inside of the other) , I need to find another polyline which keeps a certain condition.

    This condition is the following - for every point on the new polyline, if I create perpendiculars to the old polylines, the distance (meaning the length of the perpendiculars) will be the same in both directions. (The solution may be discreet)

    It's almost like finding the average between to polylines.

    First of all I would be glad to receive any kind of advice but my main question is about the AutoCad implementation of the offset function. How does it work? What are the mathematical caculations behind it?

    Anyway, I would be highly grateful for any kind of help.
    Thank you :)
    Elizabeth
     
    FrozenLips, Feb 4, 2005
    #1
  2. FrozenLips

    TomD Guest


    I can't offer you any detailed math help, but if you happen to have land
    desktop, set one pline to an elevation, the other to a different elevation.
    Create a surface from those two. Then create contours, specifying only the
    elevation midway between the others you used.

    I don't know if that's accurate enough, but works for the situations I need
    something like that.

    (To my knowledge, there is nothing built-in that will handle that.)
     
    TomD, Feb 4, 2005
    #2
  3. FrozenLips

    Matt W Guest

    I'm still trying to figure out where the vegetables come into play. :-S
     
    Matt W, Feb 4, 2005
    #3
  4. FrozenLips

    FrozenLips Guest

    Hey Tom. thanks a lot for the advice, it just might help with a couple of new ideas offered to me at the office.

    And the vegetables? Wherever you'd like them to ;)

    Tata,
    Elizabeth
     
    FrozenLips, Feb 5, 2005
    #4
  5. First of all I would be glad to receive any kind of advice but my main
    sample in dev help
     
    Paul Richardson, Feb 5, 2005
    #5
  6. FrozenLips

    FrozenLips Guest

    "sample in dev help"

    What do you mean by that (I;m new in here so....)


    Elizabeth
     
    FrozenLips, Feb 6, 2005
    #6
  7. If you open the Developer Help menu in AutoCad and do a search
    for Offset there are fully functional examples you can paste right
    into a code page.

    gl
    Paul
     
    Paul Richardson, Feb 6, 2005
    #7
  8. FrozenLips

    TomD Guest

    Ouch! :eek:
     
    TomD, Feb 7, 2005
    #8
  9. FrozenLips

    DRW1975 Guest

    I think what elizabeth is looking for is the actual mathematical algorithm (not VBA code) that AutoCAD uses to determine in space what the new offsetted object will look like. Things like lines and circles are easy, but mis-shapen closed polylines offsetted can often form shapes somewhat different than the original - but of course at all times maintaining the minimum specified offset distance.

    Excellent question, but I'm afraid I do not know the answer. I've thought about it for a few minutes, and can't even muster up a rough logic flow chart for how it could work...

    Must be some vector algebra trickery to determine it - then perhaps merging of items.

    sorry :(

    DRW
     
    DRW1975, Feb 7, 2005
    #9
  10. FrozenLips

    FrozenLips Guest

    Yup, you got it right.

    The only reasonable mathematical solution I had found for it was the following:
    (Though it IS discreet)

    - find the center of the mass of the inner polyline using integrals
    - from it build a polar array of rays
    - using the intersections of the rays and the polylines, some approximation of the needed polyline can be created.

    Ofcourse, the more rays we send, the more approximate we get.

    And yet this solution may not work well with complex topographies...... (Think about a U shaped inner polyline inside of a circle shaped polyline)

    Anyhoops, this is the best I cold think about (Without getting down to linear Algebra stuff :)

    tata,
    lata,
    Elizabeth
     
    FrozenLips, Feb 7, 2005
    #10
  11. ah..;0
     
    Paul Richardson, Feb 7, 2005
    #11
  12. One way of doing it is using Voronoi diagrams.
    Coding this stuff is pretty complicated.

    If you're looking for something simpler
    maybe using
    (vlax-curve-getSecondDeriv curve-obj param)
    at each vertex to get the tangent vector
    and then running a perpendicular vector
    from the tangent with the desired distance
    you'll get the points to draw the offset
    polyline.

    I believe your "ray" approach will not work
    cause rays from the mass center to the polyline
    are not perpendicular to the polyline at all points.

    The offset polyline is the intersection of a plane
    at your offset distance, and a solid extruded from
    your original polyline at a 45 degree angle.
     
    Jorge Jimenez, Feb 8, 2005
    #12
  13. FrozenLips

    DRW1975 Guest

    So it seems as though you are trying to generate an intermediate contour line from two existing ones, perhaps there is a better way to interpolate between the two... This business of using perpendicular distances being equal between plines may be a bit more complicated than is required... (the offset routine is only for a constant distance, your problem will have variable distances, and even if you were to figure it out, it may be useless)

    Perhaps you want a routine that does the following:

    compare pline1 & pline2 for the number of points that form them individually.

    match up control points that form pline1 and pline2 by some method (say shortest distance, or say numerical order on the actual pline) <- this is the trickiest part depending on how your plines are created in the begining.

    interpolate between these two points to form a new midpoint

    connect all the midpoints - and hence your new pline


    does that sound reasonable?


    DRW
     
    DRW1975, Feb 8, 2005
    #13
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.