Author Topic: 3D Polyline Editing  (Read 4000 times)

0 Members and 1 Guest are viewing this topic.

demesne

  • Guest
3D Polyline Editing
« on: March 22, 2012, 09:49:08 AM »
Hi

I'm wondering if anyone has any ideas how I can speed up the follwing process:

The attached dwg shows the following in a graphical manner, by the way.

1 - Take a 3D polyline representing a curve in a road.  This is topographical survey data with too few vertices to accurately show the true road line (vertices currently only at each 'surveyed point').
2 - Create a spline (cubic, zero fit tolerance) through each 3D polyline vertex.
3 - Break the spline at each 3D polyline vertex. This is to ensure that the end result has a vertex at each 'surveyed point'.
4 - Use pedit to convert the splines to 3d polylines.
5 - Join the resulting 3D polyline to form one string.

The reason I convert the spline is to enable the drawing to be used by an earthworks package when creating surface models.

I've tried CAB's BreakAll routines to automatically break the spline but this wasn't written to do what I'm trying to do and so misses some of the breaks.

I'm hoping that one of you will have a routine that does the above with one click.  .....I live in hope.  :|


Regards
Demesne
« Last Edit: March 22, 2012, 09:54:08 AM by demesne »

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: 3D Polyline Editing
« Reply #1 on: March 22, 2012, 10:03:36 AM »
I think that step "3. Break spline" is unnecessary - you create spline that has knots at each 3dpolyline vertex... Consider segmentation of spline curve with points between knots including knots and new object 3dpolyline should have these vertices too...

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

:)

M.R. on Youtube

demesne

  • Guest
Re: 3D Polyline Editing
« Reply #2 on: March 22, 2012, 10:14:37 AM »
Unfortunately that doesn’t happen. Pedit doesn’t need to use the knots as long as it is creating a 3d polyline that is true to the precision you specify. So, it ignores them.

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: 3D Polyline Editing
« Reply #3 on: March 22, 2012, 10:23:23 AM »
I thought that you don't need to pedit spline... I thought that you want to create list of vertices from spline that have precision segmentation you specify within lisp and which includes knots as start-end segment vertices (you would have precision within each segment). With that new list of vertices you can directly create new 3dpolyline...

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

:)

M.R. on Youtube

demesne

  • Guest
Re: 3D Polyline Editing
« Reply #4 on: March 22, 2012, 10:31:59 AM »
Ah I see.  But I have hundereds of lines to edit and not much idea of how to do what you suggest.  :-(

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: 3D Polyline Editing
« Reply #5 on: March 22, 2012, 12:11:09 PM »
I've made this quick...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:3dpl-seg ( / OSM 3DPL 3DPLA COORDS ENPAR ENPT INCRPAR K M N PT PT11 PTLST PTLST11 PTN PTNEWLST PTNLST SPL STPAR STPT )
  2.   (setq osm (getvar 'osmode))
  3.   (setvar 'osmode 0)
  4.   (vl-cmdf "osnap" "off")
  5.   (prompt "\nPick 3dpolyline to perform curve segmentation between its vertices")
  6.   (setq 3dpl (ssname (ssget "_+.:E:S" '((0 . "POLYLINE") (100 . "AcDbEntity") (100 . "AcDb3dPolyline"))) 0))
  7.   (setq 3dplA (vlax-ename->vla-object 3dpl))
  8.   (setq coords (vlax-safearray->list (vlax-variant-value (vla-get-coordinates 3dplA))))
  9.   (repeat (/ (length coords) 3)
  10.     (setq pt (list (car coords) (cadr coords) (caddr coords)))
  11.     (setq coords (cdddr coords))
  12.     (setq ptlst (cons pt ptlst))
  13.   )
  14.   (setq ptlst (reverse ptlst))
  15.   (foreach pt ptlst
  16.     (setq pt11 (cons 11 pt))
  17.     (setq ptlst11 (cons pt11 ptlst11))
  18.     (setq ptlst11 (cons (cons 41 1.0) ptlst11))
  19.   )
  20.   (setq ptlst11 (reverse ptlst11))
  21.   (setq spl (entmakex (append '((0 . "SPLINE") (100 . "AcDbEntity") (100 . "AcDbSpline") (210 0.0 0.0 1.0) (70 . 12) (71 . 2) (72 . 6)) (list (cons 73 (length ptlst)) (cons 74 0) (cons 42 1.0e-010) (cons 43 1.0e-010) (cons 40 0.0) (cons 40 0.0) (cons 40 0.0) (cons 40 1.0) (cons 40 1.0) (cons 40 1.0)) ptlst11 )))
  22.   (initget 6)
  23.   (setq n (getint "\nInput segmentation precision per segment : "))
  24.   (setq k -1)
  25.   (setq ptnewlst '())
  26.   (repeat (- (length ptlst) 1)
  27.     (setq ptnlst nil)
  28.     (setq stpt (nth (setq k (1+ k)) ptlst))
  29.     (setq enpt (nth (+ k 1) ptlst))
  30.     (setq stpar (vlax-curve-getparamatpoint spl stpt))
  31.     (setq enpar (vlax-curve-getparamatpoint spl enpt))
  32.     (setq incrpar (/ (- enpar stpar) (float n)))
  33.     (setq m -1)
  34.     (repeat n
  35.       (setq ptn (vlax-curve-getpointatparam spl (+ stpar (* (float (setq m (1+ m))) incrpar))))
  36.       (setq ptnlst (cons ptn ptnlst))
  37.     )
  38.     (setq ptnlst (reverse ptnlst))
  39.     (setq ptnewlst (append ptnewlst ptnlst))
  40.   )
  41.   (setq ptnewlst (reverse ptnewlst))
  42.   (setq ptnewlst (cons enpt ptnewlst))
  43.   (setq ptnewlst (reverse ptnewlst))
  44.   (entdel spl)
  45.   (vl-cmdf "_.3dpoly")
  46.   (foreach pt ptnewlst
  47.     (vl-cmdf pt)
  48.   )
  49.   (while (> (getvar 'cmdactive) 0) (vl-cmdf ""))
  50.   (setvar 'osmode osm)
  51.   (princ)
  52. )
  53.  

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

:)

M.R. on Youtube

demesne

  • Guest
Re: 3D Polyline Editing
« Reply #6 on: March 22, 2012, 01:08:20 PM »
Marko

Thank you very much.  I didn't expect a full solution.  That's excellent.

I had a look at the lisp to see if I could change the knot parameter to 'square root' from 'chord' although I'm lost with that one.  I thought I might see a reference to the SPLKNOTS system variable.  It's not too important though.

Thanks again - you've saved me hours!  :-)

Regards
Demesne