Jump to content

Recommended Posts

Posted

Hi,

 

Does anyone know how to get elevation from surface for polyline but only at vertices (TIN example and polyline with 8 vertices below ). So i want to mark TIN and polyline and then convert to 3D polyline with elevations in vertices (without intersections with edges of TIN).

 

Example_surface.dwg

Posted (edited)

@AirBall

Is it necessary through Lisp 

This can be done by forming cogo points from the surface of 

and then connecting the points  

through their numbers

Edited by hosneyalaa
Posted

Like @hosneyalaa this is a inbuilt function in CIV3D. 

 

Do a google "get elevation of point on 3dface autocad lisp" there are answers out there found one from 2012.

Posted

@AirBall

With your request :elevations in vertices

Try this for convert your lwpolyline to 3Dpoly with 3Dfaces

(defun pt_sum_store (pt? pt_lst / count p1 p2 vtx alpha btw_alpha)
  (setq
    alpha 0.0
    vtx (car pt_lst)
    count 1
  )
  (while (< 1 (length pt_lst))
    (setq
      p1 (car pt_lst)
      p2 (cadr pt_lst)
      pt_lst (cdr pt_lst)
      btw_alpha (q_ang pt? p1 p2)
      btw_alpha
      (if (< 180.0 btw_alpha)
        (- btw_alpha 360.0)
        btw_alpha
      )
      alpha (+ alpha btw_alpha)
    )
    (setq count (1+ count))
  )
  (setq
    btw_alpha (q_ang pt? p2 vtx)
    btw_alpha
    (if (< 180.0 btw_alpha)
      (- btw_alpha 360.0)
      btw_alpha
    )
  )
  (+ alpha btw_alpha)
)
(defun q_ang (pt? p1 p2 / alpha beta)
  (setq
    beta (angle pt? p1)
    alpha (angle pt? p2)
    alpha (- alpha beta)
  )
  (if (< alpha 0)
    (setq alpha (+ (* 2 pi) alpha))
  )
  (* (/ (float alpha) pi) 180.0)
)
(defun pt_in_poly (pt? pt_lst / )
  (if (equal 0.0 (pt_sum_store pt? pt_lst) 0.0001)
    nil
    T
  )
)
(vl-load-com)
(defun c:lwpolyto3dpoly ( / js AcDoc Space ename obj pr lst_pt ss nb ent dxf_ent l_pt n X1 X2 X3 Y1 Y2 Y3 Z1 Z2 Z3 E1 E2 E3 E4 Z nw_lst-pt nw_obj)
  (princ "\nSelect polyline.")
  (while
    (null
      (setq js
        (ssget "_+.:E:S"
          (list
            (cons 0 "*POLYLINE")
            (cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
            (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
            (cons -4 "<NOT")
              (cons -4 "&") (cons 70 112)
            (cons -4 "NOT>")
          )
        )
      )
    )
  )
  (setq
    AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
    Space
    (if (= 1 (getvar "CVPORT"))
      (vla-get-PaperSpace AcDoc)
      (vla-get-ModelSpace AcDoc)
    )
  )
  (setq
    ename (ssname js 0)
    obj (vlax-ename->vla-object ename)
    pr -1
  )
  (repeat (fix (vlax-curve-getEndParam obj))
    (setq
      pr (1+ pr)
      lst_pt (cons (vlax-curve-GetPointAtParam obj pr) lst_pt)
    )
  )
  (setq lst_pt (cons (vlax-curve-GetPointAtParam obj (1+ pr)) lst_pt))
  (setq ss (ssget "_F" lst_pt '((0 . "3DFACE"))))
  (cond
    (ss
      (repeat (setq nb (sslength ss))
        (setq
          ent (ssname ss (setq nb (1- nb)))
          dxf_ent (entget ent)
          l_pt
          (list
            (cdr (assoc 10 dxf_ent))
            (cdr (assoc 11 dxf_ent))
            (cdr (assoc 12 dxf_ent))
            (cdr (assoc 13 dxf_ent))
          )
        )
        (if (equal (car l_pt) (cadr l_pt))
          (setq l_pt (list (list (cadr l_pt) (caddr l_pt) (cadddr l_pt))))
          (setq l_pt (cons (list (car l_pt) (cadr l_pt) (caddr l_pt)) (list (list (cadr l_pt) (caddr l_pt) (cadddr l_pt)))))
        )
        (mapcar
          '(lambda (y / n)
            (foreach e lst_pt
              (cond
                ((pt_in_poly e y)
                  (setq n 0)
                  (foreach item '(("X" . "'car") ("Y" . "'cadr") ("Z" . "'caddr"))
                    (mapcar '(lambda (e) (set (read (strcat (car item) (itoa (setq n (1+ n))))) e))
                      (mapcar (eval (read (cdr item))) (car l_pt))
                    )
                    (setq n 0)
                  )
                  (setq
                    E1 (+ (* X1 (- Y2 Y3)) (* X2 (- Y3 Y1)) (* X3 (- Y1 Y2)))
                    E2 (+ (* Y1 (- Z2 Z3)) (* Y2 (- Z3 Z1)) (* Y3 (- Z1 Z2)))
                    E3 (+ (* Z1 (- X2 X3)) (* Z2 (- X3 X1)) (* Z3 (- X1 X2)))
                    E4 (- (- (* E2 X1)) (* E3 Y1) (* E1 Z1))
                    Z (- (- (* (/ E2 E1) (car e))) (* (/ E3 E1) (cadr e)) (/ E4 E1))
                    nw_lst-pt (cons (trans (list (car e) (cadr e) Z) 1 0) nw_lst-pt)
                  )
                )
              )
            )
          )
          l_pt
        )
      )
      (setq nw_obj
        (vlax-invoke
          Space
          'Add3dPoly
          (apply
            'append
            nw_lst-pt
          )
        )
      )
      (vla-put-Layer nw_obj (vla-get-Layer obj))
      (vla-put-Color nw_obj (vla-get-Color obj))
      (vla-put-Lineweight nw_obj (vla-get-Lineweight obj))
      (vla-delete obj)
    )
  )
  (prin1)
)

 

  • Like 4
Posted

@Tsuky

 

Thank you very much, that is exactly what I needed. 😃

 

 

 

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...