Author Topic: 3D Polyline Along a Surface  (Read 2355 times)

0 Members and 1 Guest are viewing this topic.

PM

  • Guest
3D Polyline Along a Surface
« on: December 23, 2020, 11:19:11 AM »
hI I am searching for a lisp to draw 3D Polyline Along a Surface.

Thanks

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: 3D Polyline Along a Surface
« Reply #1 on: December 23, 2020, 11:33:10 AM »
You mean curve along Surface - look into PROJECTGEOMETRY command...
[EDIT : You also have SURFEXTRACTCURVE command that operates on SURFACE entity...]

Or you mean to project 3D POLYLINE on TIN surface made from triangular 3DFACES...
Then look into attachment in this post :
http://www.theswamp.org/index.php?topic=9042.msg576276#msg576276
« Last Edit: December 23, 2020, 11:39:51 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

PM

  • Guest
Re: 3D Polyline Along a Surface
« Reply #2 on: December 25, 2020, 09:23:12 AM »
I want to draw a polyline over contours and become a 3d polyline. Because i want to use this 3dpolyline to create longsections

Thanks

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: 3D Polyline Along a Surface
« Reply #3 on: December 25, 2020, 09:57:02 AM »
I want to draw a polyline over contours and become a 3d polyline. Because i want to use this 3dpolyline to create longsections

Thanks

Here is another link for you to look... It may be helpful...
https://www.cadtutor.net/forum/topic/63122-longitudinal-profile-from-3d-polyline/?do=findComment&comment=521325
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

PM

  • Guest
Re: 3D Polyline Along a Surface
« Reply #4 on: December 25, 2020, 10:07:25 AM »
Hi ribarm. I know this code. I use this but this code convert a polyline to 3dpolyline and create vertex on every contour.
The  problem is , if the vertex of the  polyline is between 2 contours skip it and didnt calculate elevetion for this vertex.  Is any way to calculate the elevetions from the previous and next contour elevetion ?

Thanks

BIGAL

  • Swamp Rat
  • Posts: 1417
  • 40 + years of using Autocad
Re: 3D Polyline Along a Surface
« Reply #5 on: December 25, 2020, 06:22:24 PM »
You need to look at VL intersectwith you need to use ssget F and get all the crossing contour lines in a selection set , you may need to sort the order so they are in correct sequence.

Code: [Select]
; obj is section line
; ob2 is the contour line

(setq intpt1 (vlax-invoke obj2 'intersectWith obj acExtendThisEntity))
(537.634539233539 111.048606831557 10.0)
A man who never made a mistake never made anything

PM

  • Guest
Re: 3D Polyline Along a Surface
« Reply #6 on: December 26, 2020, 03:02:11 AM »
Can you fix it ?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:flw23pel ;fencelwpoly23dpolyelevations
  2.  ( / *error* bbucs ucsf osm cec ss1 ss2 i lw pl sss ssl sspl e )
  3.  
  4.  
  5.  (defun *error* ( msg )
  6.    (if ucsf
  7.      (command "_.UCS" "_P")
  8.    )
  9.    (command "_.ZOOM" "_P")
  10.    (if osm
  11.      (setvar 'osmode osm)
  12.    )
  13.    (if cec
  14.      (setvar 'cecolor cec)
  15.    )
  16.    (if msg
  17.      (prompt msg)
  18.    )
  19.    (princ)
  20.  )
  21.  
  22.  (defun bbucs ( ss / UCS2WCSMatrix WCS2UCSMatrix n ent minpt maxpt minptlst maxptlst minptbbx minptbby minptbbz minptbb maxptbbx maxptbby maxptbbz maxptbb )
  23.  
  24.  
  25.    ;; Doug C. Broad, Jr.
  26.    ;; can be used with vla-transformby to
  27.    ;; transform objects from the UCS to the WCS
  28.    (defun UCS2WCSMatrix ()
  29.      (vlax-tmatrix
  30.        (append
  31.          (mapcar
  32.           '(lambda (vector origin)
  33.            (append (trans vector 1 0 t) (list origin))
  34.          )
  35.          (list '(1 0 0) '(0 1 0) '(0 0 1))
  36.          (trans '(0 0 0) 0 1)
  37.          )
  38.          (list '(0 0 0 1))
  39.        )
  40.      )
  41.    )
  42.    ;; transform objects from the WCS to the UCS
  43.    (defun WCS2UCSMatrix ()
  44.      (vlax-tmatrix
  45.        (append
  46.          (mapcar
  47.           '(lambda (vector origin)
  48.            (append (trans vector 0 1 t) (list origin))
  49.          )
  50.          (list '(1 0 0) '(0 1 0) '(0 0 1))
  51.          (trans '(0 0 0) 1 0)
  52.          )
  53.          (list '(0 0 0 1))
  54.        )
  55.      )
  56.    )
  57.  
  58.    (if ss
  59.      (progn
  60.        (repeat (setq n (sslength ss))
  61.          (setq ent (ssname ss (setq n (1- n))))
  62.          (vla-TransformBy (vlax-ename->vla-object ent) (UCS2WCSMatrix))
  63.          (vla-getboundingbox (vlax-ename->vla-object ent) 'minpoint 'maxpoint)
  64.          (vla-TransformBy (vlax-ename->vla-object ent) (WCS2UCSMatrix))
  65.          (setq minpt (vlax-safearray->list minpoint))
  66.          (setq maxpt (vlax-safearray->list maxpoint))
  67.          (setq minptlst (cons minpt minptlst))
  68.          (setq maxptlst (cons maxpt maxptlst))
  69.        )
  70.        (setq minptbbx (caar (vl-sort minptlst '(lambda (a b) (< (car a) (car b))))))
  71.        (setq minptbby (cadar (vl-sort minptlst '(lambda (a b) (< (cadr a) (cadr b))))))
  72.        (setq minptbbz (caddar (vl-sort minptlst '(lambda (a b) (< (caddr a) (caddr b))))))
  73.        (setq maxptbbx (caar (vl-sort maxptlst '(lambda (a b) (> (car a) (car b))))))
  74.        (setq maxptbby (cadar (vl-sort maxptlst '(lambda (a b) (> (cadr a) (cadr b))))))
  75.        (setq maxptbbz (caddar (vl-sort maxptlst '(lambda (a b) (> (caddr a) (caddr b))))))
  76.        (setq minptbb (list minptbbx minptbby minptbbz))
  77.        (setq maxptbb (list maxptbbx maxptbby maxptbbz))
  78.      )
  79.    )
  80.    (list minptbb maxptbb)
  81.  )
  82.  
  83.  (if (= 0 (getvar 'worlducs))
  84.    (progn
  85.      (command "_.UCS" "_W")
  86.      (command "_.PLAN" "")
  87.      (setq ucsf t)
  88.    )
  89.    (command "_.PLAN" "")
  90.  )
  91.  (setq osm (getvar 'osmode))
  92.  (setvar 'osmode 0)
  93.  (setq cec (getvar 'cecolor))
  94.  (setvar 'cecolor "3")
  95.  (prompt "\nSelect OPEN \"STRAIGHT\" LWPOLYLINES that lie in plane parallel to WCS - PROJECTION LWPOLYLINES (NOT ELEVATION)...")
  96.  (setq ss1 (ssget (list '(0 . "LWPOLYLINE") '(-4 . "<or") '(70 . 0) '(70 . 128) '(-4 . "or>") '(-4 . "<or") '(210 0.0 0.0 1.0) '(210 0.0 0.0 -1.0) '(-4 . "or>") '(-4 . "<not") '(-4 . "<>") '(42 . 0.0) '(-4 . "not>"))))
  97.  (while (or
  98.           (not ss1)
  99.           (vl-every '(lambda ( x ) (not (equal (caddar (bbucs (ssadd x))) (caddr (cadr (bbucs (ssadd x)))) 1e-6))) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1))))
  100.         )
  101.    (prompt "\nEmpty sel.set... Please reselect again...")
  102.    (setq ss1 (ssget (list '(0 . "LWPOLYLINE") '(-4 . "<or") '(70 . 0) '(70 . 128) '(-4 . "or>") '(-4 . "<or") '(210 0.0 0.0 1.0) '(210 0.0 0.0 -1.0) '(-4 . "or>") '(-4 . "<not") '(-4 . "<>") '(42 . 0.0) '(-4 . "not>"))))
  103.  )
  104.  (prompt "\nSelect LWPOLYLINES that lie in plane parallel to WCS - ELEVATION LWPOLYLINES (NOT PROJECTION)...")
  105.  (setq ss2 (ssget (list '(0 . "LWPOLYLINE") '(-4 . "<or") '(210 0.0 0.0 1.0) '(210 0.0 0.0 -1.0) '(-4 . "or>"))))
  106.  (while (not ss2)
  107.    (prompt "\nEmpty sel.set... Please reselect again...")
  108.    (setq ss2 (ssget (list '(0 . "LWPOLYLINE") '(-4 . "<or") '(210 0.0 0.0 1.0) '(210 0.0 0.0 -1.0) '(-4 . "or>"))))
  109.  )
  110.  (repeat (setq i (sslength ss1))
  111.    (setq lw (ssname ss1 (setq i (1- i))))
  112.    (setq pl (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= (car x) 10)) (entget lw))))
  113.    (setq sss (ssget "_F" pl (list '(0 . "LWPOLYLINE") '(-4 . "<or") '(210 0.0 0.0 1.0) '(210 0.0 0.0 -1.0) '(-4 . "or>"))))
  114.    (setq ssl (ssnamex sss))
  115.    (setq ssl (vl-remove-if '(lambda ( x ) (eq (cadr x) lw)) ssl))
  116.    (setq sspl (mapcar 'cadr (apply 'append (mapcar '(lambda ( x ) (vl-remove-if-not 'listp x)) ssl))))
  117.    (command "_.3DPOLY")
  118.    (foreach p sspl
  119.      (if (vl-some '(lambda ( x ) (if (vlax-curve-getparamatpoint x (list (car p) (cadr p) (cdr (assoc 38 (entget x))))) (setq e x))) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss2))))
  120.        (command "_non" (list (car p) (cadr p) (cdr (assoc 38 (entget e)))))
  121.      )
  122.    )
  123.    (command "")
  124.  )
  125.  (*error* nil)
  126. )
  127.  


Thanks

BIGAL

  • Swamp Rat
  • Posts: 1417
  • 40 + years of using Autocad
Re: 3D Polyline Along a Surface
« Reply #7 on: December 28, 2020, 01:09:01 AM »
I think you have over complicated the task, with no dwg to check if the contours are plain plines but at a elevation or are they true 3dpolylines. Using the fence ssget you get all the crossing contours then intersectwith for a point Z should be returned, a plain pline will return . I mentioned sort to make sure they are in correct order so make a list ((dist enttityname)(dist entityname)...)and sort on dist.

A pline using elev has just that a elevation property where as a 3dpoly does not have this property.
A man who never made a mistake never made anything

PM

  • Guest
Re: 3D Polyline Along a Surface
« Reply #8 on: December 28, 2020, 10:51:33 AM »
BIGAL . Hi Bigal. I upload a dwg file to see the results of the lisp code . With blue color is the 2d polyline i draw. With green is the 3d polyline from the lisp code.

I want 2 updates if you can help for this code

1) if it possible to understand the contours without select them (from the layer name)
2) The 3d polyline is shorter than the blue 2d polyline beause there no contours at the edges of the 2d polyline. Is it possible to calculate the elevetion between the polylines

Thanks