CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2020 开发者帮助

更改线型说明 (.NET)

2024-5-18 18:25| 发布者: admin| 查看: 12| 评论: 0|原作者: admin|来自: AutoCAD

更改线型说明 (.NET)

线型可以具有与之关联的描述。描述提供线型的 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-6-27 16:03

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部