;Tip1691: FACE2LIN.LSP 3D faces to lines (c)2001, Jeff Foster ;OBJECTIVE*** ;The purpose of this routine is to allow the user to select a group ;of 3dfaces on a selected layer and convert them to either lines or ;3dpolylines as directed by the user. All 3d information is preserved. ;3dfaces may be retained or erased. ; ;TO RUN*** ;At the command line, type (load "c:/lispdir/face2lin") ;where c:/ is the drive where FACE2LIN.lsp is contained ;where lispdir/ is the directory where FACE2LIN.lsp is contained (Defun C:FACE2LIN () (PREPROCESS) (PROCESS) (POSTPROCESS) ) (Defun PREPROCESS () (setq c-cmd (getvar "cmdecho") c-lyr (getvar "clayer") ) (setvar "cmdecho" 0) (initget 0 "Pline Lines") (setq p-l (getkword "\nConvert 3dfaces to Plines or Lines? : ") ) (if (= p-l nil) (setq p-l "Lines") ) (prompt "\n") (princ) ) (Defun PROCESS () (while (= (setq get3dface (car (entsel "\rSelect sample 3dface: "))) nil ) ) (setq 3d-inf (entget get3dface)) (if (/= (cdr (assoc 0 3d-inf)) "3DFACE") (PROCESS) ) (command "_layer" "_s" (cdr (assoc 8 3d-inf)) "") (setq ss3d (ssget "X" (list (cons 0 "3DFACE") (cons 8 (cdr (assoc 8 3d-inf)))) ) 2del (ssget "X" (list (cons 0 "3DFACE") (cons 8 (cdr (assoc 8 3d-inf)))) ) cnt 0 ) (while (/= (setq sse3d (ssname ss3d 0)) nil) (setq sse3d-inf (entget sse3d) pt1 (cdr (assoc 10 sse3d-inf)) pt2 (cdr (assoc 11 sse3d-inf)) pt3 (cdr (assoc 12 sse3d-inf)) pt4 (cdr (assoc 13 sse3d-inf)) ) (if (= p-l "Lines") (command "_line") (command "_3dpoly") ) (command pt1 pt2 pt3) (if (= (distance pt3 pt4) 0) (command "_C") (command pt4 "_C") ) (setq cnt (+ cnt 1)) (ssdel sse3d ss3d) ) ) (Defun POSTPROCESS () (initget 0 "Yes No") (setq y-n (getkword "\nDelete 3dfaces? : ")) (if (or (= y-n nil) (= y-n "Yes")) (command "_erase" 2del "") ) (prompt (strcat "\n" (itoa cnt) " 3dfaces converted")) (setvar "cmdecho" c-cmd) (setvar "clayer" c-lyr) (princ) ) ;;;;(C:FACE2LIN)