flopo Posted September 21, 2011 Share Posted September 21, 2011 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 21, 2011 Share Posted September 21, 2011 Is the resultant 2D LWPolyline meant to lie in the XZ-plane? Quote Link to comment Share on other sites More sharing options...
flopo Posted September 21, 2011 Author Share Posted September 21, 2011 Sorry, is a mistake in my drawing... can be in x-y plane Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 21, 2011 Share Posted September 21, 2011 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) ) Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 21, 2011 Share Posted September 21, 2011 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. Quote Link to comment Share on other sites More sharing options...
flopo Posted September 21, 2011 Author Share Posted September 21, 2011 Both of them are ok, thanks guys! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.