How to use AutoLISP to trim lines ?

Discussion in 'AutoCAD' started by jingzhang.jz, Mar 30, 2006.

  1. jingzhang.jz

    jingzhang.jz Guest

    Hello,everyone!

    I meet a problem when use AutoLISP:

    There is a long , straight line going through a circle. I just want to
    trim off the part inside this circle ,and of course to remain the
    outside part of this line.

    Does anyone know how to do that by using AutoLISP? Hope your answer
    might be as simple as possilble, I am just a begineer to use LISP.
     
    jingzhang.jz, Mar 30, 2006
    #1
  2. jingzhang.jz

    Remo Shiva Guest


    I dont understand, why would you want to use autolisp to do this when the
    trim command will do it for you?
     
    Remo Shiva, Mar 30, 2006
    #2
  3. I can think of two approaches right off.

    One is to actually "trim" it by a command call, selecting the two items, and
    using a point inside the circle (easily generated from the circle's center

    OR

    another is to find the intersections of the line and circle, the endpoints
    of the line, and erase the original line and create two lines using the
    above points.

    Both approaches have their challenges.

    Have fun, and post some code as you work it out. I'm sure you'll get some
    help if needed...
     
    Michael Bulatovich, Mar 30, 2006
    #3
  4. jingzhang.jz

    Dees Guest

    (command "trim" "" pt "")
    pt must be defined as a varible and be the endpoint of the line to trim.
    This line can be placed in your autolisp routine after the endpoint of your
    line has been set to the varible pt.

    I used this method when I first started learning autolisp but defining the
    endpoints
    of the lines and drawing the lines from pointa to pointb is a cleaner way to
    achieve the
    same end result. imo
    Although with radii it does involve a bit of math to define the points to
    draw the line.
     
    Dees, Mar 30, 2006
    #4
  5. jingzhang.jz

    Paul Turvill Guest

    How would the line and circle be selected? I can't think of any obvious way
    LISP or any other add-on routine could do it faster or with fewer clicks
    than the TRIM command.
    ___
     
    Paul Turvill, Mar 30, 2006
    #5
  6. I assume it's part of a larger, more complex function that one wouldn't want
    to repeat too much.
     
    Michael Bulatovich, Mar 30, 2006
    #6

  7. Got that right. I usually don't get around to it since I work in an office
    with zero turnover. We just learn to live with the bumps.
     
    Michael Bulatovich, Mar 30, 2006
    #7
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.