この例では、Celtype プロパティを使用し、Database オブジェクトで線種を現在の線種に設定します。
Imports 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
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 } }
ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item("Center")