Trim Polyline

Discussion in 'AutoCAD' started by mgrigoriev, Apr 29, 2004.

  1. mgrigoriev

    mgrigoriev Guest

    Hi,
    I am looking for the best way to trim a polyline. In case of a line, it is simple. I just change the start/end point to an intersection point with the cutting object. I tried to use intersection point with the polyline, but there may be several verticies liying beyond the cutting edge that have to be removed. Just changing the start/end point to an intersection point doesn't work.
    Thanks,
    Mike
     
    mgrigoriev, Apr 29, 2004
    #1
  2. mgrigoriev

    JRWalker Guest

    You could just create a new pline with the definition you want and delete
    the old one. That is one method.

    JRWalker

    simple. I just change the start/end point to an intersection point with the
    cutting object. I tried to use intersection point with the polyline, but
    there may be several verticies liying beyond the cutting edge that have to
    be removed. Just changing the start/end point to an intersection point
    doesn't work.
     
    JRWalker, Apr 30, 2004
    #2
  3. Trimming polylines can be a fairly complicated exercise, and while
    you can do all the work in VB, it's not something I'd savor doing.

    AcadX (available at the URL below), has a Curve class that supports
    a number of operations on any type of curve object (which includes
    lines, arcs, polylines, splines, elliptical curves, and so on). These
    include programmatic counterparts for DIVIDE, MEASURE, and
    BREAK. The Curve class makes trimming these kind of objects fairly
    easy using the Break() method. You get the intersection points of the
    'cutting edge' and the entity that you want to trim using IntersectWith,
    and then pass them to the Break() method, and it 'cuts' the entity at
    the intersection points, returning an array of new objects. You can
    just delete those you don't want, and that's it.




    to an intersection point with the cutting object. I tried to use intersection point with the polyline, but there may be
    several verticies liying beyond the cutting edge that have to be removed. Just changing the start/end point to an
    intersection point doesn't work.
     
    Tony Tanzillo, Apr 30, 2004
    #3
  4. mgrigoriev

    AKS Guest

    You can handle polylines by discovering in which segment you want to make the alteration. For example when using a pick routine that returns the entity and the pick point coordinate, you step through each pair of polyline vertices while checking if the pick point is on that line. There are a number of ways to do that "is on line" check. A simple function
    "intWhichPolyVertice(ent,pickpoint)" that returns an interger telling you which segement number the pick point was works well as the basis for the remainder of your polyline process . It may not be the best way, but it works. I have something along these lines that I could post if you want.

    AKS
     
    AKS, May 6, 2004
    #4
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.