本示例使用属性设置通过对象的线型电流。DatabaseCeltype VB.NETImports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
<CommandMethod("SetLinetypeCurrent")> _
Public Sub SetLinetypeCurrent()
'' 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 for read
Dim acLineTypTbl As LinetypeTable
acLineTypTbl = acTrans.GetObject(acCurDb.LinetypeTableId, _
OpenMode.ForRead)
Dim sLineTypName As String = "Center"
If acLineTypTbl.Has(sLineTypName) = True Then
'' Set the linetype Center current
acCurDb.Celtype = acLineTypTbl(sLineTypName)
'' Save the changes
acTrans.Commit()
End If
'' Dispose of the transaction
End Using
End Sub
C#using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
[CommandMethod("SetLinetypeCurrent")]
public static void SetLinetypeCurrent()
{
// 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 for read
LinetypeTable acLineTypTbl;
acLineTypTbl = acTrans.GetObject(acCurDb.LinetypeTableId,
OpenMode.ForRead) as LinetypeTable;
string sLineTypName = "Center";
if (acLineTypTbl.Has(sLineTypName) == true)
{
// Set the linetype Center current
acCurDb.Celtype = acLineTypTbl[sLineTypName];
// Save the changes
acTrans.Commit();
}
// Dispose of the transaction
}
}
VBA/ActiveX 代码参考ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item("Center")
相关概念父主题: |
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 17:09
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.