我在做插块功能,但正常下没问题但,我突然发现了个问题,当我用新布局的时候,这个命令就不行,所以我发现它只会缓存“模型”和“布局1”(一个布局),当我用“布局2”或者新增的布局时,(vla-get-PaperSpace (vla-get-ActiveDocument (vlax-get-acad-object))就会出错,请教这个怎么解决
- ;;(lyt_bl_insert "名" (getpoint) 1 1 1 0)
- ;;说明:插入块
- ;;参数:block_name:
- ;;返回:ent
- (defun lyt_bl_insert (block_name pt xs ys zs ang / bn doc e2 e1 l-b mspace str)
- (defun T_220530block (block_name)
- (vla-insertblock
- mspace
- (vlax-3d-point pt)
- block_name
- xs
- ys
- zs
- ang
- )
- )
- ;(vl-load-com)
- ;(vlax-release-object (vlax-get-acad-object))
- ;(setq doc (cadr(lyt_doc)))
- (setq str "想插入的文件不存在\n")
- (setq e1 (entlast))
- (setq doc (Vlax-Get (Vlax-Get-Acad-Object) 'ActiveDocument));(vla-get-ActiveDocument (vlax-get-acad-object))
- (if(= 1(vla-get-ActiveSpace doc));(vla-get-ActiveDocument (vlax-get-acad-object))
- (setq mspace (vla-get-modelspace doc))
- (setq mspace (vla-get-PaperSpace doc))
- )
- (vlax-for block (lyt_vget vla-get-blocks)
- (setq l-b (cons (vla-get-name block) l-b))
- )
- (if(member block_name l-b)
- (T_220530block block_name)
- (if (wcmatch block_name "~*.dwg")
- (if (findfile block_name);(setq block_name (findfile (strcat block_name ".dwg")))
- (T_220530block block_name)
- (progn
- (setq bn(strcat block_name ".dwg"))
- (if (findfile bn)
- (T_220530block bn)
- (progn
- (setq bn(strcat block_name ".dxf"))
- (if (findfile bn)
- (T_220530block bn)
- (princ str)
- )
- )
- )
- )
- )
- (if (findfile block_name)
- (T_220530block block_name)
- (princ str)
- )
- )
- )
- ;(vl-doc-ref 'vla-get-PaperSpace)
- ;(vlax-release-object (vla-get-Document (vlax-get-acad-object)))
- (vlax-release-object doc)
- (vlax-release-object (vlax-get-acad-object))
- (setq e2 (entlast))
- (if (not(equal e1 e2))
- e2
- nil
- )
- )
|