Author Topic: callibrate a 3dPolyline  (Read 4988 times)

0 Members and 1 Guest are viewing this topic.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
callibrate a 3dPolyline
« on: October 16, 2013, 07:20:08 AM »
Hello!

Iīm wondering if somebody have thought about how I can  modify a 3dPolyline like picture "before" to two 3dPolyline like picture "after".
It coming from surfeyor as he gones sections of a road with same pointCodes. My function draws a 3dPoly after direction of pointNumber. But in this point I need propose improvements.
Anybody a idea how to begin ?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: callibrate a 3dPolyline
« Reply #1 on: October 16, 2013, 07:31:51 AM »
I don't see any images Dirk...

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: callibrate a 3dPolyline
« Reply #2 on: October 16, 2013, 07:42:47 AM »
oh sorry I forgot it ...
white line shows the direction as Polyline was measured.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: callibrate a 3dPolyline
« Reply #3 on: October 16, 2013, 08:45:24 AM »
Still on my second cup of coffee so maybe I'm not awake yet, but are we looking at a before profile (bottom purple line)
and an after profile (top purple line)?

What pline are you trying to create?
I've reached the age where the happy hour is a nap. (°ŋ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: callibrate a 3dPolyline
« Reply #4 on: October 16, 2013, 09:16:54 AM »
No itīs not a profile itīs in plan view I mean the man out measured one 3dPolyline in this form as white line shows. Now I want to convert this Polyline (white) in two Polylines (magenta) so it will be two straight Polylines.
I have a try with select Polyline and compare angle between first and next segment. If the angle is bigger than 10grads third Polylinevertex erased. Can you follow me?

PS.(thanks Gile for your great stringSplitter)

Code: [Select]
;;; (sublist '(1 2 3 4 5 6) 2 2) -> (3 4)
(defun sublist (lst start leng / n r)
  (if (or (not leng) (< (- (length lst) start) leng))
    (setq leng (- (length lst) start))
  )
  (setq n (+ start leng))
  (repeat leng
    (setq r (cons (nth (setq n (1- n)) lst) r))
  )
)
;; (split-list '(1 2 3 4 5 6 7 8) 2) -> ((1 2) (3 4) (5 6) (7 8))
(defun split-list (lst n)
  (if lst
    (cons (sublist lst 0 n)
  (split-list (sublist lst n nil) n)
    )
  )
)
(defun c:foo (/ z ent)
  (while (= z nil)
    (if (setq ent (entsel "\nSelect Polyline" ))
      (if (or (= "POLYLINE" (cdr (assoc 0 (entget (car ent)))))
      (= "LWPOLYLINE" (cdr (assoc 0 (entget (car ent)))))
   )
(progn
  (setq z 0)
  (setq coordList (split-list (vlax-get (vlax-ename->vla-object (car ent)) 'Coordinates) 3))
)
(princ "\n No Polyline selected")

      )
      (setq z nil)
    )
   )
  (setq z nil)
  (princ)
  )

(defun checkSegments ( p1 p2 p3)
  (if (equal (angle p1 p2) (angle p2 p3) (* pi (/ 10 180)))
    (setq lista  (append (list lista) (list p1) (list p2) (list p3)))
    (setq lista  (append (list lista) (list p1) (list p2)))
    )
  )
(defun c:test ()
  (while (/= coordList nil)
    (checkSegments
      (car coordList)
      (cadr coordList)
      (caddr coordList)
      )
    (setq coordList (cdr coordList))(setq coordList (cdr coordList))(setq coordList (cdr coordList))
    )
  )

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: callibrate a 3dPolyline
« Reply #5 on: October 16, 2013, 09:28:51 AM »
Sorry was a error
Code: [Select]
(defun checkSegments ( p1 p2 p3)
  (if (equal (angle p1 p2) (angle p2 p3) (* pi (/ 10 180)))
    (setq lista  (append lista (list p1) (list p2) (list p3)))
    (setq lista  (append lista (list p1) (list p2)))
    )
  (setq mspace (vla-get-ModelSpace
(vla-get-ActiveDocument
   (vlax-get-acad-object)
   )
)
  )
  (vlax-invoke mspace 'Add3dPoly (apply 'append (reverse lista)))
  (princ)
  )

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: callibrate a 3dPolyline
« Reply #6 on: October 16, 2013, 10:12:19 AM »
Take a look on this video, maby better than my explanation

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: callibrate a 3dPolyline
« Reply #7 on: October 17, 2013, 02:07:44 AM »
my idea is to check segment (a) and follow segment (b), if the follow segment(b) goes ca. same angle as segment(a) it should draw a new 3dPolyline otherwise it should stop drawing and check next follow segment(c). Endresult will be a 3dPolyline that goes straight along so I did it in video.

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: callibrate a 3dPolyline
« Reply #8 on: October 17, 2013, 06:19:02 AM »
This worked on my example - see attachment...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:reconst3dpoly (/ 3dpl fuzzang fuzzangr initang pt ptlst pt1lst pt2lst ptlst1 ptlst11 ptlst2 ss tst tt vert)
  2.   (prompt "\nPick zig-zag reference 3d polyline")
  3.   (while (not ss)
  4.     (setq ss (ssget "_+.:E:S:L" (list '(0 . "POLYLINE") '(70 . 8))))
  5.     (if (not ss) (prompt "\nMissed, try again"))
  6.   )
  7.   (setq 3dpl (ssname ss 0))
  8.   (setq vert 3dpl)
  9.   (while (and (setq vert (entnext vert)) (eq (cdr (assoc 0 (entget vert))) "VERTEX"))
  10.     (setq pt (cdr (assoc 10 (entget vert))))
  11.     (setq ptlst (cons pt ptlst))
  12.   )
  13.   (setq ptlst (reverse ptlst))
  14.   (initget 7)
  15.   (setq fuzzang (getreal "\nInput fuzz tolerance angle in decimal degrees for recreating new 3d polyines of reference 3d polyline vertices: "))
  16.   (setq fuzzangr (* (/ fuzzang 180.0) pi))
  17.   (setq initang (angle (car ptlst) (cadr ptlst)))
  18.   (setq pt2lst ptlst)
  19.   (foreach pt1 ptlst
  20.     (setq pt1lst (cons pt1 pt1lst))
  21.     (foreach pt pt1lst (setq pt2lst (vl-remove pt pt2lst)))
  22.     (if (and ptlst1 (equal pt1 (car ptlst1) 1e-6)) (setq tt nil))
  23.     (foreach pt2 pt2lst
  24.       (if (and (not tt) (equal (angle pt1 pt2) initang fuzzangr)) (progn (setq initang (angle pt1 pt2)) (setq ptlst1 (cons pt1 ptlst1) ptlst1 (cons pt2 ptlst1) tt t)))
  25.     )
  26.   )
  27.   (setq ptlst1 (reverse ptlst1))
  28.   (setq ptlst1 (acet-list-remove-duplicates ptlst1 1e-6))
  29.   (setq initang (angle (car ptlst1) (cadr ptlst1)))
  30.   (setq tst (mapcar '(lambda (a b) (if (equal (angle a b) initang fuzzangr) (progn (setq initang (angle a b)) T) nil)) ptlst1 (cdr ptlst1)))
  31.   (while (eq (car tst) T)
  32.     (setq ptlst11 (cons (car ptlst1) ptlst11))
  33.     (setq ptlst1 (cdr ptlst1) tst (cdr tst))
  34.   )
  35.   (setq ptlst11 (cons (car ptlst1) ptlst11))
  36.   (setq ptlst1 ptlst11)
  37.   (setq ptlst2 ptlst)
  38.   (foreach pt ptlst1
  39.     (setq ptlst2 (vl-remove pt ptlst2))
  40.   )
  41.   (entmake
  42.     (list
  43.       '(0 . "POLYLINE")
  44.       '(100 . "AcDbEntity")
  45.       '(100 . "AcDb3dPolyline")
  46.       '(66 . 1)
  47.       '(62 . 1)
  48.       '(10 0.0 0.0 0.0)
  49.       '(70 . 8)
  50.       '(210 0.0 0.0 1.0)
  51.     )
  52.   )
  53.   (foreach pt ptlst1
  54.     (entmake
  55.       (list
  56.         '(0 . "VERTEX")
  57.         '(100 . "AcDbEntity")
  58.         '(100 . "AcDbVertex")
  59.         '(100 . "AcDb3dPolylineVertex")
  60.         (cons 10 pt)
  61.         '(70 . 32)
  62.       )
  63.     )
  64.   )
  65.     (list
  66.       '(0 . "SEQEND")
  67.       '(100 . "AcDbEntity")
  68.     )
  69.   )
  70.   (entmake
  71.     (list
  72.       '(0 . "POLYLINE")
  73.       '(100 . "AcDbEntity")
  74.       '(100 . "AcDb3dPolyline")
  75.       '(66 . 1)
  76.       '(62 . 1)
  77.       '(10 0.0 0.0 0.0)
  78.       '(70 . 8)
  79.       '(210 0.0 0.0 1.0)
  80.     )
  81.   )
  82.   (foreach pt ptlst2
  83.     (entmake
  84.       (list
  85.         '(0 . "VERTEX")
  86.         '(100 . "AcDbEntity")
  87.         '(100 . "AcDbVertex")
  88.         '(100 . "AcDb3dPolylineVertex")
  89.         (cons 10 pt)
  90.         '(70 . 32)
  91.       )
  92.     )
  93.   )
  94.     (list
  95.       '(0 . "SEQEND")
  96.       '(100 . "AcDbEntity")
  97.     )
  98.   )
  99.   (princ)
  100. )
  101.  

M.R.
« Last Edit: October 17, 2013, 01:18:59 PM by ribarm »
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: callibrate a 3dPolyline
« Reply #9 on: October 17, 2013, 06:45:14 AM »
Thanks for big effort Marco, I test on your example, but I donīt get it. I donīt realy understand which fuzzy I should typing.

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: callibrate a 3dPolyline
« Reply #10 on: October 17, 2013, 07:00:54 AM »
For my example it's 15-20 degree, but if top projection of imaginary 3d poly connections are close to line the fuzz angle should be smaller...
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: callibrate a 3dPolyline
« Reply #11 on: October 17, 2013, 07:36:06 AM »
How do I know, which angle I must typing - "try and error" or can I get help. Do you mean angle of first Polylinesegment ?

My try to get angle of segment like this... itīs not helping
Code: [Select]
(setq fuzzang (getreal (strcat "\nInput fuzz tolerance angle in decimal degrees for recreating new 3d polyines of reference 3d polyline vertices: " (rtos (* (/ 180 pi) (angle (car ptlst) (cadr ptlst))) 2 (getvar "AUPREC")))))
« Last Edit: October 17, 2013, 07:46:20 AM by cadplayer »

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: callibrate a 3dPolyline
« Reply #12 on: October 17, 2013, 09:12:21 AM »
Look cadplayer, this angle is tolerance angle, not angle of starting segment... As I said if top projections of imaginary connections of resulting polylines are close to straight line, that angle should be near 0.0 degree - 0.0 isn't allowed so you must enter 1.0 or some small angle, and if projections are curving, like in my posted example then you should enter angle close to difference angles of adjacent segments of imaginary projection polyline...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: callibrate a 3dPolyline
« Reply #13 on: October 17, 2013, 09:29:43 AM »
Marko,
Running the routine I get a copy of the original less the north end segments.
Not an outside trace as requested. I used one & 5 & then 10 as the angle tolerance.

I've reached the age where the happy hour is a nap. (°ŋ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: callibrate a 3dPolyline
« Reply #14 on: October 17, 2013, 09:36:07 AM »
Marko, can you explain, what did it do your code. You collect all vertex and than your working with a toleranz angle from what. Is it the angle between seg1 to seg2 and seg2 to seg3 and seg3 to seg 4 ... ?
My example in last drawing didnīt work if I typed 1, 5, 10 or 15 degrees