Author Topic: find z value of selected 3dpolylines at equal distances  (Read 2983 times)

0 Members and 1 Guest are viewing this topic.

motee-z

  • Newt
  • Posts: 40
find z value of selected 3dpolylines at equal distances
« on: November 02, 2014, 04:18:51 AM »
Hello
please help to label z value of 3d polyline at equal distances like in attached drawing
manually doing that very long i have to flatten 3d polyline then explode it then join these lines to convert it to polyline then divided at equal distances then apparent entersection to get z value then label this value
thanks for any help 

motee-z

  • Newt
  • Posts: 40
Re: find z value of selected 3dpolylines at equal distances
« Reply #1 on: November 05, 2014, 06:02:58 AM »
it looks my request very difficult that no one reply

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: find z value of selected 3dpolylines at equal distances
« Reply #2 on: November 05, 2014, 08:19:07 AM »
Look into the vlax-curve-* functions.
As far as I can see the steps are:
1.
Create a copy of the 3D poly and set the Z for all vertices to zero.
2.
Use the vlax-curve-getpointatdist function on the flat 3D poly to get a list of points.
3.
Use the vlax-curve-getclosestpointtoprojection to project the points on the original poly.
4.
Extract the Z value from the points and create texts. Use vlax-curve-getfirstderiv for angle info.

It is not exactly hard, but it does involve some work. Maybe you should do some of that work yourself.

ronjonp

  • Needs a day job
  • Posts: 7533
Re: find z value of selected 3dpolylines at equal distances
« Reply #3 on: November 05, 2014, 10:52:49 AM »
Give this a try ... remember to donate to TheSwamp  8)
Code - Auto/Visual Lisp: [Select]
  1. (defun c:labelz (/ makereadable a e i n np o o2 op p x)
  2.   ;; Make Angle Readable by: ymg
  3.   (defun makereadable (a)
  4.     (setq a (rem (+ a pi pi) (+ pi pi)))
  5.     (rem (if (< (* pi 0.5) a (* pi 1.5))
  6.            (+ a pi)
  7.            a
  8.          )
  9.          (+ pi pi)
  10.     )
  11.   )
  12.   (if (and (setq e (car (entsel "\nPick 3D Polyline: ")))
  13.            (setq o (vlax-ename->vla-object e))
  14.            (= (vla-get-objectname o) "AcDb3dPolyline")
  15.            (setq o2 (vla-copy o))
  16.            (null (initget 7))
  17.            (setq n (getreal "\nEnter distance increment to label: "))
  18.       )
  19.     (progn (setq i 0)
  20.            ;; Flatten 3d point list
  21.            (setq np (mapcar '(lambda (x)
  22.                                (if (zerop (rem (setq i (1+ i)) 3))
  23.                                  0.0
  24.                                  x
  25.                                )
  26.                              )
  27.                             ;; 3D point list
  28.                             (setq op (vlax-get o 'coordinates))
  29.                     )
  30.            )
  31.            (setq i 0)
  32.            ;; Flatten copy of polyline
  33.            (vlax-put o2 'coordinates np)
  34.            (while (setq p (vlax-curve-getpointatdist o2 i))
  35.              ;; Perpendicular angle at point
  36.              (setq
  37.                a (makereadable
  38.                    (+ (* pi 0.5)
  39.                       (angle '(0 0) (vlax-curve-getfirstderiv o2 (vlax-curve-getparamatpoint o2 p)))
  40.                    )
  41.                  )
  42.              )
  43.              ;; 3D point
  44.              (setq p (vlax-curve-getclosestpointtoprojection o p '(0.0 0.0 1.0) t))
  45.              ;; Create label
  46.              (entmakex (list '(0 . "TEXT")
  47.                              '(100 . "AcDbEntity")
  48.                              '(67 . 0)
  49.                              '(8 . "POINT LABEL")
  50.                              '(100 . "AcDbText")
  51.                              (cons 10 p)
  52.                              '(40 . 1.2)
  53.                              (cons 1 (rtos (last p) 2 2))
  54.                              (cons 50 a)
  55.                              '(41 . 1.0)
  56.                              '(51 . 0.0)
  57.                              '(7 . "Standard")
  58.                              '(71 . 0)
  59.                              '(72 . 0)
  60.                              (cons 11 (list 0.0 0.0 (last p)))
  61.                              '(100 . "AcDbText")
  62.                              '(73 . 0)
  63.                        )
  64.              )
  65.              ;; Make circle
  66.              (entmakex (list '(0 . "CIRCLE")
  67.                              '(100 . "AcDbEntity")
  68.                              '(67 . 0)
  69.                              '(8 . "Place LABEL")
  70.                              '(100 . "AcDbCircle")
  71.                              (cons 10 p)
  72.                              '(40 . 0.18)
  73.                        )
  74.              )
  75.              ;; Increment index
  76.              (setq i (+ i n))
  77.            )
  78.            ;; Erase copy
  79.            (vla-delete o2)
  80.     )
  81.   )
  82.   (princ))
« Last Edit: November 05, 2014, 10:58:10 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

motee-z

  • Newt
  • Posts: 40
Re: find z value of selected 3dpolylines at equal distances
« Reply #4 on: November 05, 2014, 11:32:40 AM »
i have been looking for this lisp since 5 year
thank you ronjonp nice lisp

ronjonp

  • Needs a day job
  • Posts: 7533
Re: find z value of selected 3dpolylines at equal distances
« Reply #5 on: November 05, 2014, 11:55:10 AM »
i have been looking for this lisp since 5 year
thank you ronjonp nice lisp
Glad to help out.  :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC