See the top rated post in this thread. Click here

Page 2 of 6 FirstFirst 123456 LastLast
Results 11 to 20 of 54

Thread: Length of polylines within an area

  1. #11
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Length of polylines within an area

    Glad it worked for you.
    As I was going to sleep last night I realized there may be a situation where the
    contour line may run on top of or just touch the boundary and saty on the
    previous side of the boundary. This would not work wit the toggle method I used.
    You would need to test the segment at some point along it to see if it was in or
    out. Hope that made sense.

  2. #12
    AUGI Addict .T.'s Avatar
    Join Date
    2000-12
    Location
    Lost
    Posts
    1,473
    Login to Give a bone
    0

    Default Re: Length of polylines within an area

    Quote Originally Posted by CAB2k
    Glad it worked for you.
    As I was going to sleep last night I realized there may be a situation where the
    contour line may run on top of or just touch the boundary and saty on the
    previous side of the boundary. This would not work wit the toggle method I used.
    You would need to test the segment at some point along it to see if it was in or
    out. Hope that made sense.
    I see your point. I'll have to look at that some more. Maybe and even/odd number of intersections test? More pondering to do...

  3. #13
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Length of polylines within an area

    I was thinking something like this.
    Note that there may be a bug in the '@cv_inside' function I was using.
    It worked when I had it draw the vectors in my test setup but failed to
    return true for points inside when I did not have it draw vectors.
    I offer that tid bit in case you were using the same function.

    Code:
    (defun c:test ()
      (or border (setq border (car (entsel "\nSelect the border."))))
      (or pline  (setq pline  (car (entsel "\nSelect the conture line."))))
      
      (setq oborder (vlax-ename->vla-object border)
            opline  (vlax-ename->vla-object pline)
      )
      (setq ilst  (vlax-invoke oborder 'intersectwith opline acextendnone)
            ilst  (@cv_triple_up ilst) ; convert list to list of triples
            strpt (vlax-curve-getstartpoint opline)
            endpt (vlax-curve-getendpoint opline)
            len   0
      )
      ;;  make alist with distance
      (setq ilst (mapcar '(lambda (x) (cons x (vlax-curve-getdistatpoint opline x))) ilst))
      (setq ilst (vl-sort ilst '(lambda (e1 e2) (< (cdr e1) (cdr e2)))))
      (setq lastpt strpt)
      (foreach pt ilst
        ;; get the mid point of the segment
        (setq dist (+ (vlax-curve-getdistatpoint opline lastpt)
                      (/ (setq net (- (vlax-curve-getdistatpoint opline (car pt))
                                      (vlax-curve-getdistatpoint opline lastpt)))
                         2))
                   )
        (command "point" (vlax-curve-getPointAtDist opline dist))
        (setq midpt (list (car (setq tmp (vlax-curve-getPointAtDist opline dist)))
                          (cadr tmp)))
        (if (@cv_inside midpt oborder t)
          (setq len (+ len net))
        )
        (setq lastpt (car pt))
      )
      len
    )

  4. #14
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    1

    Default Re: Length of polylines within an area

    PS
    Be aware that there are many scenarios to consider to make this a complete function.
    I think you know that but I thought I should mention it for others that may be lurking.
    One got-ya is when the end of the spline is inside the border, the last segment is not
    included.

  5. #15
    AUGI Addict .T.'s Avatar
    Join Date
    2000-12
    Location
    Lost
    Posts
    1,473
    Login to Give a bone
    0

    Default Re: Length of polylines within an area

    Cab, you're awesome!

    It looks like you did what I was in the middle of doing ; checking if a point between the points is inside or out. I will dissect and test the heck out of it, tomorrow (_ork is getting in the way ).

    For the inside function, the math, etc. was way over my head and I was offsetting the boundary through the point and comparing the areas of the two polylines. That was until I found THIS. They seem to have put a lot of thought and testing into it, and it seems to be faster, so I decided to use it. to them, also.
    BTW, there are a couple of typos in their posted routine (at least the one I grabbed), so be aware if you decide to check it out.

    As far as the hanging end inside the border case, a simple test to see if the pline begins or ends inside the boundary is probably good policy (if nothing else, to verify that there are no unexpected breaks in the pline), and adding it to the point list would probably work if that is the case. But I don't see that happening for what I am using it for; It would disqualify the final calculation for the whole parcel, because the data (contours) would be incomplete. Or maybe I could cheat and extend it until it does intersect...j/k

    Thank you very much for your help and ideas. This is definitely a learning experience for me.

  6. #16
    AUGI Addict .T.'s Avatar
    Join Date
    2000-12
    Location
    Lost
    Posts
    1,473
    Login to Give a bone
    0

    Default Re: Length of polylines within an area

    Well, I found some time to do a little...that's something.

    I have attached what I have so far, and any and all constructive criticism is welcome. c:test is the main program so far, I haven't added error checking, and I left off some filtering to make testing easier.

    I am especially interested in ways to streamline the code. Some of it I just hammered on until it worked (and sometimes it took a VBFH) .

    Note: I haven't talked to the person that wrote the @inside function yet, so I don't feel comfortable including it, so I didn't. See previous posts for details.

    CAB, you will find that testing for the endpoints falling inside and adding them to the point list if they do works pretty well, and actually took care of another case I hadn't thought of: having a contour that is totally enclosed by the boundary (such as a depression or knob). Please hammer on it with all of the scenarios you can think of if you have time (but I think I have them covered). BTW, if the contour follows the boundary for a distance (what do they call it? Co-linear?), it excludes that part, which is good for me and my calcs hehehe (every little bit that you can get away with helps).

    Have a great weekend everyone!
    Attached Files Attached Files

  7. #17
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Length of polylines within an area

    I'll check it out when time permits.
    There is a newer version out there. If I find the link I'll post it.

    Code:
    (defun @cv_inside (PIQ Object Draw / IsPolyline Closest Start End Param P ClosestParam
                                         NextParam a1 a2 Defl @2D @Insect @Bulge @Deflect
                                         @Closest Color)
      ;;               "LOOK, MA'... NO RAYS!"
      ;; @Inside.lsp v1.0 (09-15-03) John F. Uhden, Cadlantic.
      ;; v2.0 Revised (09-17-03) - See notes below.
      ;; v3.0 Revised (09-20-03) - See notes below.
      ;; v4.0 Revised (09-20-04) but still missing something
      ;; v5.0 Revised (04-04-04) - See notes below.
    Also do a search for the @cv_triple_up function, it's very fast.

  8. #18
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Length of polylines within an area

    @cv_inside.lsp is attached to one of the post here http://tinyurl.com/jsvak
    Another thread of interest http://tinyurl.com/m2yro

    @cv_triple_up can be found here http://tinyurl.com/lftvc
    Last edited by CAB2k; 2006-04-08 at 09:58 PM.

  9. #19
    AUGI Addict .T.'s Avatar
    Join Date
    2000-12
    Location
    Lost
    Posts
    1,473
    Login to Give a bone
    0

    Default Re: Length of polylines within an area

    Thanks for looking at it, CAB.

    The first link didn't work; can you check it for me? I want to make sure I have the right one.

  10. #20
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Length of polylines within an area

    OK, I fixed the link.

Page 2 of 6 FirstFirst 123456 LastLast

Similar Threads

  1. Polylines: total area and length
    By Wish List System in forum AutoCAD Wish List
    Replies: 6
    Last Post: 2015-05-24, 10:44 AM
  2. Total Length of Polylines
    By vijaybaskergundla in forum AutoLISP
    Replies: 7
    Last Post: 2015-04-30, 04:29 PM
  3. Polylines: total area and length
    By Wish List System in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2014-01-29, 05:16 AM
  4. Polylines and Total Length
    By revit.wishlist1942 in forum Revit Architecture - Wish List
    Replies: 3
    Last Post: 2012-06-13, 08:10 PM
  5. LENGTH and area of many polylines
    By marijan.marsic in forum AutoLISP
    Replies: 16
    Last Post: 2008-12-02, 08:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •