Conversion 3dpoly - 2d poly -
Hi guys,Starting with a 3d polyline, i want to draw a 2d polylinethat will have vertices with the same z value, and the distances betweenvertices will be the same as for 3d polyline... any lisp for somethinglike this? You can see the attached drawing... Somethig like a"flattening" , but to keep distances between vertices ...Thanks!
3DPOLY-2DPOLY.dwg Is the resultant 2D LWPolyline meant to lie in the XZ-plane? Sorry, is a mistake in my drawing... can be in x-y plane Try something like this (hacked together):
(defun c:test ( / d e l s x ) (if (setq s (ssget "_+.:E:S" '( (0 . "POLYLINE") (-4 . "") ) ) ) (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)) 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. Both of them are ok, thanks guys!
页:
[1]