CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

访问集合 (.NET)

2023-1-1 16:40| 发布者: admin| 查看: 1269| 评论: 0|来自: AutoCAD

大多数集合和容器对象都是通过理论对象访问的。Theandobjects 包含一个属性,用于访问大多数可用集合对象的对象或对象 ID。例如,下面的代码定义一个变量并检索表示当前绘图中集合的对象:DocumentDatabaseDocumentDatabaseLayersTableLayers

VB.NET

'' Get the current document and start the Transaction Manager
Dim acCurDb As Database = Application.DocumentManager.MdiActiveDocument.Database
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
 
    '' This example returns the layer table for the current database
    Dim acLyrTbl As LayerTable
    acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId, _
                                 OpenMode.ForRead)
 
    '' Dispose of the transaction
End Using

C#

// Get the current document and start the Transaction Manager
Database acCurDb = Application.DocumentManager.MdiActiveDocument.Database;
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
    // This example returns the layer table for the current database
    LayerTable acLyrTbl;
    acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId,
                                 OpenMode.ForRead) as LayerTable;
 
     // Dispose of the transaction
}

VBA/ActiveX 代码参考

Dim layerCollection as AcadLayers
Set layerCollection = ThisDrawing.Layers

路过

雷人

握手

鲜花

鸡蛋

最新评论

python编程Autocad从入门到精通

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

GMT+8, 2024-5-6 20:19

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部