乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 49|回复: 18

[编程交流] ObjectDBX: vla-Detach

[复制链接]

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 07:18:55 | 显示全部楼层 |阅读模式
As Reference Manager can only change the path to External References, and not the name of the reference drawing itself (which I need to do), I'm looking into correcting a set of drawings using ObjectDBX.
 
I've been successful at adding XREFs to ODBX drawings in the past using vla-AttachExternalReference, but am not understanding why I am receiving this error when attempting to detach:
 
  1. ; error: Automation Error. Description was not provided.
 
Here is my 'working' code at the moment:
 

[code](defun c:FOO  (/ sheets path dbx n oXref) (vl-load-com) (if (and (setq sheets (vl-directory-files                         (setq path "SomePath\\")                         "*.dwg"                         1))          (setq dbx (vla-GetInterfaceObject                      (vlax-Get-Acad-Object)                      (strcat "ObjectDBX.AxDbDocument."                              (substr (getvar 'acadver) 1 2)))))   (progn     (foreach sheet  sheets       (vl-catch-all-apply         'vla-open         (list dbx (strcat path sheet)))       (vlax-for x  (setq oLayoutBlock                           (vla-get-block                             (vla-item (vla-get-layouts dbx)                                       "Model")))         (if           (and (= "AcDbBlockReference" (vla-get-objectname x))                (vl-position                  (setq n (vla-get-effectivename x))                  '("XREF1" "XREF2"))                (= :vlax-true                   (vla-get-isxref                     (setq                       oXref (vla-item (vla-get-blocks dbx) n)))))            (vla-detach oXref)))                                       ;
回复

使用道具 举报

11

主题

98

帖子

87

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-6 07:22:41 | 显示全部楼层
I think you need to reference the document as the first parameter and then the xref as a second
  1. (vla-detach dbx oXref)
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 07:27:49 | 显示全部楼层
Soliver, I appreciate the suggestion.
 
Despite the parameters listed in the Developer Documentation, I tried your suggestion anyways with no success.
 
See the error returned:
 
  1. ; error: ActiveX Server returned the error: unknown name: Detach
 
... As the ODBX Document Object does not inherit the Detach Method.
 
回复

使用道具 举报

11

主题

98

帖子

87

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-6 07:29:13 | 显示全部楼层
Heavy
I think this post covers it: http://www.cadtutor.net/forum/archive/index.php/t-44133.html
 
I reckon the following is roughly what you're looking for from the link.
  1. (vlax-for block (setq blocks(vla-get-blocks dbx)))   (if(= (vla-get-isXRef block) :vlax-true)   (vla-detach block) ))
回复

使用道具 举报

3

主题

27

帖子

25

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 07:35:27 | 显示全部楼层
RenderMan,
Did you ever resolve this?
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 07:36:54 | 显示全部楼层
 
Knowing full well that I am willingly, officially zombifying this thread....
 
Wow I was bad about posting my solution back then... I did, and will dig through my toolbox to see if I cannot find what I used. I've learned a lot since back then, and may have changed code for other uses, etc..
 
Is there something specific your needing other than what I describe above?
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 07:39:35 | 显示全部楼层
Of course, were I coding this new, I'd probably use the .NET API... Specifically ReadDwgFile() and Autodesk.AutoCAD.Internal.Utils.WcMatch(string, string) Methods.
回复

使用道具 举报

3

主题

27

帖子

25

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 07:44:00 | 显示全部楼层
Specifically. Detaching an xref from a drawing that is opened with dbx.
I'm converting a lisp that originally only functioned in the current session. Now I wish to convert to batch processing with dbx.
I'm just not there in .net yet.
 
vla-detach works in the current session, but fails in dbx - exactly the problem you had. How did you wind up detaching while in dbx?
 
One suggestion was to vla-delete = failed
The post suggested by SOliver also did not solve. Couldn't really tell if Joro was getting results and Lee was trying to troubleshoot..??, or if Lee hadn't tested the concept first?? Either way, it was a similar issue. Lee's code generated the Automation error without vla-catch-all-apply.
 
I would have started a new post, but I didn't see that age of this post in my browser. Thanks for looking back into this.
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 07:46:16 | 显示全部楼层
It was so long ago, I honestly do not remember how I got around this... I'll see what I can find, and post back.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 07:51:39 | 显示全部楼层
As far as I know, XRefs are not loaded in drawings opened with ObjectDBX and hence cannot be detached.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-10 05:10 , Processed in 0.726075 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表