Jump to content

Conversion 3dpoly - 2d poly - same elevation and distance between vertices"


flopo

Recommended Posts

Hi guys,

Starting with a 3d polyline, i want to draw a 2d polyline that will have vertices with the same z value, and the distances between vertices will be the same as for 3d polyline... any lisp for something like this? You can see the attached drawing... Somethig like a "flattening" , but to keep distances between vertices ... Thanks!

3DPOLY-2DPOLY.dwg

Link to comment
Share on other sites

Try something like this (hacked together):

 

(defun c:test ( / d e l s x )
   (if
       (setq s
           (ssget "_+.:E:S"
              '(
                   (0 . "POLYLINE")
                   (-4 . "<NOT")
                       (-4 . "&")
                       (70 . 119)
                   (-4 . "NOT>")
               )
           )
       )
       (progn
           (setq e (ssname s 0))
           (while
               (eq "VERTEX"
                   (cdr
                       (assoc 0
                           (setq d
                               (entget
                                   (setq e (entnext e))
                               )
                           )
                       )
                   )
               )
               (setq l (cons (cdr (assoc 10 d)) l))
           )
           (setq l (reverse l)
                 x (caar l)
           )
           (setq l
               (mapcar
                   (function
                       (lambda ( a b / d z p )
                           (setq d (distance a b)
                                 z (- (caddr a) (caddr b))
                                 p (list 10 x (caddr a))
                                 x (+ x (sqrt (- (* d d) (* z z))))
                           )
                           p
                       )
                   )
                   l (append (cdr l) (list (car l)))
               )
           )
           (entmakex
               (append
                   (list
                       (cons 0 "LWPOLYLINE")
                       (cons 100 "AcDbEntity")
                       (cons 100 "AcDbPolyline")
                       (cons 90 (length l))
                       (cons 70 0)
                   )
                   l
               )
           )
       )
   )
   (princ)
)

Link to comment
Share on other sites

I've done this :

 

(defun c:3dpl2dpl-unwrap ( / 3DPL 3DPLA 3DPLCOORD 3DPLPTL DX DZ K L O OSM PT PTT PTTT PTTTW SSLINES )
(vl-load-com)
(setq osm (getvar 'osmode))
(setvar 'osmode 0)
(setq 3dpl (car (entsel "\nPick 3d poly")))
(setq 3dplA (vlax-ename->vla-object 3dpl))
(setq 3dplcoord (vlax-safearray->list (vlax-variant-value (vla-get-Coordinates 3dplA))))
(repeat (/ (length 3dplcoord) 3)
(setq pt (list (car 3dplcoord) (cadr 3dplcoord) (caddr 3dplcoord)))
(setq 3dplcoord (cdddr 3dplcoord))
(setq 3dplptl (cons pt 3dplptl))
)
(setq 3dplptl (reverse 3dplptl))
(setq o '(0.0 0.0 0.0))
(setq sslines (ssadd))
(setq k 0)
(repeat (- (length 3dplptl) 1)
(setq k (1+ k))
(vl-cmdf "ucs" "w")
(vl-cmdf "ucs" "x" 90)
(if (eq k 1) (setq pt (trans (car 3dplptl) 0 1)) (setq pt (trans ptttw 0 1)))
(vl-cmdf "ucs" "m" pt)
(setq ptt (trans (cadr 3dplptl) 0 1))
(setq l (distance (car 3dplptl) (cadr 3dplptl)))
(setq dz (cadr ptt))
(setq dx (sqrt (- (expt l 2) (expt dz 2))))
(setq pttt (list dx dz 0.0))
(setq ptttw (trans pttt 1 0))
(vl-cmdf "_.line" o pttt "")
(ssadd (entlast) sslines)
(setq 3dplptl (cdr 3dplptl))
)
(vl-cmdf "_.pedit" "m" sslines "" "y" "j" "" "")
(vl-cmdf "_.chprop" (entlast) "" "c" "1" "")
(vl-cmdf "ucs" "w")
(setvar 'osmode osm)
(princ)
)

 

M.R.

Link to comment
Share on other sites

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...