how to define direction in vla-offset

Discussion in 'AutoCAD' started by kemp, Apr 12, 2004.

  1. kemp

    kemp Guest

    I have a basic line and I want to be able to run vla-offset based on a user
    selection, but I can't think up the logic required to define what is
    positive and what is negative. Anyone have insight on how to make a function
    that would do this?

    thanks,
    kemp
     
    kemp, Apr 12, 2004
    #1
  2. kemp

    Jeff Mishler Guest

    Find the angle from the line to the pick point for the offset, if it's
    between 180 degrees and 360 degrees it is negative. Note that this works
    for lines and plines, but arcs are different. For an arc you need to
    check the relationship form the point to the arc's radius point, if it'
    smaller then the arc's radius then use a negative.

    (defun c:eek:ff-test ()
    (setq offdist (getdist "\nOffset distance: ")
    l1 (entsel "\nSelect line to offset: ")
    l1 (car l1)
    l1 (vlax-ename->vla-object l1)
    )
    (setq p1 (getpoint "\nSelect side to offset to: "))
    (setq p2 (vlax-curve-getclosestpointto l1 p1 t))
    (setq ang (angle p2 p1))
    (if (< pi ang (* pi 2))
    (setq offdist (- offdist))
    )
    (setq l2 (vla-offset l1 offdist))
    )

    HTH,
    Jeff
     
    Jeff Mishler, Apr 12, 2004
    #2
  3. I've been trying to figure out what this convoluted approach does for you.
    It looks like it's asking the user to give the offset distance, and to
    select the object to offset, and to pick which side to offset it to, so why
    not just use the regular Offset command? Maybe I just don't understand the
    intent of the original post.

    Kent Cooper, AIA
     
    Kent Cooper, AIA, Apr 12, 2004
    #3
  4. kemp

    kemp Guest

    I have my line defined as activeX data, and was hoping to find a simple
    function to do this. Looks like the example given by Jeff Misler will work
    but it is rather large.. I will try both this way and using the command
    method and see which is faster. I assume a lot of you lisp pro's already
    know the results I should get.

    Thanks for the info,

    kemp
     
    kemp, Apr 13, 2004
    #4
  5. kemp

    Jeff Mishler Guest

    The nice thing about using ActiveX is that there is no need to worry
    about osnaps interfering with your results. Also, no unwanted data is
    sent to the command line.

    The example I posted was just that, and example. If i were to be using
    that in a module that was creating the line to offset, or otherwise
    working with a known line, and probably also have a known point, I would
    use this little function.

    It requires a valid line in vla-object format and a 2d/3d point to be
    passed to it.

    (defun off-test (ent point / p2 ang)
    (setq p2 (vlax-curve-getclosestpointto ent point t))
    (setq ang (angle p2 point))
    (if (< pi ang (* pi 2)) t nil)
    )

    If this returns "T" then the offset is negative, nil is positive.

    HTH,
    Jeff
     
    Jeff Mishler, Apr 13, 2004
    #5
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.