ObjectArx学习笔记-设置字体样式

实现代码:

static void qxzyOperateLayer_AddStyle(void)
	{
		AcDbTextStyleTable *pTextStyleTbl;
		acdbHostApplicationServices()->workingDatabase()
			->getTextStyleTable(pTextStyleTbl, AcDb::kForWrite);

		AcDbTextStyleTableRecord *pTextStyleTblRcd;
		pTextStyleTblRcd = new AcDbTextStyleTableRecord();
		pTextStyleTblRcd->setName(_T("仿宋体"));
		pTextStyleTblRcd->setFileName(_T("simfang.ttf"));
		pTextStyleTblRcd->setXScale(0.7);

		pTextStyleTbl->add(pTextStyleTblRcd);

		pTextStyleTblRcd->close();
		pTextStyleTbl->close();
	}

字体的名称不一定与字体文件的名称相同。打开控制面板,进入“字体”文件夹,右键单击“仿宋体”图标,从弹出的快捷菜单中选择【属性】菜单项,系统会弹出对话框显示字体文件的名称。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
从acdbmgd.dll导出的内容,方便参考,格式如下: 类:Autodesk.AutoCAD.DatabaseServices.TextStyleTableRecord:Autodesk.AutoCAD.DatabaseServices.SymbolTableRecord New() 方法: {dtor}() {dtor}() {dtor}() {dtor}() ApplyPaperOrientationTransform(Viewport) ApplyPartialUndo(DwgFiler,RXClass) Audit(AuditInfo) Cancel() Close() CloseAndPage(Boolean) CopyFrom(RXObject) CreateExtensionDictionary() DisableUndoRecording(Boolean) Dispose() DowngradeOpen() DowngradeToNotify(Boolean) DwgIn(DwgFiler) DwgOut(DwgFiler) DxfIn(DxfFiler) DxfOut(DxfFiler) Erase() Erase(Boolean) HandOverTo(DBObject,Boolean,Boolean) ReleaseExtensionDictionary() RemoveField(ObjectId) ResetScaleDependentProperties() SetObjectIdsInFlux() SetPaperOrientation(Boolean) SwapIdWith(ObjectId,Boolean,Boolean) SwapReferences(IdMapping) UpgradeOpen() ViewportDraw(ViewportDraw) XDataTransformBy(Matrix3d) 函数: Clone() AS System.Object CompareTo(Object) AS System.Int32 CreateObjRef(Type) AS System.Runtime.Remoting.ObjRef DecomposeForSave(DwgVersion) AS Autodesk.AutoCAD.DatabaseServices.DecomposeForSaveReplacementRecord DeepClone(DBObject,IdMapping,Boolean) AS Autodesk.AutoCAD.DatabaseServices.DBObject Equals(Object) AS System.Boolean GetHashCode() AS System.Int32 GetLifetimeService() AS System.Object GetObjectSaveVersion(DwgFiler) AS Autodesk.AutoCAD.DatabaseServices.FullDwgVersion GetObjectSaveVersion(DxfFiler) AS Autodesk.AutoCAD.DatabaseServices.FullDwgVersion GetPersistentReactorIds() AS Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection GetReactors() AS System.Collections.Generic.List`1[[Autodesk.AutoCAD.Runtime.RXObject, acdbmgd, Version=17.1.0.0, Culture=neutral, PublicKeyToken=null]] GetRXClass() AS Autodesk.AutoCAD.Runtime.RXClass GetType() AS System.Type GetXDataForApplication(String) AS Autodesk.AutoCAD.DatabaseServices.ResultBuffer HasPersistentReactor(ObjectId) AS System.Boolean InitializeLifetimeService() AS System.Object QueryX(RXClass) AS System.IntPtr RemoveField() AS Autodesk.AutoCAD.DatabaseServices.ObjectId RemoveField(String) AS Autodesk.AutoCAD.DatabaseServices.ObjectId SetAttributes(DrawableTraits) AS System.Int32 SetField(Field) AS Autodesk.AutoCAD.DatabaseServices.ObjectId SetField(String,Field) AS Autodesk.AutoCAD.DatabaseServices.ObjectId SetFromStyle() AS System.Boolean ToString() AS System.String UpgradeFromNotify() AS System.Boolean ViewportDrawLogicalFlags(ViewportDraw) AS System.Int32 WblockClone(RXObject,IdMapping,Boolean) AS Autodesk.AutoCAD.DatabaseServices.DBObject WorldDraw(WorldDraw) AS System.Boolean X(RXClass) AS System.IntPtr 属性: AcadObject AS System.Object 可读不可写 Annotative AS Autodesk.AutoCAD.DatabaseServices.AnnotativeStates 可读可写 AutoDelete AS System.Boolean 可读可写 BigFontFileName AS System.String 可读可写 ClassID AS System.Guid 可读不可写 Database AS Autodesk.AutoCAD.DatabaseServices.Database 可读不可写 Drawable AS Autodesk.AutoCAD.GraphicsInterface.Drawable 可读不可写 DrawableType AS Autodesk.AutoCAD.GraphicsInterface.DrawableType 可读不可写 ExtensionDictionary AS Autodesk.AutoCAD.DatabaseServices.ObjectId 可读不可写 FileName AS System.String 可读可写 FlagBits AS System.Byte 可读可写 Font AS Autodesk.AutoCAD.GraphicsInterface.FontDescriptor 可读可写 Handle AS Autodesk.AutoCAD.DatabaseServices.Handle 可读不可写 HasFields AS System.Boolean 可读不可写 HasSaveVersionOverride AS System.Boolean 可读可写 Id AS Autodesk.AutoCAD.DatabaseServices.ObjectId 可读不可写 IsAProxy AS System.Boolean 可读不可写 IsCancelling AS System.Boolean 可读不可写 IsDependent AS System.Boolean 可读不可写 IsDisposed AS System.Boolean 可读不可写 IsErased AS System.Boolean 可读不可写 IsEraseStatusToggled AS System.Boolean 可读不可写 IsModified AS System.Boolean 可读不可写 IsModifiedGraphics AS System.Boolean 可读不可写 IsModifiedXData AS System.Boolean 可读不可写 IsNewObject AS System.Boolean 可读不可写 IsNotifyEnabled AS System.Boolean 可读不可写 IsNotifying AS System.Boolean 可读不可写 IsObjectIdsInFlux AS System.Boolean 可读不可写 IsPersistent AS System.Boolean 可读不可写 IsReadEnabled AS System.Boolean 可读不可写 IsReallyClosing AS System.Boolean 可读不可写 IsResolved AS System.Boolean 可读不可写 IsShapeFile AS System.Boolean 可读可写 IsTransactionResident AS System.Boolean 可读不可写 IsUndoing AS System.Boolean 可读不可写 IsVertical AS System.Boolean 可读可写 IsWriteEnabled AS System.Boolean 可读不可写 MergeStyle AS Autodesk.AutoCAD.DatabaseServices.DuplicateRecordCloning 可读可写 Name AS System.String 可读可写 ObjectBirthVersion AS Autodesk.AutoCAD.DatabaseServices.FullDwgVersion 可读不可写 ObjectId AS Autodesk.AutoCAD.DatabaseServices.ObjectId 可读不可写 ObliquingAngle AS System.Double 可读可写 OwnerId AS Autodesk.AutoCAD.DatabaseServices.ObjectId 可读可写 PaperOrientation AS Autodesk.AutoCAD.DatabaseServices.PaperOrientationStates 可读不可写 PriorSize AS System.Double 可读可写 TextSize AS System.Double 可读可写 UndoFiler AS Autodesk.AutoCAD.DatabaseServices.DwgFiler 可读不可写 UnmanagedObject AS System.IntPtr 可读不可写 XData AS Autodesk.AutoCAD.DatabaseServices.ResultBuffer 可读可写 XScale AS System.Double 可读可写 -------------------------------- 类:Autodesk.AutoCAD.DatabaseServices.TextVerticalMode:System.Enum 函数: CompareTo(Object) AS System.Int32 Equals(Object) AS System.Boolean GetHashCode() AS System.Int32 GetType() AS System.Type GetTypeCode() AS System.TypeCode ToString() AS System.String ToString(IFormatProvider) AS System.String ToString(String,IFormatProvider) AS System.String ToString(String) AS System.String 字段: TextBase AS TextVerticalMode TextBottom AS TextVerticalMode TextTop AS TextVerticalMode TextVerticalMid AS TextVerticalMode value__ AS Int32
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` 属性设置的。你可以根据自己的需要修改这些参数。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值