Author Topic: How to Make PI (Point of Intersection) on Pline Arc  (Read 7905 times)

0 Members and 1 Guest are viewing this topic.

rashidaziz

  • Mosquito
  • Posts: 11
How to Make PI (Point of Intersection) on Pline Arc
« on: July 30, 2015, 09:22:36 AM »
I need Lisp for Draw or Make PI (point of intersection) Points on Centerline (PLINE with Arcs and Spline).
Draw only on ARC (not on Spline)
Please HELP me.

Thanks so much.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #1 on: July 30, 2015, 09:32:19 AM »
Perhaps use the vector returned by vlax-curve-getfirstderiv at the end point of the surrounding splines in conjunction with the spline end points and the inters function (with the onseg argument set to nil), i.e.:
Code: [Select]
(inters
    <spline 1 end point>
    (mapcar '+ <spline 1 end point> (vlax-curve-getfirstderiv <spline 1> (vlax-curve-getparamatpoint <spline 1> <spline 1 end point>)))
    <spline 2 end point>
    (mapcar '+ <spline 2 end point> (vlax-curve-getfirstderiv <spline 2> (vlax-curve-getparamatpoint <spline 2> <spline 2 end point>)))
    nil
)

rashidaziz

  • Mosquito
  • Posts: 11
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #2 on: July 30, 2015, 09:58:54 AM »
Thanks Lee Mac

I am very new on AutoLISP. Please make LISP Program for me to Make PI Point on All Pline Arcs

Thanks and i appreciate for Helping and very quick reply.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #3 on: July 30, 2015, 01:43:22 PM »
The section indicated as 'spline' is in fact a series of very small straight segments belonging to the same polyline as the arc segment. The curve consists of a single polyline and not 3 or more elements.

Why not do it 'manually'?:
  • Create a copy of the polyline on a dedicated layer.
  • Change the linetype of the new polyline to continuous.
  • Explode it.
  • Change the colour of the arcs to make them stand out.
  • Use the FILLET command with R=0 on the facets bordering the arcs.
  • Use the TRIM command to trim the lengthened facets using the arcs as the cutting edges.
  • Erase all redundant facets.
  • Done!
BTW:
The texts in the dwg have a rotation of 0.355561 degrees.
I get worried when I see something like that...

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #4 on: July 30, 2015, 02:01:22 PM »
Or
1. line endp osnap PC
2. int osnap each tangent for PI
3. endp osnap PT

When using fillet to add an arc I use [No trim] when those lines might come in handy later on.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #5 on: July 30, 2015, 02:37:17 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun c:welcometotheswamp (/ _angle _line e ep p sp tmp)
  2.   (defun _angle (ename pt / ang clpt e param)
  3.     (if (and (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getendparam (list ename))))
  4.              (setq clpt (vlax-curve-getclosestpointto ename pt))
  5.              (setq param (vlax-curve-getparamatpoint ename clpt))
  6.              (setq ang (angle '(0 0) (vlax-curve-getfirstderiv ename param)))
  7.         )
  8.       ang
  9.     )
  10.   )
  11.   (defun _line (p1 p2 layer)
  12.     (entmakex (list '(0 . "LINE")
  13.                     '(100 . "AcDbEntity")
  14.                     (cons 8 layer)
  15.                     (cons 10 p1)
  16.                     (cons 11 p2)
  17.               )
  18.     )
  19.   )
  20.   (if (and (setq e (car (entsel))) (setq tmp (vlax-invoke (vlax-ename->vla-object e) 'explode)))
  21.     (foreach o tmp
  22.       (if (= "AcDbArc" (vla-get-objectname o))
  23.         (progn (setq sp (vlax-curve-getstartpoint o))
  24.                (setq ep (vlax-curve-getendpoint o))
  25.                (setq p (inters sp (polar sp (_angle o sp) 1) ep (polar ep (_angle o ep) 1) nil))
  26.                (_line sp p "Intersection")
  27.                (_line ep p "Intersection")
  28.                (vla-delete o)
  29.         )
  30.         (vla-delete o)
  31.       )
  32.     )
  33.   )
  34.   (princ)
  35. )
« Last Edit: July 30, 2015, 03:25:33 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #7 on: July 30, 2015, 03:11:01 PM »

Nice!
Thanks!  :)


Although it may not be what the OP wanted  :|

« Last Edit: July 30, 2015, 03:27:22 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #8 on: July 30, 2015, 04:42:08 PM »
Or
1. line endp osnap PC
2. int osnap each tangent for PI
3. endp osnap PT

When using fillet to add an arc I use [No trim] when those lines might come in handy later on.
Can you explain this in more detail. What are PC, PI and PT?

ymg

  • Guest
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #9 on: July 30, 2015, 09:44:52 PM »
Roy,

In surveyor parlance, Tangent are straight line segment along an alignment.

PC stands for point of curvature, (beginning of Arc) although nowadays we use TC for Tangent to Curve.

PT is point of tangency that is end of the arc, nowadays CT for Curve to Tangent.

PI stand for point of intersection of two tangent.

Similarly you also have

TS  Tangent to Spiral
SC  Spiral to Curve
CS  Curve to Spiral
ST  Spiral to Tangent

ymg

« Last Edit: July 30, 2015, 10:02:03 PM by ymg »

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #10 on: July 31, 2015, 03:32:27 AM »
Thanks you ymg.
But can the second step in tombu's procedure be accomplished without creating temporary tangent lines?

rashidaziz

  • Mosquito
  • Posts: 11
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #11 on: July 31, 2015, 04:00:58 AM »
Thanks so much all of you.

My problem solved with " ronjonp" post and special thanks to " ronjonp"

I really appreciate for solving my problem.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #12 on: July 31, 2015, 08:40:28 AM »
Thanks so much all of you.

My problem solved with " ronjonp" post and special thanks to " ronjonp"

I really appreciate for solving my problem.
Glad to help out :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ymg

  • Guest
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #13 on: July 31, 2015, 09:47:26 AM »
Here is another way:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:calcpi (/ bulge ptcp pct delta/2 ang chord radius tangent enpi pilst)
  2.    
  3.    (setq  en (car (entsel "Select Alignment: "))
  4.          lst (listpolb en)
  5.        pilst nil         
  6.    )     
  7.    (while (> (length lst) 1)
  8.       (if (not (zerop (setq bulge (cadar lst))))
  9.          (setq     ptc (caar lst)
  10.                    pct (caadr lst)
  11.                delta/2 (* (atan bulge) 2.0)
  12.                    ang (- (angle ptc pct) delta/2)     
  13.                  chord (distance ptc pct)
  14.                 radius (/ chord (* 2 (sin delta/2)))
  15.                tangent (* radius (tan delta/2))
  16.                  pilst (cons (polar ptc ang tangent) pilst)
  17.                   enpi (entmakex (list (cons 0 "POINT") (cons 10 (car pilst))))
  18.          )
  19.       )
  20.       (setq lst (cdr lst))
  21.    )
  22.    (print pilst)
  23.    (princ)
  24. )
  25.  
  26. ;; tan   From std-lib                                                         ;
  27. (defun tan (z / cosz)
  28.   (cond ((zerop (rem z pi)) 0.0)       
  29.         ((zerop (rem z (/ pi 2))) 1.7e308)
  30.         ((zerop (setq cosz (cos z))) 1.7e308)  
  31.         (t (/ (sin z) cosz))))
  32.  
  33.  
  34. ;;                                                                            ;
  35. ;; listpolb     by ymg    (Simplified a Routine by Gile Chanteau              ;
  36. ;;                                                                            ;
  37. ;; Parameter:  en,  Entity Name or Object Name of Any Type of Polyline        ;
  38. ;;                                                                            ;
  39. ;; Returns:   List of Points and Bulge in Current UCS                         ;
  40. ;;                                                                            ;
  41. ;; Notes:      On Closed Polyline the Last Vertex is Same as First)           ;
  42. ;;                                                                            ;
  43.  
  44. (defun listpolb (en / i p l)  
  45.    (repeat (setq i (fix (1+ (vlax-curve-getEndParam en))))           
  46.       (setq l (cons (list (trans (vlax-curve-getPointAtParam en (setq i (1- i))) 0 1)
  47.                              (vla-getbulge (vlax-ename->vla-object en) i)
  48.                     )
  49.                     l
  50.               )    
  51.       )
  52.    )
  53. )
  54.  
« Last Edit: July 31, 2015, 02:13:45 PM by ymg »

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #14 on: August 01, 2015, 05:20:17 AM »
@ ymg:
Nice to see some 'old school' trigonometry.
Three things to have another look at:
The (listpolb) function cannot handle closed polylines and does not translate from WCS to OCS.
The PI points should be translated from OCS to WCS.
Perhaps exclude bulge=1/-1.

ymg

  • Guest
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #15 on: August 01, 2015, 10:09:20 AM »
Roy,

Old school for sure!!

A bulge of +/- 1 would be a 180 degree curves
which theoretically can happen.

I'll check listpolb but it should repeat the first point
at the end of the list.

Thanks for comments!
.
ymg

ymg

  • Guest
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #16 on: August 02, 2015, 11:52:48 AM »
Roy,

Here I've modified "listpolb" so that it works with closed polyline.

For the case of bulges equals to +/- 1, I did not bother as in the
context of an alignment such a curve would be split in two curves.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:calcpi (/ bulge ptcp pct delta/2 ang chord radius tangent enpi pilst)
  2.    
  3.    (setq  en (car (entsel "Select Alignment: "))
  4.          lst (listpolb en)
  5.        pilst nil         
  6.    )     
  7.    (while (> (length lst) 1)
  8.       (if (not (zerop (setq bulge (cadar lst))))
  9.          (setq     ptc (caar lst)
  10.                    pct (caadr lst)
  11.                delta/2 (* (atan bulge) 2.0)
  12.                    ang (- (angle ptc pct) delta/2)     
  13.                  chord (distance ptc pct)
  14.                 radius (/ chord (* 2 (sin delta/2)))
  15.                tangent (* radius (tan delta/2))
  16.                  pilst (cons (polar ptc ang tangent) pilst)
  17.                   enpi (entmakex (list (cons 0 "POINT") (cons 10 (car pilst))))
  18.          )
  19.       )
  20.       (setq lst (cdr lst))
  21.    )
  22.    (print pilst)
  23.    (princ)
  24. )
  25.  
  26. ;; tan   From std-lib                                                         ;
  27. (defun tan (z / cosz)
  28.   (cond ((zerop (rem z pi)) 0.0)       
  29.         ((zerop (rem z (/ pi 2))) 1.7e308)
  30.         ((zerop (setq cosz (cos z))) 1.7e308)  
  31.         (t (/ (sin z) cosz))))
  32.  
  33.  
  34. ;;                                                                            ;
  35. ;; listpolb     by ymg                                                        ;
  36. ;;                                                                            ;
  37. ;; Parameter:  en,  Entity Name  or Object Name                               ;
  38. ;;                                                                            ;
  39. ;; Returns:   List of Points and Bulge in WCS                                 ;
  40. ;;                                                                            ;
  41. ;; Notes:      On Closed Polyline the Last Vertex is Same as First)           ;
  42. ;;                                                                            ;
  43.  
  44. (defun listpolb (en / obj i p l)
  45.    (if (= (type en) 'ENAME)
  46.       (setq obj (vlax-ename->vla-object en))
  47.       (setq obj en en (vlax-vla-object->ename en))
  48.    )         
  49.    (repeat (setq i (fix (vlax-curve-getEndParam en)))        
  50.       (setq l (cons (list (vlax-curve-getPointAtParam en (setq i (1- i)))
  51.                              (vla-getbulge obj i)
  52.                     )
  53.                     l
  54.               )    
  55.       )
  56.    )
  57.    (if (= (vla-get-closed obj) :vlax-true)
  58.       (append l (list (car l)))
  59.       l
  60.    )
  61. )
  62.  

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #17 on: August 04, 2015, 06:05:00 AM »
FWIW: Here is a function inspired by this topic.
Code - Auto/Visual Lisp: [Select]
  1. ; Obj must be an "AcDb2dPolyline" of the acsimplepoly type or an "AcDbPolyline".
  2. ; Return value: Point in WCS.
  3. ; (mapcar '- (_Geom_PolylineArcTangentialInters (vlax-ename->vla-object (car (entsel))) 0) (getpoint "\nPoint: "))
  4. (defun _Geom_PolylineArcTangentialInters (obj idx / ang bulge ptSta ptEnd)
  5.   (if
  6.     (and
  7.       (< idx (vlax-curve-getendparam obj))
  8.       (not (equal 0.0 (setq bulge (vla-getbulge obj idx)) (_Math_FuzzDefault)))
  9.       (not (equal 1.0 (abs bulge) (_Math_FuzzDefault)))
  10.     )
  11.     (progn
  12.       (setq ptSta (vlax-get obj 'coordinate idx))
  13.       (setq ptEnd (vlax-get obj 'coordinate (1+ idx)))
  14.       (trans
  15.         (append
  16.           (_Geom_XYof
  17.             (polar
  18.               ptSta
  19.               (- (angle ptSta ptEnd) (setq ang (* 2.0 (atan bulge))))
  20.               (/ (distance ptSta ptEnd) 2.0 (cos ang))
  21.             )
  22.           )
  23.           (list (vla-get-elevation obj))
  24.         )
  25.         (vlax-get obj 'normal)
  26.         0
  27.       )
  28.     )
  29.   )
  30. )
  31.  
  32. (defun _Geom_XYof (pt)
  33.   (list
  34.     (_Geom_Xof pt)
  35.     (_Geom_Yof pt)
  36.   )
  37. )
  38.  
  39. (defun _Geom_Xof (pt)
  40.   (if (car pt)
  41.     (float (car pt))
  42.     0.0
  43.   )
  44. )
  45.  
  46. (defun _Geom_Yof (pt)
  47.   (if (cadr pt)
  48.     (float (cadr pt))
  49.     0.0
  50.   )
  51. )
  52.  
  53. (defun _Math_FuzzDefault ()
  54.   0.00000001
  55. )

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #18 on: August 08, 2015, 04:20:51 PM »

Nice!
Thanks!  :)


Although it may not be what the OP wanted  :|
Turned out it was!

I modified it to work with preselected objects as well including arcs & lwpolylines.  I use right-click menus for modifying so I needed the preselected option.
Code - Auto/Visual Lisp: [Select]
  1. ; by ronjonp
  2. ; modified it to work with preselected objects as well including arcs & lwpolylines - by Tom Beauford
  3. ; (load "AddArcTangents.lsp") AddArcTangents
  4. ; ^P(or C:AddArcTangents (load "AddArcTangents.lsp"));AddArcTangents
  5. ; http://www.theswamp.org/index.php?topic=49865.msg550417#msg550417
  6. (defun c:AddArcTangents (/ _angle _line e ep p sp tmp)
  7.   (defun _angle (ename pt / ang clpt e param)
  8.     (if (and (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getendparam (list ename))))
  9.              (setq clpt (vlax-curve-getclosestpointto ename pt))
  10.              (setq param (vlax-curve-getparamatpoint ename clpt))
  11.              (setq ang (angle '(0 0) (vlax-curve-getfirstderiv ename param)))
  12.         )
  13.       ang
  14.     )
  15.   )
  16.   (defun _line (p1 p2 layer)
  17.     (entmakex (list '(0 . "LINE")
  18.                     '(100 . "AcDbEntity")
  19.                     (cons 8 layer)
  20.                     (cons 10 p1)
  21.                     (cons 11 p2)
  22.               )
  23.     )
  24.   )
  25.  
  26.   (princ "\nSelect Arc or Polyline ")
  27.   (setq tmp (ssget "+.:E:S" '((0 . "arc,lwpolyline"))))
  28.   (if tmp
  29.     (progn
  30.       (setq e (ssname tmp 0)
  31.             EnTyp (cdr (assoc 0 (entget e)))
  32.       )
  33.       (if (= EnTyp "LWPOLYLINE")
  34.         (setq tmp (vlax-invoke (vlax-ename->vla-object e) 'explode))
  35.         (setq tmp (list (vlax-ename->vla-object e)))
  36.       )
  37. ;  (if (and (setq e (car (entsel))) (setq tmp (vlax-invoke (vlax-ename->vla-object e) 'explode)))
  38.       (foreach o tmp
  39.         (if (= "AcDbArc" (vla-get-objectname o))
  40.           (progn (setq sp (vlax-curve-getstartpoint o))
  41.                  (setq ep (vlax-curve-getendpoint o))
  42.                  (setq p (inters sp (polar sp (_angle o sp) 1) ep (polar ep (_angle o ep) 1) nil))
  43.                  (_line sp p "Intersection")
  44.                  (_line ep p "Intersection")
  45.                  (if (= EnTyp "LWPOLYLINE")(vla-delete o))
  46.           )
  47.           (if (= EnTyp "LWPOLYLINE")(vla-delete o))
  48.         )
  49.       )
  50.     )
  51.   )
  52.  
  53.   (princ)
  54. )
Thanks again!
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #19 on: August 08, 2015, 09:21:34 PM »

Nice!
Thanks!  :)


Although it may not be what the OP wanted  :|
Turned out it was!

I modified it to work with preselected objects as well including arcs & lwpolylines.  I use right-click menus for modifying so I needed the preselected option.
Code - Auto/Visual Lisp: [Select]
  1. ; by ronjonp
  2. ; modified it to work with preselected objects as well including arcs & lwpolylines - by Tom Beauford
  3. ; (load "AddArcTangents.lsp") AddArcTangents
  4. ; ^P(or C:AddArcTangents (load "AddArcTangents.lsp"));AddArcTangents
  5. ; http://www.theswamp.org/index.php?topic=49865.msg550417#msg550417
  6. (defun c:AddArcTangents (/ _angle _line e ep p sp tmp)
  7.   (defun _angle   (ename pt / ang clpt e param)
  8.     (if   (and (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getendparam (list ename))))
  9.         (setq clpt (vlax-curve-getclosestpointto ename pt))
  10.         (setq param (vlax-curve-getparamatpoint ename clpt))
  11.         (setq ang (angle '(0 0) (vlax-curve-getfirstderiv ename param)))
  12.    )
  13.       ang
  14.     )
  15.   )
  16.   (defun _line (p1 p2 layer)
  17.     (entmakex (list '(0 . "LINE")
  18.           '(100 . "AcDbEntity")
  19.           (cons 8 layer)
  20.           (cons 10 p1)
  21.           (cons 11 p2)
  22.          )
  23.     )
  24.   )
  25.  
  26.   (princ "\nSelect Arc or Polyline ")
  27.   (setq tmp (ssget "+.:E:S" '((0 . "arc,lwpolyline"))))
  28.   (if tmp
  29.     (progn
  30.       (setq e (ssname tmp 0)
  31.        EnTyp (cdr (assoc 0 (entget e)))
  32.       )
  33.       (if (= EnTyp "LWPOLYLINE")
  34.    (setq tmp (vlax-invoke (vlax-ename->vla-object e) 'explode))
  35.    (setq tmp (list (vlax-ename->vla-object e)))
  36.       )
  37. ;  (if (and (setq e (car (entsel))) (setq tmp (vlax-invoke (vlax-ename->vla-object e) 'explode)))
  38.       (foreach o tmp
  39.         (if (= "AcDbArc" (vla-get-objectname o))
  40.        (progn (setq sp (vlax-curve-getstartpoint o))
  41.             (setq ep (vlax-curve-getendpoint o))
  42.             (setq p (inters sp (polar sp (_angle o sp) 1) ep (polar ep (_angle o ep) 1) nil))
  43.             (_line sp p "Intersection")
  44.             (_line ep p "Intersection")
  45.             (if (= EnTyp "LWPOLYLINE")(vla-delete o))
  46.      )
  47.      (if (= EnTyp "LWPOLYLINE")(vla-delete o))
  48.         )
  49.       )
  50.     )
  51.   )
  52.  
  53.   (princ)
  54. )
Thanks again!
Glad you could make use of it  :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

rashidaziz

  • Mosquito
  • Posts: 11
Re: How to Make PI (Point of Intersection) on Pline Arc
« Reply #20 on: August 10, 2015, 04:00:18 PM »
Thanks so much all of you,

Awesome work.

Thanks again