使用线型 (.NET)
线型是破折号、点和空格的重复图案。复杂线型是符号的重复模式。要使用线型,必须先将其加载到图形中。线型定义必须存在于 LIN 库文件中,然后才能将线型加载到图形中。若要将线型加载到图形中,请使用对象的 member 方法。LoadLineTypeFileDatabase 注意:AutoCAD 内部使用的线型不应与某些绘图仪提供的硬件线型相混淆。两种类型的虚线产生相似的结果。但是,不要同时使用这两种类型,因为结果可能无法预测。
将线型加载到 AutoCAD 中本示例尝试从 acad.lin 文件加载线型“CENTER”。如果线型已存在,或者文件不存在,则会显示一条消息。 VB.NETImports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices <CommandMethod("LoadLinetype")> _ Public Sub LoadLinetype() '' 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) = False Then '' Load the Center Linetype acCurDb.LoadLineTypeFile(sLineTypName, "acad.lin") End If '' 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("LoadLinetype")] public static void LoadLinetype() { // 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) == false) { // Load the Center Linetype acCurDb.LoadLineTypeFile(sLineTypName, "acad.lin"); } // Save the changes and dispose of the transaction acTrans.Commit(); } } VBA/ActiveX 代码参考Sub LoadLinetype() On Error GoTo ERRORHANDLER Dim linetypeName As String linetypeName = "CENTER" ' Load "CENTER" line type from acad.lin file ThisDrawing.Linetypes.Load linetypeName, "acad.lin" Exit Sub ERRORHANDLER: MsgBox Err.Description End Sub 父主题: |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-19 07:26
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.