本帖最后由 作者 于 2010-9-3 23:40:40 编辑
改了一下,能用了,谢谢分享。- (defun c:3d2d(/ laylst lay ss) ;3D转2D,并复制 ;from 高山流水 2010.08
- (vl-load-com)
- (setvar "cmdecho" 0)
- (vl-catch-all-apply 'vl-cmdf (list "UCS" "N" "V" "LAYOUT" "N" "Test"))
- (setvar "CTAB" "Test")
- (setq ss (ssget "x"))
- (vl-catch-all-apply 'vl-cmdf (list "ERASE" ss "" "MVIEW" "F" "MSPACE"))
- (setq ss (ssget "x"))
- (if (not SolProf_bak) ;这里改了一下,谢谢龙龙仔版主提醒。
- (progn
- (setq SolProf_bak T)
- (vl-catch-all-apply 'vl-cmdf (list "SolProf" ss "" "Y" "Y" "N"))
- )
- (SolProf ss "" "Y" "Y" "N")
- )
- (setq laylst (get-layer))
- (setq lay (last (vl-remove-if-not (function (lambda (x) (wcmatch x "PV*"))) laylst)))
- (setvar "CTAB" "Model")
- (vl-cmdf "UCS" "N" "V")
- (setq ss (ssget "x" (list (cons 8 lay))))
- ;(vl-file-delete "C:\\TEST.DWG") ;可以更改路径,也可以改成发送到剪贴板
- ;(vl-cmdf "wblock" "C:\\TEST.dwg" "" '(0 0 0) ss "")
- (vl-cmdf "_copyclip" ss "")
- (foreach a laylst
- (if (wcmatch a "P[VH]-*")
- (vl-cmdf "ERASE" (ssget "X" (list (cons 8 a))) "")
- )
- )
- (vl-catch-all-apply 'vl-cmdf (list "layout" "D" "TEST" "UCS" ""))
- (command "_.PURGE" "a" "*" "N") ;这里您可以选择执行
- (command "UCS" "")
- (princ "\n3D转换2D完成,2D线框已复制,粘贴即可。")
- (princ)
- )
- (defun get-layer(/ lay layer layname) ;获得图层列表
- (setq layer nil lay (tblnext "LAYER" T))
- (while (/= lay nil)
- (setq layname (cdr (assoc 2 lay))
- layer (cons layname layer)
- lay (tblnext "LAYER")
- )
- )
- (setq layer (ACAD_Strlsort layer))
- )
|