Results 1 to 5 of 5

Thread: With LISP, how can I tell how many segments are in a LWPOLYLINE ?

  1. #1
    I could stop if I wanted to
    Join Date
    2005-08
    Posts
    378
    Login to Give a bone
    0

    Cool With LISP, how can I tell how many segments are in a LWPOLYLINE ?

    Guys,
    I am clear on how to get the start point, end point and to set a specific distance of a LWPOLYLINE.

    (setq ET (entlast))
    (setq OBJ (vlax-ename->vla-object ET))
    (setq STRTPT (vlax-curve-getStartPoint OBJ))
    (setq ENDPT (vlax-curve-getendPoint OBJ))
    (setq PLPT (vlax-curve-getpointatdist OBJ "MyPolylinePoint"))

    This will give me the angle of the first segment, if i am correct. Not clear on how it is doing it. I have read a previous thread though couldn't follow.

    (setq ANGL
    (* (/ 180 pi)
    (angle (list 0.0 0.0 0.0)
    (vlax-curve-getFirstDeriv OBJ
    (vlax-curve-getparamatdist OBJ 0.0001))
    )
    )
    )

    Is it possible with code to determin how many actual segments a polyline has ?
    How do I cycle through and get the angle and direction for multiple segments of the LWPOLYLINE ?

    Could someone please try an explain the small code above that determins the angle and what it is doing ? The "K.I.S.S." (keep it simple stupid) method is much preffered as i am simple.

    Any assistance is much appreciated.


    Stephen

  2. #2
    100 Club CADmium's Avatar
    Join Date
    2004-08
    Location
    Eberswalde, Germany, Europe
    Posts
    128
    Login to Give a bone
    0

    Default Re: With LISP, how can I tell how many segments are in a LWPOLYLINE ?

    try this:
    (setq ET (entlast))
    (setq OBJ (vlax-ename->vla-object ET))

    (setq SEG-COUNT (vlax-curve-getendparam OBJ))

  3. #3
    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: With LISP, how can I tell how many segments are in a LWPOLYLINE ?

    See the second post.
    http://forums.augi.com/showthread.php?t=32645

    Also see kennet's post below that one.

  4. #4
    I could stop if I wanted to
    Join Date
    2005-08
    Posts
    378
    Login to Give a bone
    0

    Cool Re: With LISP, how can I tell how many segments are in a LWPOLYLINE ?

    Thank you CADmium, that gets me the mumber of segments.

    Cab2k,
    I have been over that thread already and now again though not understanding it all. I wan't to be able to get the angles and lengths of all the segments if possible ? The answer is most likely in my face but just not understanding Kennet. Is there another thread that covers this topic in any simpler detail.

    Stephen

  5. #5
    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: With LISP, how can I tell how many segments are in a LWPOLYLINE ?

    See if this helps explain it.
    Code:
    (defun C:TEST (/ curve idx ang)
      (vl-load-com)
      (command "_.pline"
               "_non" '(0 0)
               "_non" '(10 0)
               "_non" '(0 10)
               "_non" '(0 20)
               "_non" '(-10 20)
               "_non" '(-10 10)
               "")
      (setq curve (entlast))
      (setq idx 0)
      (repeat (fix (1- (vlax-curve-getendparam curve)))
        (setq ang (angle '(0 0) (vlax-curve-getFirstDeriv curve idx))) ; (+ idx 0.005)
        (print "Angle of segment #")
        (princ idx)
        (princ " is ")
        (princ ang)
        (princ " radians.")
        (setq idx (1+ idx))
      )
      (princ)
    )

Similar Threads

  1. Reshape of LWPOLYLINE
    By srinivasarajug in forum AutoLISP
    Replies: 1
    Last Post: 2014-06-26, 06:31 PM
  2. LWPolyline group codes
    By buncobob in forum AutoLISP
    Replies: 3
    Last Post: 2010-08-05, 05:04 PM
  3. Replies: 4
    Last Post: 2007-02-20, 05:29 PM
  4. lwpolyline bulge
    By pnorman in forum AutoLISP
    Replies: 3
    Last Post: 2005-05-17, 04:59 PM
  5. Replies: 7
    Last Post: 2005-03-16, 01:42 PM

Posting Permissions

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