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

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: callibrate a 3dPolyline
« Reply #15 on: October 17, 2013, 09:37:48 AM »
My approach would be to create an average or center line & then plot the points that were the greatest distance from one side & then the other side.
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.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: callibrate a 3dPolyline
« Reply #16 on: October 17, 2013, 10:45:31 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

Tolerance angle is little greater angle than greatest angle of differences between all pairs of adjacent segments of imaginary reconstruction 3dpolys... For ex. approx. angle between seg1 and seg2 is 10 degrees; between seg2 and seg3 is 12.5 degrees, between seg3 and seg4 is 11.0 degrees... From these angles greatest one is 12.5 degrees => tolerance angle is just little greater than 12.5 degrees => 12.6 degrees... But note that tolerance angle must be less than between segments that do zig-zag of real top projection of reference 3dpoly that you pick... So if zig-zag angle is 30 degrees, 12.6 degrees will satisfy this case, but if you enter tolerance 35 degrees, CAD will assume that first point list vertices that are to be used in entmaking first of 2 recreation 3dpolys are the same as original point list of picked reference 3dpoly, so CAD will entmake 1st 3dpoly the same as picked reference 3dpoly, and 2nd 3dpoly won't make... So this angle is important to be exact... In some cases in witch zig-zag angle is smaller than greatest adjacent imaginary angle of 3dpoly that is to be made it is impossible to create these 2 3dpolys... Simply CAD will overdraw 3dpoly over original 3dpoly... This is my approach, maybe there is better way, but be aware that this are 3dpolys that you are operating with so center 3dpoly for reference that could be used for making first and second reconstruct 3dpolys from each side isn't possible to determine, so perhaps you could make center reference 2d poly and according to this reference do operation of entmaking 3dpolys from each side in 3d...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: callibrate a 3dPolyline
« Reply #17 on: October 17, 2013, 01:20:25 PM »
Sorry, I had mistake in my code... Please, do test it now - look in my post where I modified the code...

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: callibrate a 3dPolyline
« Reply #18 on: October 18, 2013, 04:12:06 AM »
Hi Marco!

I must thinking little more, I donīt get working your function in all cases.
Thanks a lot!

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: callibrate a 3dPolyline
« Reply #19 on: October 18, 2013, 02:07:04 PM »
cadplayer, please check my revision of your DWG - see attachment... DWG is in R2010 file format...

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

:)

M.R. on Youtube

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: callibrate a 3dPolyline
« Reply #20 on: October 18, 2013, 02:54:48 PM »
For me (ACAD2006) it just traces over existing pline.

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.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: callibrate a 3dPolyline
« Reply #21 on: October 18, 2013, 03:16:52 PM »
Here are 2 helper codes for preparing DWG...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:clean3dpoly (/ ss 3dpl vert pt ptlst ptlstclean)
  2.   (prompt "\nPick 3dpoly to clean its overlapping vertices")
  3.   (while (not ss)
  4.     (setq ss (ssget "_+.:E:S:L" (list '(0 . "POLYLINE") '(-4 . "&=") '(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.   (setq ptlstclean (acet-list-remove-duplicates ptlst 1e-2))
  15.   (entmake (vl-remove-if '(lambda (x) (member (car x) '(-1 5))) (entget 3dpl)))
  16.   (foreach pt ptlstclean
  17.     (entmake
  18.       (list
  19.         '(0 . "VERTEX")
  20.         '(100 . "AcDbEntity")
  21.         '(100 . "AcDbVertex")
  22.         '(100 . "AcDb3dPolylineVertex")
  23.         (cons 10 pt)
  24.         '(70 . 32)
  25.       )
  26.     )
  27.   )
  28.     (list
  29.       '(0 . "SEQEND")
  30.       '(100 . "AcDbEntity")
  31.     )
  32.   )
  33.   (entdel 3dpl)
  34.   (princ)
  35. )
  36.  

Code - Auto/Visual Lisp: [Select]
  1. (defun c:clean3dpolys (/ ss)
  2.  
  3.   (defun clean3dpoly (3dpl / vert pt ptlst ptlstclean)
  4.     (setq vert 3dpl)
  5.     (while (and (setq vert (entnext vert)) (eq (cdr (assoc 0 (entget vert))) "VERTEX"))
  6.       (setq pt (cdr (assoc 10 (entget vert))))
  7.       (setq ptlst (cons pt ptlst))
  8.     )
  9.     (setq ptlst (reverse ptlst))
  10.     (setq ptlstclean (acet-list-remove-duplicates ptlst 1e-2))
  11.     (entmake (vl-remove-if '(lambda (x) (member (car x) '(-1 5))) (entget 3dpl)))
  12.     (foreach pt ptlstclean
  13.       (entmake
  14.         (list
  15.           '(0 . "VERTEX")
  16.           '(100 . "AcDbEntity")
  17.           '(100 . "AcDbVertex")
  18.           '(100 . "AcDb3dPolylineVertex")
  19.           (cons 10 pt)
  20.           '(70 . 32)
  21.         )
  22.       )
  23.     )
  24.     (entmake
  25.       (list
  26.         '(0 . "SEQEND")
  27.         '(100 . "AcDbEntity")
  28.       )
  29.     )
  30.     (entdel 3dpl)
  31.   )
  32.  
  33.   (prompt "\nSelect 3dpolys to clean their overlapping vertices")
  34.   (while (not ss)
  35.     (setq ss (ssget "_:L" (list '(0 . "POLYLINE") '(-4 . "&=") '(70 . 8))))
  36.     (if (not ss) (prompt "\nEmpty selection, try again..."))
  37.   )
  38.   (mapcar '(lambda (x) (clean3dpoly x)) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
  39.   (princ)
  40. )
  41.  

This is intended to be used for DWG that has 3dpolys with overlapping vertices - so in "3dpoly.dwg" you attached Dirk...
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 #22 on: October 29, 2013, 06:17:03 AM »
Hi Marko!

Sorry for dellay. I come a bit forward and would like use your routine more practically. Your routine works fine, but if I run I have to know which tollerance I must type in. In my example it was 7.67 deg, but how can I know this in beginning. Have I to measure every segmentsdiff in angle or is there a esier way. I try to generate all diffence angles some text. I would be nice it comes before I must type in tollerance angle.
A big compliment to your effort.

Code: [Select]
(defun c:reconst3dpoly (/ 3dpl fuzzang fuzzangr initang pt ptlst pt1lst pt2lst ptlst1 ptlst11 ptlst2 ss tst tt vert)

  (prompt "\nPick zig-zag reference 3d polyline")

  (while (not ss)

    (setq ss (ssget "_+.:E:S:L" (list '(0 . "POLYLINE") '(70 . 8))))

    (if (not ss) (prompt "\nMissed, try again"))

  )

  (setq 3dpl (ssname ss 0))

  (setq vert 3dpl)

  (while (and (setq vert (entnext vert)) (eq (cdr (assoc 0 (entget vert))) "VERTEX"))

    (setq pt (cdr (assoc 10 (entget vert))))

    (setq ptlst (cons pt ptlst))

  )

  (setq ptlst (reverse ptlst))

  (initget 7)

  (setq fuzzang (getreal "\nInput fuzz tolerance angle in decimal degrees for recreating new 3d polyines of reference 3d polyline vertices: "))

  (setq fuzzangr (* (/ fuzzang 180.0) pi))

  (setq initang (angle (car ptlst) (cadr ptlst)))

  (setq pt2lst ptlst)

  (foreach pt1 ptlst

    (setq pt1lst (cons pt1 pt1lst))

    (foreach pt pt1lst (setq pt2lst (vl-remove pt pt2lst)))

    (if (and ptlst1 (equal pt1 (car ptlst1) 1e-6)) (setq tt nil))

    (foreach pt2 pt2lst

      (if (and (not tt)
       (equal (setq diffan (angle pt1 pt2)) initang fuzzangr))
(progn
  (setq diffan (/ (* 180 (- diffan initang)) pi))
  (setq initang (angle pt1 pt2))
  (setq ptlst1 (cons pt1 ptlst1)
ptlst1 (cons pt2 ptlst1)
tt t
)
  (entmake (list '(0 . "TEXT")
               '(100 . "AcDbEntity")
               '(100 . "AcDbText")
               (cons 10 (trans pt1 1 0))
               (cons 8 (getvar "CLAYER"))
               (cons 7 "SIMPLEX8"); Textstyle
               (cons 62 3) ; TextColor
       (cons 40 (getvar "TEXTSIZE")); Textsize
       (cons 41 0.8) ; TextWidth
       (cons 50 0) ; TextAngle
       (cons 1 (rtos diffan 2 (getvar "AUPREC"))) ; Textmessage
               )
      )

  )
)

    )

  )

  (setq ptlst1 (reverse ptlst1))

  (setq ptlst1 (acet-list-remove-duplicates ptlst1 1e-6))

  (setq initang (angle (car ptlst1) (cadr ptlst1)))

  (setq tst (mapcar '(lambda (a b) (if (equal (angle a b) initang fuzzangr) (progn (setq initang (angle a b)) T) nil)) ptlst1 (cdr ptlst1)))

  (while (eq (car tst) T)

    (setq ptlst11 (cons (car ptlst1) ptlst11))

    (setq ptlst1 (cdr ptlst1) tst (cdr tst))

  )

  (setq ptlst11 (cons (car ptlst1) ptlst11))

  (setq ptlst1 ptlst11)

  (setq ptlst2 ptlst)

  (foreach pt ptlst1

    (setq ptlst2 (vl-remove pt ptlst2))

  )

  (entmake

    (list

      '(0 . "POLYLINE")

      '(100 . "AcDbEntity")

      '(100 . "AcDb3dPolyline")

      '(66 . 1)

      '(62 . 1)

      '(10 0.0 0.0 0.0)

      '(70 . 8)

      '(210 0.0 0.0 1.0)

    )

  )

  (foreach pt ptlst1

    (entmake

      (list

        '(0 . "VERTEX")

        '(100 . "AcDbEntity")

        '(100 . "AcDbVertex")

        '(100 . "AcDb3dPolylineVertex")

        (cons 10 pt)

        '(70 . 32)

      )

    )

  )

  (entmake

    (list

      '(0 . "SEQEND")

      '(100 . "AcDbEntity")

    )

  )

  (entmake

    (list

      '(0 . "POLYLINE")

      '(100 . "AcDbEntity")

      '(100 . "AcDb3dPolyline")

      '(66 . 1)

      '(62 . 1)

      '(10 0.0 0.0 0.0)

      '(70 . 8)

      '(210 0.0 0.0 1.0)

    )

  )

  (foreach pt ptlst2

    (entmake

      (list

        '(0 . "VERTEX")

        '(100 . "AcDbEntity")

        '(100 . "AcDbVertex")

        '(100 . "AcDb3dPolylineVertex")

        (cons 10 pt)

        '(70 . 32)

      )

    )

  )

  (entmake

    (list

      '(0 . "SEQEND")

      '(100 . "AcDbEntity")

    )

  )

  (princ)

)

 

ymg

  • Guest
Re: callibrate a 3dPolyline
« Reply #23 on: October 29, 2013, 09:09:21 AM »
Don't know if it is always the case, but in your example simply separating  the polylines every  2 vertices will give you the two polylines you are after.

So you end up with (0 1 4 5 8 9 ... etc.) and (2 3 6 7 10 11... etc.) , here the numbers are indices to each vertex.

Normally when a surveyor take point to be joined, he should not cross the street like that but go along one side and come back along the other side.

ymg
« Last Edit: October 29, 2013, 09:20:15 AM by ymg »

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: callibrate a 3dPolyline
« Reply #24 on: October 30, 2013, 11:34:06 AM »
cannot follow you, which value you was typing. I only see a list of what?
Surveyor can go after lines but itīs not always useful, on 2 km road it haves repeatly same codes so it is better to go "sectionwise" /Dirk