| 
UID1积分16111精华贡献 威望 活跃度 D豆 在线时间 小时注册时间2002-1-3最后登录1970-1-1 
 | 
 
| 
LISP: How do I convert a Polygon Mesh into polylines?
×
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册 
    ID    76913
 Applies to:    AutoCAD 2004
 AutoCAD 2002
 
 Date    9/16/2003
 
 This document is part of   Visual Lisp   Polyline   Complex Entities
 
 
 Question
 Using Visual LISP, is there a way to reduce Polygon Meshs (3D Meshs) into regular
 polylines or lines?
 Answer
 While Visual LISP has no built-in method for converting a polygon mesh to polylines
 (or lines), you can explode it, and then draw polylines using the coordinates
 of the resulting 3dFaces.  The sample code below demonstrates this.  It searches
 modelspace for polygon mesh objects, explodes them into 3dFaces, draws polylines
 (adding vertices to the the 3dFace coordinates), and deletes the original mesh
 (and faces):
 
 [PHP]
 (defun c:XplPgMesh (/ oApp oDoc oMSp oObj vXplObj aXplObj oObjLst oObj2 vCoords o3dPline)
 (VL-LOAD-COM)
 (setq oApp (vlax-get-acad-object)
 oDoc (vla-get-activedocument oApp)
 oMSp (vla-get-modelspace oDoc)
 ) ;setq
 (vlax-for oObj oMsp
 (if (= (vla-get-objectname oObj) "AcDbPolygonMesh")
 (if (setq vXplObj (vla-explode oObj))
 (progn
 (setq aXplObj (vlax-variant-value vXplObj))
 (if (not (minusp (vlax-safearray-get-u-bound aXplObj 1))) ;check for empty safearray
 (progn
 (setq oObjLst (vlax-safearray->list aXplObj))
 (foreach oObj2 oObjLst
 (if (= (vla-get-objectname oObj2) "AcDbFace")
 (progn
 (setq vCoords (vla-get-coordinates oObj2)
 o3dPline (vla-Add3DPoly oMSp vCoords)
 ) ;setq
 (vlax-put-property o3dPline 'Closed :vlax-true)
 (vla-delete oObj2)
 (vlax-release-object o3dPline)
 ) ;progn
 ) ;if
 ) ;foreach
 (foreach itm oObjLst (vlax-release-object itm))
 ) ;progn
 ) ;if
 (vla-delete oObj)
 ) ;progn
 ) ;if
 ) ;if
 ) ;vlax-for
 (princ)
 )
 [/PHP]
 | 
 |