TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: cadplayer on October 10, 2012, 07:22:01 AM

Title: points on line?
Post by: cadplayer on October 10, 2012, 07:22:01 AM
Hello all!

I wish to can get all polyline vertex- and intersection points on line from 3dPolyline.
First I ask the polyline if it have "VERTEX"
Code: [Select]
(setq en (car (entsel "\nSelect Polyline ")))
(while (and (setq en (entnext en))
            (setq edata (entget en))
            (=(cdr(assoc 0 edata))"VERTEX")
            )
  )

  )
Intersection points from terrain points (Gpt) to my ployline (vl-en) I get
Code: [Select]
(defun _sect ()
  (vlax-curve-getClosestPointTo vl-en Gpt)
  )

The vertex points I get with
Code: [Select]
(defun _polyV (en /)
  (cdr (assoc 10 edata))
  )

My Question: How can I get all points in a order
(pList '((vertex1 x y z) (vertex2 x y z) (section1 x y z) (section2 x y z) (vertex3 x y z) (section3 x y z) (vertex4 x y z) (section4 x y z)....))
Title: Re: points on line?
Post by: Stefan on October 10, 2012, 08:00:53 AM
Just a guess...
Code - Auto/Visual Lisp: [Select]
  1.   (append vertex_list section_list)
  2.     (lambda (x y)
  3.       (<
  4.         (vlax-curve-GetDistAtPoint vl-en x)
  5.         (vlax-curve-GetDistAtPoint vl-en y)
  6.       )
  7.     )
  8.   )
  9. )
Title: Re: points on line?
Post by: cadplayer on October 10, 2012, 09:13:13 AM
thanks that was answer of my question
Title: Re: points on line?
Post by: Kerry on October 10, 2012, 08:27:52 PM

Be aware that vl-sort may remove duplicate data ... so you may have issues if you expect all points will be retained.
Title: Re: points on line?
Post by: cadplayer on October 16, 2012, 05:48:13 AM
That is okay.
Now I have a problem how I build function if I have diffrent lists in section_list and vertex_list
but alway is coordinates in second position

section_list
(("S" 152747.0 6.4086e+006 72.3828) ("S" 152752.0 6.4086e+006 72.3091) ("S" 152770.0 6.40863e+006 72.1742) ("S" 152774.0 6.40863e+006 72.1143) ("S" 152786.0 6.40866e+006 71.9021))

vertex_list
(("S" 152747.0 6.4086e+006 72.3828 "A" -4.19779) ("S" 152752.0 6.4086e+006 72.3091 "A" -1.95332) ("S" 152770.0 6.40863e+006 72.1742 "A" 0.722905) ("S" 152774.0 6.40863e+006 72.1143 "A" -2.4611) ("S" 152786.0 6.40866e+006 71.9021 "A" 9.32426))


I try it with a sub-function but finally I donīt know to get a
Code: [Select]
(defun xxx (y)
   (foreach L y
     (setq D (vlax-curve-GetDistAtPoint vl-en (list (cadr L) (caddr L) (cadddr L))))
     (setq liste (cons D liste))
     )
   )

Code: [Select]
vl-sort (xxx section_list) '<

vl-sort (xxx vertex_list) '<


So I get two list with distance
But I want one list with "S"coordinates  and "A"area sort by distance D

Can somebody help me.
Title: Re: points on line?
Post by: Lee Mac on October 16, 2012, 06:18:56 AM
This?

Code - Auto/Visual Lisp: [Select]
  1. (vl-sort (append section_list vertex_list)
  2.     (function
  3.         (lambda ( a b )
  4.             (< (vlax-curve-getdistatpoint vl-en (list (cadr a) (caddr a) (cadddr a)))
  5.                (vlax-curve-getdistatpoint vl-en (list (cadr b) (caddr b) (cadddr b)))
  6.             )
  7.         )
  8.     )
  9. )
Title: Re: points on line?
Post by: cadplayer on October 17, 2012, 03:01:36 AM
Thanks Lee that I was not trying to do.
Title: Re: points on line?
Post by: Lee Mac on October 17, 2012, 07:50:50 AM
Thanks Lee that I was not trying to do.

Did I misunderstand? :?
Title: Re: points on line?
Post by: CAB on October 17, 2012, 08:54:43 AM
I'm confused.  :-o
Title: Re: points on line?
Post by: Kerry on October 17, 2012, 08:57:55 AM
I'm confused.  :-o
Hi, I'm phred.
Title: Re: points on line?
Post by: cadplayer on October 17, 2012, 02:43:00 PM
Sorry my English is very bad, I mean it was answer to my problem. It was not easy to find a solution and Lee was very fast. Thanks for helping