ObjectArx设置标注样式,并置为当前

设置标注样式,这里就不再废话了,网上一大堆教程,你也可以参考CAD开发手册

这里只讲述将标注样式置为当前的办法,因为当前能在网上找到的置前方法,只能将我们新建的标注样式,加入到数据库中,但不能置前

1、先取得新建标注样式块表记录的 Id

AcDbObjectId DimStyleId;
pDimStyleTab->add(DimStyleId, pDimStyleTabRec);

2、复制标注样式数据,到当前数据库中。这一步很重要,如果直接调用 setDimstyle() 函数,咋们自己创建的标注样式,会加载到数据库中,但是置为当前的,是新建标注样式的替代样式,并且这个替代样式,并不是咋们新建的标注样式

AcDbDatabase* pDataBase = acdbHostApplicationServices()->workingDatabase();
Acad::ErrorStatus es = Acad::eOk;
es = pDataBase->setDimstyleData(pDimStyleTabRec);

3、设置标注样式。此时就需要之前取得的,新建标注样式块表记录的 Id

es = pDataBase->setDimstyle(DimStyleId);

4、点赞收藏

若有错误、遗漏,请评论区指正

C# ObjectARX 是 AutoCAD 的 .NET API,可以通过 C# 代码实现 AutoCAD 的二次开发。下面是按范围打印并设置打印样式表的示例代码: ```csharp using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.GraphicsInterface; using Autodesk.AutoCAD.PlottingServices; using Autodesk.AutoCAD.Publishing; namespace MyCommands { public class MyCommandsClass { [CommandMethod("MyPrint")] public void MyPrint() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; // 获取打印范围 PromptPointResult ppr = ed.GetPoint("\n请指定打印范围的第一个角点:"); if (ppr.Status != PromptStatus.OK) return; Point3d pt1 = ppr.Value; ppr = ed.GetCorner("\n请指定打印范围的第二个角点:", pt1); if (ppr.Status != PromptStatus.OK) return; Point3d pt2 = ppr.Value; // 设置打印样式表 string styleSheetName = "MyStyleSheet"; if (!PlotSettingsValidator.StyleSheetExists(styleSheetName)) { PlotSettingsValidator.AddNewStyleSheet(styleSheetName); } PlotSettingsValidator.SetCurrentStyleSheet(styleSheetName); // 创建打印信息 PlotInfo pi = new PlotInfo(); pi.Layout = "*Model_Space"; pi.OverrideSettings = null; // 创建打印设备 PlotSettings ps = new PlotSettings(doc.Editor); ps.CopyFrom(pi); // 设置打印范围 ps.SetPlotWindowArea(pt1, pt2); // 设置打印样式 ps.PlotStyleName = "monochrome.ctb"; // 创建打印对象 PlotInfoValidator piv = new PlotInfoValidator(); piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled; piv.Validate(pi); // 打印 PlotEngine pe = PlotFactory.CreatePublishEngine(); pe.BeginPlot(null, null); pe.BeginDocument(pi, doc.Name, null, 1, true, null); pe.BeginPage(new PlotPageInfo(), pi, true, null); pe.SetPlotSettings(ps); pe.BeginGenerateGraphics(null); pe.EndGenerateGraphics(null); pe.EndPage(null); pe.EndDocument(null); pe.EndPlot(null); } } } ``` 以上代码实现了按指定范围打印并设置打印样式表。需要注意的是,代码中的打印范围是使用 `SetPlotWindowArea` 方法设置的,打印样式表是使用 `PlotStyleName` 属性设置的。你可以根据自己的需要修改这些参数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值