CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

更改线型描述 (.NET)

2023-1-1 13:00| 发布者: admin| 查看: 399| 评论: 0|来自: AutoCAD

线型可以具有与其关联的描述。该描述提供了线型的 ASCII 表示形式。可以使用属性指定或更改线型描述。AsciiDescription

线型描述最多可包含 47 个字符。描述可以是注释或一系列下划线、点、短划线和空格,以显示线型图案的简单表示。

更改线型的描述

以下示例更改当前线型的说明。

VB.NET

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
 
<CommandMethod("ChangeLinetypeDescription")> _
Public Sub ChangeLinetypeDescription()
    '' Get the current document and database
    Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
    Dim acCurDb As Database = acDoc.Database
 
    '' Start a transaction
    Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
 
        '' Open the Linetype table record of the current linetype for write
        Dim acLineTypTblRec As LinetypeTableRecord
        acLineTypTblRec = acTrans.GetObject(acCurDb.Celtype, _
                                            OpenMode.ForWrite)
 
        '' Change the description of the current linetype
        acLineTypTblRec.AsciiDescription = "Exterior Wall"
 
        '' Save the changes and dispose of the transaction
        acTrans.Commit()
    End Using
End Sub

C#

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
 
[CommandMethod("ChangeLinetypeDescription")]
public static void ChangeLinetypeDescription()
{
    // Get the current document and database
    Document acDoc = Application.DocumentManager.MdiActiveDocument;
    Database acCurDb = acDoc.Database;
 
    // Start a transaction
    using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
    {
        // Open the Linetype table record of the current linetype for write
        LinetypeTableRecord acLineTypTblRec;
        acLineTypTblRec = acTrans.GetObject(acCurDb.Celtype,
                                            OpenMode.ForWrite) as LinetypeTableRecord;
 
        // Change the description of the current linetype
        acLineTypTblRec.AsciiDescription = "Exterior Wall";
 
        // Save the changes and dispose of the transaction
        acTrans.Commit();
    }
}

VBA/ActiveX 代码参考

ThisDrawing.ActiveLinetype.Description = "Exterior Wall"

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 13:19

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部