Author Topic: Polyline point  (Read 12229 times)

0 Members and 1 Guest are viewing this topic.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Polyline point
« on: July 03, 2012, 05:44:07 AM »
Hi!

Iīm trying a little complicate topic for me with polylines. In the code I can read all GC10 on screen. Now Iīm thinking if a polyline have a arc-segment I would like divide the arc-segment in 3 parts to get center-point and two arc-points (start and end point from arc I already have)
I donīt know to handle  vla-getBulge what it means ?

Command: (vla-getBulge (vlax-ename->vla-object ssn) z)
-3.42231

Can I calculate radius from that ?


Code: [Select]
(defun c:T (/
    ss
    ssn
    z
    i
    p
    s
    )
  (prompt "** << Select Polylines to export their coordinates >> **" )
  (if (setq ss (ssget '((0 . "POLYLINE,LWPOLYLINE"))))
    (progn
      (repeat (setq i (sslength ss))
(setq ssn (ssname ss (setq i (1- i)))
      z -1
      p (abs (fix (vlax-curve-getendparam ssn))))

(princ (strcat "\nPolyline " (itoa i) " have "  " " (itoa p) " segments\n"))
(repeat (1+ p)
  (princ
    (strcat "\n"
    (rtos (car (setq s (apply 'list (vlax-curve-getpointatparam ssn (setq z (1+ z)))))) 2)
    " "
    (rtos (cadr s) 2)
    " "
    (rtos (caddr s) 2)
    )
    )
  )
(princ "\n")
)
      )
    (princ)
    )
  (princ)
  )


fixo

  • Guest

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Polyline point
« Reply #2 on: July 03, 2012, 06:43:21 AM »
Basically a bulge means "How curved is the segment". A bulge value of 1.0 means it's a 180 degree arc starting and stopping at the vector's endpoints.

To see some samples look at the functions in my Library (line 320 should give you an idea): http://caddons.svn.sourceforge.net/viewvc/caddons/Libraries/Math.LSP?revision=65&view=markup

From there you get the degrees of curvature. And from that it's a geometrical calculation to get the center point from the two endpoints.

Edit: BTW, a very nice explanation of how bulges work: http://www.afralisp.net/archive/lisp/Bulges1.htm
« Last Edit: July 03, 2012, 07:13:29 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Polyline point
« Reply #3 on: July 03, 2012, 07:50:28 AM »
Thanks it all. I can continue...

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Polyline point
« Reply #4 on: July 03, 2012, 08:09:19 AM »
Here is my take on the subject:

http://lee-mac.com/bulgeconversion.html

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Polyline point
« Reply #5 on: July 03, 2012, 08:18:42 AM »
http://elpanov.com/index.php?id=35#eea-cen-lw-seg
Code - Auto/Visual Lisp: [Select]
  1. (defun eea-cen-lw-seg (p1 p2 b)
  2.                       ;|
  3. *****************************************************************************************
  4.  
  5. by ElpanovEvgeniy
  6.  
  7. &#1041;&#1080;&#1073;&#1083;&#1080;&#1086;&#1090;&#1077;&#1095;&#1085;&#1072;&#1103; &#1092;&#1091;&#1085;&#1082;&#1094;&#1080;&#1103;,
  8.  
  9. &#1056;&#1072;&#1076;&#1080;&#1091;&#1089; &#1080; &#1094;&#1077;&#1085;&#1090;&#1088; &#1076;&#1091;&#1075;&#1086;&#1074;&#1086;&#1075;&#1086; &#1089;&#1077;&#1075;&#1084;&#1077;&#1085;&#1090;&#1072; &#1087;&#1086;&#1083;&#1080;&#1083;&#1080;&#1085;&#1080;&#1080;, &#1079;&#1072;&#1076;&#1072;&#1085;&#1085;&#1086;&#1075;&#1086; &#1076;&#1074;&#1091;&#1084;&#1103; &#1090;&#1086;&#1095;&#1082;&#1072;&#1084;&#1080; &#1080; &#1082;&#1088;&#1080;&#1074;&#1080;&#1079;&#1085;&#1086;&#1081;
  10.  
  11. p1 - &#1085;&#1072;&#1095;&#1072;&#1083;&#1100;&#1085;&#1072;&#1103; &#1090;&#1086;&#1095;&#1082;&#1072; &#1076;&#1091;&#1075;&#1086;&#1074;&#1086;&#1075;&#1086; &#1089;&#1077;&#1075;&#1084;&#1077;&#1085;&#1090;&#1072;
  12. p2 - &#1082;&#1086;&#1085;&#1077;&#1095;&#1085;&#1072;&#1103; &#1090;&#1086;&#1095;&#1082;&#1072; &#1076;&#1091;&#1075;&#1086;&#1074;&#1086;&#1075;&#1086; &#1089;&#1077;&#1075;&#1084;&#1077;&#1085;&#1090;&#1072;
  13. b  - &#1082;&#1088;&#1080;&#1074;&#1080;&#1079;&#1085;&#1072; &#1076;&#1091;&#1075;&#1086;&#1074;&#1086;&#1075;&#1086; &#1089;&#1077;&#1075;&#1084;&#1077;&#1085;&#1090;&#1072; (&#1090;&#1072;&#1085;&#1075;&#1077;&#1085;&#1089; &#1095;&#1077;&#1090;&#1074;&#1077;&#1088;&#1090;&#1080; &#1094;&#1077;&#1085;&#1090;&#1088;&#1072;&#1083;&#1100;&#1085;&#1086;&#1075;&#1086; &#1091;&#1075;&#1083;&#1072; &#1076;&#1091;&#1075;&#1080;).
  14.  
  15. &#1044;&#1072;&#1090;&#1072; &#1089;&#1086;&#1079;&#1076;&#1072;&#1085;&#1080;&#1103;      2000 - 2005 &#1075;&#1086;&#1076;&#1099;
  16. *****************************************************************************************
  17.  
  18. Library function.
  19.  
  20. Radius and the centre of an arc segment of the polyline set by two points and bulge
  21.  
  22. p1 - start segment point
  23. p2 - end segment point
  24. b  - bulge is the tangent of 1/4 of the included angle for the arc segment
  25.  
  26. Date of creation   2000 - 2005 years.
  27. *****************************************************************************************
  28.  
  29. (setq e  (entsel "\n Specify a polyline, in the necessary arc segment...")
  30.       b  (cdr
  31.           (nth
  32.            (fix
  33.             (vlax-curve-getParamAtPoint (car e) (vlax-curve-getClosestPointTo (car e) (cadr e)))
  34.            ) ;_  fix
  35.            (vl-remove-if-not (function (lambda (x) (= (car x) 42))) (entget (car e)))
  36.           ) ;_  nth
  37.          ) ;_  cdr
  38.       p1 (fix
  39.           (vlax-curve-getParamAtPoint (car e) (vlax-curve-getClosestPointTo (car e) (cadr e)))
  40.          ) ;_  fix
  41.       p1 (vlax-curve-getPointAtParam (car e) d)
  42.       p2 (vlax-curve-getPointAtParam (car e) (1+ d))
  43. ) ;_  setq
  44.  
  45.    
  46. (eea-cen-lw-seg p1 p2 b)
  47.  
  48. *****************************************************************************************
  49. |;
  50.  ((lambda (a v r)
  51.    ((lambda (c s vx vy r)
  52.      (list (list (+ (* (- (* vx c) (* vy s)) r) (car p1))
  53.                  (+ (* (+ (* vx s) (* vy c)) r) (cadr p1))
  54.            ) ;_  list
  55.            r
  56.      ) ;_  list
  57.     ) ;_  lambda
  58.     (cos a)
  59.     (sin a)
  60.     (cos v)
  61.     (sin v)
  62.     r
  63.    )
  64.   ) ;_  lambda
  65.   (- 1.570796326794897 (* (atan b) 2.))
  66.   (angle p1 p2)
  67.   (/ (distance p1 p2) 2. (sin (* (atan b) 2.)))
  68.  )
  69. ) ;_  defun

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Polyline point
« Reply #6 on: July 03, 2012, 08:20:41 AM »
weird formatting Russian characters in the code ...  :-o

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Polyline point
« Reply #7 on: July 05, 2012, 04:33:38 AM »
Thanks for your examples. Itīs realy complicate to understand your difficult codes

@lee-mac
Yes very good to try your codes... perfekt describtion

@fixo
It comes nearly what I want to do...

@Elpanov
Fantastic Giv me little time to do your lessons...

How can help me, I want know when I pick on a segment from polyline is it a line or arc segment


irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Polyline point
« Reply #8 on: July 05, 2012, 05:15:41 AM »
How can help me, I want know when I pick on a segment from polyline is it a line or arc segment
One way would be to find the bulge value. You obtain the index of the picked segment by using the vlax-curve-* functions. In particular the vlax-curve-GetClosestPointTo to get the exact point on the polyline from the entsel's point value. Then you get the paramater at that point through vlax-curve-GetParamAtPoint. This value is a real, it's integer portion is the index of the previous vector point - so simply use fix to get the index of the selected vector.

Now get the bulge by using the ActiveX GetBulge method. So you'll need to change the ename of the polyline to a vla-object (vlax-ename->vla-object  ;) ). Then use (vla-GetBulge <vla-obj> <index>). If the value is anything else than 0.0 then it's a curve, otherwise it's a line.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Polyline point
« Reply #9 on: July 05, 2012, 05:42:52 AM »
Here's an example of what I mean:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:CheckPLArc (/ en eo)
  2.   (if (setq en (entsel "\nPick polyline segment: "))
  3.     (if (and (setq eo (vlax-ename->vla-object (car en)))
  4.              (eq (vla-get-ObjectName eo) "AcDbPolyline"))
  5.         (alert "That segment is a line.")
  6.         (alert "That segment is an arc."))
  7.       (alert "That's not a light-weight polyline")))
  8.   (princ))

And alternative method using only the vlax-curve functions and no ActiveX.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:CheckPLArc1 (/ en param)
  2.   (if (setq en (entsel "\nPick polyline segment: "))
  3.       (if (equal (angle (vlax-curve-GetPointAtParam (car en) (fix param)) (vlax-curve-GetPointAtParam (car en) (+ 0.5 (fix param))))
  4.                  (angle (vlax-curve-GetPointAtParam (car en) (fix param)) (vlax-curve-GetPointAtParam (car en) (1+ (fix param))))
  5.                  1e-12)
  6.         (alert "That segment is a line.")
  7.         (alert "That segment is an arc."))))
  8.   (princ))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Polyline point
« Reply #10 on: July 05, 2012, 07:22:31 AM »
And alternative method using only the vlax-curve functions and no ActiveX.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:CheckPLArc1 (/ en param)
  2.   (if (setq en (entsel "\nPick polyline segment: "))
  3.       (if (equal (angle (vlax-curve-GetPointAtParam (car en) (fix param)) (vlax-curve-GetPointAtParam (car en) (+ 0.5 (fix param))))
  4.                  (angle (vlax-curve-GetPointAtParam (car en) (fix param)) (vlax-curve-GetPointAtParam (car en) (1+ (fix param))))
  5.                  1e-12)
  6.         (alert "That segment is a line.")
  7.         (alert "That segment is an arc."))))
  8.   (princ))

Alternatively,

Code - Auto/Visual Lisp: [Select]
  1. (defun c:CheckSeg ( / en )
  2.     (if
  3.         (and
  4.             (setq en (entsel "\nPick LWPolyline Segment: "))
  5.             (eq "LWPOLYLINE" (cdr (assoc 0 (entget (car en)))))
  6.         )
  7.         (if (equal '(0.0 0.0 0.0)
  8.                 (vlax-curve-getsecondderiv (car en)
  9.                     (vlax-curve-getparamatpoint (car en)
  10.                         (vlax-curve-getclosestpointto (car en) (trans (cadr en) 1 0))
  11.                     )
  12.                 )
  13.             )
  14.             (princ "\nSegment is a Line.")
  15.             (princ "\nSegment is an Arc.")
  16.         )
  17.         (princ "\nNothing Selected or Object is not an LWPolyline.")
  18.     )
  19.     (princ)
  20. )

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Polyline point
« Reply #11 on: July 05, 2012, 07:24:01 AM »
@lee-mac
Yes very good to try your codes... perfekt describtion

Thank you.

My methods are rather simple in comparison to Evgeniy, but I'm glad that my explanations were clear  :-)

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Polyline point
« Reply #12 on: July 05, 2012, 08:32:15 AM »
My methods are rather simple in comparison to Evgeniy, but I'm glad that my explanations were clear  :)
Lee, I really like this construct:
Code - Auto/Visual Lisp: [Select]
  1. (rem (+ pi pi (- ang2 ang1)) (+ pi pi))
A lot more elegant than my angle-Normal function  :kewl:

BTW, I've revamped my functions:
Code - Auto/Visual Lisp: [Select]
  1. (defun bulge->inclang (bulge /) (* 4. (atan bulge)))
  2.  
  3. (defun bulge->height (v1 bulge v2 /) (* (/ (distance v1 v2) 2.) (abs bulge)))
  4.  
  5. (defun bulge->radius  (v1 bulge v2 /)
  6.   (cond ((not (zerop bulge)) (abs (/ (/ (distance v1 v2) 2.) (sin (/ (bulge->inclang bulge) 2.)))))))
  7.  
  8. (defun midp (p1 p2 /) (mapcar (function (lambda (a b) (* (+ a b) 0.5))) p1 p2))
  9.  
  10. (defun bulge->center  (v1 bulge v2 / )
  11.   (cond ((or (zerop bulge) (equal bulge 1. 1e-16)) (midp v1 v2))
  12.         ((polar (midp v1 v2)
  13.                 ((if (> bulge 0.) + -) (angle v1 v2) (* pi 0.5))
  14.                 (- (bulge->radius v1 bulge v2) (bulge->height v1 bulge v2))))))
  15.  
  16. (defun bulge->arc (v1 bulge v2 / pC)
  17.   (list (setq pC (bulge->center v1 bulge v2))
  18.         (bulge->radius v1 bulge v2)
  19.         (angle pC v1)
  20.         (angle pC v2)))
  21.  
  22. (defun inclang->bulge (ang / ) ((lambda (a) (/ (sin a) (cos a))) (/ ang 4.)))
  23.  
  24. (defun arc->bulge (cP rad a1 a2 /)
  25.   (list (polar cP a1 rad)
  26.         (inclang->bulge (rem (+ pi pi (- a2 a1)) (+ pi pi)))
  27.         (polar cP a2 rad)))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Polyline point
« Reply #13 on: July 05, 2012, 09:04:32 AM »
Iīm impressed which different opportunities you have done. Iīm not realy understand it all but Itīs much stuff I can use and learn about "bulge " thanks so much for helping to all your are fantastic experts, I feel so smal with my Lisp-knowledge.

@irneb
how can I start your finally function ...

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Polyline point
« Reply #14 on: July 05, 2012, 10:01:09 AM »
How can help me, I want know when I pick on a segment from polyline is it a line or arc segment

way to use acet-* :
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ e)
  2.   (cond ((not (and (setq e (entsel "\nPick lwpolyline segment: ")) (= (cdadr (entget (car e))) "LWPOLYLINE"))
  3.          )
  4.          (princ "\n This is not lwpolyline!")
  5.         )
  6.                      (cadddr (ACET-PLINE-SEGMENT-LIST (entget (car e))))
  7.                 )
  8.          )
  9.          (princ "\n This is line segment.")
  10.         )
  11.         ((princ "\n This is arc segment."))
  12.   )
  13. )

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Polyline point
« Reply #15 on: July 05, 2012, 10:05:54 AM »
way of analyzing the geometry:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ e p pt)
  2.   (cond ((not (and (setq e (entsel "\nPick lwpolyline segment: ")) (= (cdadr (entget (car e))) "LWPOLYLINE"))
  3.          )
  4.          (princ "\n This is not lwpolyline!")
  5.         )
  6.                  (vlax-curve-getPointAtParam (car e) (setq p (fix (vlax-curve-getparamatpoint (car e) pt))))
  7.                  pt
  8.                  (vlax-curve-getPointAtParam (car e) (1+ p))
  9.          )
  10.          (princ "\n This is arc segment.")
  11.         )
  12.         ((princ "\n This is line segment."))
  13.   )
  14. )
« Last Edit: July 06, 2012, 12:03:05 AM by ElpanovEvgeniy »

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Polyline point
« Reply #16 on: July 05, 2012, 10:47:33 AM »
@irneb
how can I start your finally function ...
My previous post shows the new versions of my functions as I've linked to in reply #3. Sorry I should've been more clear. They're intended for use as a library of functions, not as commands.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Polyline point
« Reply #17 on: July 10, 2012, 08:06:21 AM »
Now Iīve studied little bit more. I know how can I get bulge and segments and properties from picked polylines
I understand angle = 4 * (arctan bulge)

probl 1)
But I donīt understand why I canīt get correctly radius. Formel is all rigtht

probl 2)
I want trim arc segement in 3 parts to can calculate 2 points on arc

In the end I want export alle Polylinevertex and arc-points in a txt-fil

Iīm beginner with vlisp, so Iīm little confuse with all your visual-functions.
So I try it only with Lisp

Code: [Select]
;; get bulge radius by Juergen Menzi

(defun get-radii  (p1 p2 bulge)
  (abs (/ (distance p1 p2) 2 (sin (/ (* 4 (atan (abs bulge))) 2)))))



;;; report lwpolyline vertex and bulge by Lee-Mac

(defun _lwvertices ( e )
  (if (setq e (member (assoc 10 e) e))
    (cons
      (cons
(cdr (assoc 10 e))
(cdr (assoc 42 e))
)
      (_lwvertices (cdr e))
      )
    )
  )

(defun c:t ( / ptbu i )
  (setq i 0
iL 0
iA 0)
  (if (setq ptbu (_lwvertices (entget (car (entsel "\nSelect Polyline! "))))
    ptbu (cdr (reverse ptbu))
    )
    (repeat (length ptbu)
      (cond
((equal 0.0 (cdr (nth i ptbu)))
(setq iL (1+ iL))
)
((not (equal 0.0 (setq bulge (cdr (nth i ptbu)))))
(setq p1 (car (nth i ptbu)))
(setq p2 (car (nth (1+ i) ptbu)))
(setq rad (get-radii p1 p2 bulge))
(setq iA (1+ iA))
)
)
      (setq i (1+ i))
      )
    )
  (princ (strcat "\nPolyline has\n" (itoa iL) " Line segments and"
"\n" (itoa iA) " Arc segements"))

  (princ)
  )

   


Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Polyline point
« Reply #18 on: July 10, 2012, 10:33:40 AM »
Your thread has inspired me to write this program, you may find it useful in your studies  :-)

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: Polyline point
« Reply #19 on: July 10, 2012, 03:01:05 PM »
This version uses vlax-curve to get points on arcs. No math required...:)
Of course, you can export coordinates instead drawing points.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / ss l e d z p n)
  2.   (if
  3.     (and
  4.       (setq ss (ssget ":E:S" '((0 . "lwpolyline"))))
  5.       (setq n (getint "\nArc divisions:"))
  6.       (> n 1)
  7.       )
  8.     (progn
  9.       (setq e (ssname ss 0)
  10.             z (cdr (assoc 38 (entget e)))
  11.             l (vl-remove-if-not '(lambda (x) (member (car x) '(10 42))) (entget e))
  12.             d (mapcar '(lambda (x) (/ x 1.0 n)) (repeat (1- n) (setq d (cons (1- (cond ((car d)) (n))) d))))
  13.             )
  14.       (while l
  15.         (setq p (trans (list (cadar l) (caddar l) z) e 0))
  16.         (entmake (list '(0 . "POINT") (cons 10 p)))
  17.         (if (/= 0.0 (cdadr l))
  18.           (foreach x d
  19.             (entmake (list '(0 . "POINT") (cons 10 (vlax-curve-GetPointAtParam e (+ x (vlax-curve-GetParamAtPoint e p))))))
  20.             )
  21.           )
  22.         (setq l (cddr l))
  23.         )
  24.       )
  25.     )
  26.   (princ)
  27.   )

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Polyline point
« Reply #20 on: July 10, 2012, 05:41:03 PM »
Here is quick handy tool in case you didn't get formula for radius of pline arc... Works only on arc segments of heavy or lightweight 2d polyline...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:plarcdata ( / e ent pt p p1 p2 bulge rad cen )
  2.   (setq e (entsel "\nPick arc on polyline to calculate its data"))
  3.   (setq ent (car e) pt (cadr e))
  4.   (setq bulge (vla-getbulge (vlax-ename->vla-object ent) (float (fix (vlax-curve-getparamatpoint ent p)))))
  5.   (setq rad (/ (distance p1 p2) (* 2 (sin (* 2 (atan bulge))))))
  6.   (setq cen (polar p1 (+ (angle p1 p2) (- (/ pi 2.0) (* 2 (atan bulge)))) rad))
  7.   (alert (strcat "\nRadius of arc is : " (rtos (abs rad)) "\nCenter of arc is : " (rtos (car cen)) "," (rtos (cadr cen)) "," (rtos (caddr cen)) "\nAngle of arc is : " (rtos (cvunit (* 4 (atan bulge)) "radians" "degrees"))))
  8.   (princ)
  9. )
  10.  

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Polyline point
« Reply #21 on: July 11, 2012, 03:57:39 AM »
Thanks so much for different proposals. I try it to build in my function. But it doesnīt work somtimes correctly if I have a polyline begins with line-arc-lin entities. Know somebody a better way as calc angle in circlepoint c to p1(tangent) and p2(tangent)
Hopefully you understand what I mean
Code: [Select]
(defun c:t ( /
;;;     l i
    )
  (setq i 0
iL 0
iA 0)
  (if (setq l (LM:LWVertices (entget (car (entsel "\nSelect Polyline! ")))))
    (repeat (length l)
      (cond
((equal 0.0 (cdr (assoc 42 (nth i l))))
(setq iL (1+ iL))
(entmake (list '(0 . "POINT") (cons 10 (cdar (nth i l)))))
)
((not
   (equal 0.0
  (setq b (cdr (assoc 42 (nth i l))))
  )
   )
(setq p1 (cdr (assoc 10 (nth i l))))
(entmake (list '(0 . "POINT") (assoc 10 (nth i l))))
(setq p2 (cdr (assoc 10 (nth (1+ i) l))))
(setq rad (LM:BulgeRadius p1 p2 b))
(setq c (LM:BulgeCentre p1 p2 b))
(setq iA (1+ iA))
(if
   (not
     (equal 0.0 c))
   (progn
     (setq a (- (angle c p1) (angle c p2)))
     (setq ap1 (polar c (- (angle c p1) (/ a 3)) (distance c p1)))
     (setq ap2 (polar c (- (angle c ap1) (/ a 3)) (distance c p1)))
     (entmake (list '(0 . "POINT") (cons 10 ap1)))
     (entmake (list '(0 . "POINT") (cons 10 ap2)))
     )
   )
)
)
      (setq i (1+ i))
      )
    )
  (princ (strcat "\nPolyline has\n" (itoa (1- iL)) " Line segments and"
"\n" (itoa iA) " Arc segements"))

  (princ)
  )
« Last Edit: July 11, 2012, 05:49:12 AM by cadplayer »

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Polyline point
« Reply #22 on: July 11, 2012, 04:40:19 AM »
Code: [Select]
(if
   (not
     (equal 0.0 c))
   (progn
     (setq a (- (angle c p1) (angle c p2)))
     (setq ap1 (polar c (- (angle c p1) (/ a 3)) (distance c p1)))
     (setq ap2 (polar c (- (angle c ap1) (/ a 3)) (distance c p1)))

means if it haves a centerpoint from arcentity calculate angle between lines c,p1 and c,p2. (p1 and p2 are start and endpoint of arc.)

In the case I have dubble arc in a polyline it doenīt works  idea, because I miss p2

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Polyline point
« Reply #23 on: July 11, 2012, 05:47:46 AM »
...next
« Last Edit: July 13, 2012, 01:54:16 AM by cadplayer »

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Polyline point
« Reply #24 on: July 13, 2012, 01:53:52 AM »
Can you help me. I would like have all radius of polyline which have only 3 arc segments

(setq l (LM:LWVertices (entget (car (entsel "\nSelect Polyline! "))))) ; I get all vertex but not the last one

list l looks like so...
(((10 -86.1312 67.2658) (40 . 0.0) (41 . 0.0) (42 . 0.677818))   ((10 -80.777 71.06) (40 . 0.0) (41 . 0.0) (42 . 0.348949))  ((10 -85.2064 74.5137) (40 . 0.0) (41 . 0.0) (42 . 2.38414)))
But here I miss endvertex of polyline

Thats why I have a problem: first two arcs calculates but the last canīt because VAR p2 is nil. How can I say in program the last vertex is end of polyline ?

(setq b (cdr (assoc 42 (nth i l))))
        (setq p1 (cdr (assoc 10 (nth i l))))
        (setq p2 (cdr (assoc 10 (nth (1+ i) l))))
        (setq rad (LM:BulgeRadius p1 p2 b))
        (setq c (LM:BulgeCentre p1 p2 b))
       )
« Last Edit: July 13, 2012, 04:08:36 AM by cadplayer »