多布局拆分,模型也要唯一
之前在论坛上看到一个多布局拆分的程序,但是模型没有变化。能否有高手修改一下程序,使其模型也唯一。附上原码:
(defun c:cf(/ errexit undox olderr oldcmdecho oldexpert oldcmddia fn path msg msg2 fileprefix filesuffix i j)
(defun errexit (s)
(princ "\nError:")
(princ s)
(restore)
)
(defun undox ()
(command "._undo" "_E")
(setvar "cmdecho" oldcmdecho)
(setvar "expert" oldexpert)
(setvar "cmddia" oldcmddia)
(setq *error* olderr)
(princ)
)
(setq olderr*error*
restore undox
*error* errexit
)
(setq oldcmdecho (getvar "cmdecho"))
(setq oldexpert (getvar "expert"))
(setq oldcmddia (getvar "cmddia"))
(setvar "cmdecho" 0)
(setvar "expert" 2)
(setvar "cmddia" 0)
(defun DelAllLayouts (Keeper / TabName)
(vlax-for Layout
(vla-get-Layouts
(vla-get-activedocument (vlax-get-acad-object))
)
(if
(and
(/= (setq TabName (strcase (vla-get-name layout))) "MODEL")
(/= TabName (strcase Keeper))
)
(vla-delete layout)
)
)
)
(vl-load-com)
(setq msg "" msg2 "" i 0 j 0)
(command "._undo" "_BE")
(setq fileprefix (getstring "Enter filename prefix: "))
(setq filesuffix (getstring "Enter filename suffix: "))
(foreach lay (layoutlist)
(if (and (/= lay "Model") (> (vla-get-count (vla-get-block (vla-Item (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object))) lay))) 1))
(progn
(command "_.undo" "_M")
(DelAllLayouts lay)
(setvar "tilemode" 1)
(command "_.ucs" "_w")
(setvar "tilemode" 0)
(setq path (getvar "DWGPREFIX"))
(setq fn (strcat path fileprefix lay filesuffix ".dwg"))
(if (findfile fn)
(progn
(command "_.-wblock" fn)
(if (equal 1 (logand 1 (getvar "cmdactive")))
(progn
(setq i (1+ i) msg (strcat msg "\n" fn))
(command "*")
)
(setq j (1+ j) msg2 (strcat msg2 "\n" fn))
)
)
(progn
(command "_.-wblock" fn "*")
(setq i (1+ i)msg (strcat msg "\n" fn))
)
)
(if (equal 1 (logand 1 (getvar "cmdactive")))
; Include AutoCAD Map information in the export?
; If you don't want to include Map information in the new files change "_Y" to "_N" below
(command "_Y")
)
(command "_.undo" "_B")
)
)
)
(if (/= msg "")
(progn
(if (= i 1)
(prompt "\nFollowing drawing was created:")
(prompt "\nFollowing drawings were created:")
)
(prompt msg)
)
)
(if (/= msg2 "")
(progn
(if (= j 1)
(prompt "\nFollowing drawing was NOT created:")
(prompt "\nFollowing drawings were NOT created:")
)
(prompt msg2)
)
)
(command "._undo" "_E")
(textscr)
(restore)
(princ)
)
(princ)
这是不可能的 本帖最后由 kkdolphin 于 2020-9-7 15:58 编辑
现在可以做到的是每个布局可以独立出来,但是布局形式改变了,不再是原来那种布局。秋枫大侠可以实现单独分割成每个DWG,但是布局变了。竖的布局会变为横的布局。
页:
[1]