乐筑天下

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

[求助]如何批量处理一个目录下的所有DWG文件

[复制链接]

9

主题

26

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
62
发表于 2010-9-27 17:12:00 | 显示全部楼层 |阅读模式
如题,如下代码复制代码打开test文件夹下的DWG文件后,addTitle(doc)也没有报错,但是没有预期后的执行效果;
如下处理单个文件:   
[CommandMethod("addtitle")]
        public void bxcl()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            addTitle(doc);
        }
可以正常执行。
加上参数CommandFlags.Session以后,程序可以正常运行,感谢lzh741206  的指点
但是我觉得即使不加CommandMethod 的参数CommandFlags.Session程序也应该能够正常运行啊。
我感觉即使在一个session里面,打开操作其他Document并保存也是可行的,但是根据我代码的实际运行情况来看不可行。
我的代码哪里有问题?
对于cad的session正确理解是什么?
回复

使用道具 举报

9

主题

26

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
62
发表于 2010-9-27 17:25:00 | 显示全部楼层
谁能给个打开某一目录下所有的dwg文件并处理的例子啊?
回复

使用道具 举报

9

主题

26

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
62
发表于 2010-9-27 17:52:00 | 显示全部楼层
是不是要用到长事务?
回复

使用道具 举报

72

主题

2726

帖子

9

银币

社区元老

Rank: 75Rank: 75Rank: 75

铜币
3014
发表于 2010-9-27 17:54:00 | 显示全部楼层
[CommandMethod("addtitle", CommandFlags.Session)]
回复

使用道具 举报

9

主题

26

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
62
发表于 2010-9-27 20:11:00 | 显示全部楼层

一言中的啊
问题解决,看来我的要去了解示例方法和静态方法的知识了
我还是想知道我那代码不能运行的详细原因。
回复

使用道具 举报

72

主题

2726

帖子

9

银币

社区元老

Rank: 75Rank: 75Rank: 75

铜币
3014
发表于 2010-9-27 20:45:00 | 显示全部楼层

ActionMacro = 0x8000000 This bit commands that are defined as a result of recording a series of actions with the ActionRecorder.
Defun = 0x800 This flag can only be set by the Visual LISP engine. Command can be invoked as a LISP function and can therefore use acedGetArgs() to receive arguments from LISP and can use the acedRetXxx() functions to return values to LISP.
DocExclusiveLock = 0x100000 Document will be exclusively locked when command is invoked. If this bit is not set, then the document will be share locked when the command is invoked.
DocReadLock = 0x80000 Document will be read locked when command is invoked. If this bit is not set, then the document will be write locked when the command is invoked.
Interruptible = 0x400000 The command may be interrupted when prompting for user input while it is calling any of the acedGetxxx methods.
Modal = 0 Command cannot be invoked while another command is active.
NoActionRecording = 0x4000000 This flag causes the ActionRecorder to ignore the associated command
NoBlockEditor = 0x2000000 The command is blocked during a bedit session.
NoHistory = 0x800000 The command will not be added to AutoCAD’s repeat-last-command functionality.
NoPaperSpace = 0x40 Command cannot be invoked when in paperspace.
NoTileMode = 0x20 Command cannot be invoked when TILEMODE == 1.
NoUndoMarker = 0x1000000 The command and its undo markers will not be added to the undo file. This is intended for commands that don't modify the database, and therefore should not show up in the undo file.
Redraw = 4 When the pickfirst set or grip set are retrieved, they are not cleared within AutoCAD.
Command can retrieve the pickfirst set and the grip set by using the ads_ssgetfirst function.
Command can retrieve the pickfirst set via ads_ssget("I.").
Command can set both the pickfirst and grip sets using the ads_sssetfirst function. Objects in these sets are redrawn with the proper grip handles and highlighting upon completion of the command.
Session = 0x200000 The command will be run in the application execution context rather than the current document context, with the different capabilities and limitations that entails. It should be used sparingly.
Transparent = 1 Command can be invoked while another command is active.
ads_sssetfirst() cannot be used when this flag is set
Undefined = 0x200 Command can only be invoked via the cmdGroupName.cmdGlobalName syntax.
UsePickSet = 2 When the pickfirst set is retrieved, it is cleared within AutoCAD.
Command is able to retrieve the pickfirst set via the functions ads_ssgetfirst() or ads_ssget("I.").
Command can set the pickfirst set via ads_sssetfirst(), but it only stays set until the command ends.
Command cannot retrieve nor set grips.
回复

使用道具 举报

9

主题

26

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
62
发表于 2010-9-28 19:24:00 | 显示全部楼层
对每一个Document执行下面的操作
DocumentLock doclock = doc.LockDocument();
addTitle(doc);
doclock.Dispose();
没有预期的效果。(执行过程没有报错误,但是执行不能反映到该doc中去)
但是对于当前打开的文档
Document doc = Application.DocumentManager.MdiActiveDocument;
addTitle(doc);
又能够正常运行。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-6-29 04:06 , Processed in 1.851454 second(s), 67 queries .

© 2020-2025 乐筑天下

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