ObjectDBX:Vla AttachExternalR
使用ObjectDBX,我很难完成外部参照的附着(MS)和标题栏的插入(PS)。具体来说,当使用dbx打开预设置标题栏图形(保存在PaperSpace中)时,尝试将外部参照附着成功,但仅附着到当前空间(PS),而不附着到其所属的模型空间(MS)。
尽管我努力使用(vla get modelspace dbx)作为vla AttachExternalReference的对象参数,或者通过单步执行选项卡来获取布局的块对象,如下所示:
(defun c:FOO ( / dbx master)
(vl-load-com)
(if (setq dbx (vla-GetInterfaceObject
(vlax-Get-Acad-Object)
(strcat "ObjectDBX.AxDbDocument."
(substr (getvar 'acadver) 1 2))))
(progn
(vl-catch-all-apply 'vla-open (list dbx "C:\\my_titleblock.dwt"))
(vlax-for lay(vla-get-layouts dbx)
(if (= "MODEL" (strcase (vla-get-name lay)))
(progn
(vla-attachexternalreference
(vla-get-block lay)
(setq master "C:\\my_xref.dwg")
(vl-filename-base master)
(vlax-3d-point '(0 0 0))
1
1
1
0
:vlax-true))))
(vl-catch-all-apply 'vla-saveas (list dbx "C:\\my_sheet.dwg"))
(setq dbx (vl-catch-all-apply 'vlax-Release-Object (list dbx)))))
(princ))
任何帮助都将不胜感激! 你好,Renderman,
这对我来说很好:
(defun c:test ( / dbx title master ) (vl-load-com)
(setq title"C:\\my_titleblock.dwt"
master "C:\\my_xref.dwg"
)
(if
(and
(setq dbx (LM:GetDocumentObject title))
(setq master (findfile master))
)
(progn
(vla-attachexternalreference (vla-get-modelspace dbx) master
(vl-filename-base master) (vlax-3d-point '(0 0 0)) 1. 1. 1. 0. :vlax-true
)
(vl-catch-all-apply 'vla-saveas (list dbx "C:\\my_sheet.dwg"))
(vl-catch-all-apply 'vlax-Release-Object (list dbx))
)
)
(princ)
)
;;-----------------=={ Get Document Object }==----------------;;
;; ;;
;;Retrieves a the VLA Document Object for the specified ;;
;;filename. Document Object may be present in the Documents ;;
;;collection, or obtained through ObjectDBX ;;
;;------------------------------------------------------------;;
;;Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;;Arguments: ;;
;;filename - filename for which to retrieve document object ;;
;;------------------------------------------------------------;;
;;Returns:VLA Document Object, else nil ;;
;;------------------------------------------------------------;;
(defun LM:GetDocumentObject ( filename / docs dbx ) (vl-load-com)
(vlax-map-collection (vla-get-Documents (vlax-get-acad-object))
(function
(lambda ( doc )
(setq docs
(cons
(cons (strcase (vla-get-fullname doc)) doc) docs
)
)
)
)
)
(cond
( (not (setq filename (findfile filename))) )
( (cdr (assoc (strcase filename) docs)) )
( (not
(vl-catch-all-error-p
(vl-catch-all-apply 'vla-open
(list (setq dbx (LM:ObjectDBXDocument)) filename)
)
)
)
dbx
)
)
)
;;-----------------=={ ObjectDBX Document }==-----------------;;
;; ;;
;;Retrieves a version specific ObjectDBX Document object ;;
;;------------------------------------------------------------;;
;;Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;;Arguments: - None - ;;
;;------------------------------------------------------------;;
;;Returns:VLA ObjectDBX Document object, else nil ;;
;;------------------------------------------------------------;;
(defun LM:ObjectDBXDocument ( / acVer )
(vla-GetInterfaceObject (vlax-get-acad-object)
(if (< (setq acVer (atoi (getvar "ACADVER"))) 16)
"ObjectDBX.AxDbDocument"
(strcat "ObjectDBX.AxDbDocument." (itoa acVer))
)
)
)
确保您具有直接写入C驱动器的权限。 谢谢你的尝试,李,但结果是一样的。。。外部参照通过标题栏附着到图纸空间,而不是外部参照所属的模型空间。
该行为似乎表明,无论源图形/模板保存在哪个选项卡中,都会确定附着外部参照的空间,而不管在Vla AttachExternalReference期间如何指定模型空间对象。
我已尝试使用保存在“模型”选项卡中的源图形/模板,并且外部参照已正确附着到MS。 IIRC我的测试涉及保存到MS选项卡的图形
不用担心,我*以为*我是在使用保存到PS的源图形来保存步骤,因为创建的图纸将保存到PS。
后来我改为使用源代码的标准模板(保存在MS中),我必须找到一种使用Vla InsertBlock将标题栏添加到PS的方法。
干杯
页:
[1]