乐筑天下

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

如何不打开图形设置图纸的页面设置

[复制链接]

4

主题

9

帖子

2

银币

初来乍到

Rank: 1

铜币
25
发表于 2013-6-20 20:40:00 | 显示全部楼层 |阅读模式
Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db1 = new Database(false, true);
            db1.ReadDwgFile("c:\\Awork\\1.dwg", System.IO.FileShare.ReadWrite, true, "");
            using (Transaction trans1 = db1.TransactionManager.StartTransaction())
            {               
                // Reference the Layout Manager
                LayoutManager acLayoutMgr;
                acLayoutMgr = LayoutManager.Current;
                // Get the current layout and output its name in the Command Line window
                Layout acLayout;
                acLayout = trans1.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout),
                                             OpenMode.ForRead) as Layout;
每次执行到这一行就出错,显示“eNotFromThisDocument”,怎么回事啊
                // Get the PlotInfo from the layout
                PlotInfo acPlInfo = new PlotInfo();
                acPlInfo.Layout = acLayout.ObjectId;
                // Get a copy of the PlotSettings from the layout
                PlotSettings acPlSet = new PlotSettings(acLayout.ModelType);
                acPlSet.CopyFrom(acLayout);
回复

使用道具 举报

32

主题

651

帖子

8

银币

中流砥柱

Rank: 25

铜币
779
发表于 2013-6-20 22:42:00 | 显示全部楼层
意思应该是 acLayoutMgr 和 db1 不属于同一个Dwg文件,猜而已。
回复

使用道具 举报

4

主题

9

帖子

2

银币

初来乍到

Rank: 1

铜币
25
发表于 2013-6-21 19:50:00 | 显示全部楼层

           现在已经能不打开图形创建新页面设置了,但是名为*model*初始默认页面设置无法访问编辑,我用同名plotsettings覆盖没用,想设置创建的新页面设置设置为当前,又不知道怎么弄
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db1 = new Database(false, true);
            db1.ReadDwgFile("c:\\Awork\\1.dwg", System.IO.FileShare.ReadWrite, true, "");
            using (Transaction trans1 = db1.TransactionManager.StartTransaction())
            {               
                PlotSettings acPlSet = new PlotSettings(true);
               
                DBDictionary GroDic = (DBDictionary)trans1.GetObject(db1.PlotSettingsDictionaryId , OpenMode.ForWrite);
               
                acPlSet.PlotSettingsName = "111";//名为*model*初始默认页面设置无法访问编辑,我用同名plotsettings覆盖没用
               
                // Update the PlotSettings object
                PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
                // Set the plot type
                acPlSetVdr.SetPlotType(acPlSet,Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
                // Set the plot scale
                acPlSetVdr.SetUseStandardScale(acPlSet, true);
                acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.ScaleToFit);
                // Center the plot
                acPlSetVdr.SetPlotCentered(acPlSet, true);
                // Set the plot device to use
                acPlSetVdr.SetPlotConfigurationName(acPlSet, "Microsoft XPS Document Writer","A3");
                acPlSetVdr.SetCurrentStyleSheet(acPlSet, "monochrome.ctb");               
                GroDic.SetAt("111", acPlSet);  
                trans1.AddNewlyCreatedDBObject(acPlSet, true);
                acPlSetVdr.SetDefaultPlotConfig(acPlSet);//这句我以为是设置为当前页面设置,不过试下来没用,怎么才能设置为当前页面设置啊
                try
                {
                    db1.SaveAs("c:\\Awork\\1.dwg", true, DwgVersion.Current, doc.Database.SecurityParameters);//指定c盘根目录保存
                }
                catch
                {
                    return;
                }
                trans1.Commit();
            }
回复

使用道具 举报

2

主题

10

帖子

3

银币

初来乍到

Rank: 1

铜币
18
发表于 2014-6-7 20:57:00 | 显示全部楼层
acPlSetVdr.SetDefaultPlotConfig(acPlSet);//这句我以为是设置为当前页面设置,不过试下来没用,怎么才能设置为当前页面设置啊
上面的问题不知道楼主解决没?为了给遇到同样问题的朋友以参考,我找到的方法是:
acLayout.CopyFrom(plSet)
其中acLayout为layout;plSet为PlotSettings。
具体的方法要仔细看一下Managed .NET Developer's Guide (.NET)中相应的代码。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 20:56 , Processed in 0.823662 second(s), 60 queries .

© 2020-2025 乐筑天下

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