We need to iterate through the registered application symbol table of the current database from time to time. Here is some succinct and good code in C# to do so.
[CommandMethod("LinetypeIterator")]
public static void LinetypeIterator_Method()
{
Database database = HostApplicationServices.WorkingDatabase;
using (Transaction transaction = database.TransactionManager.StartTransaction())
{
SymbolTable symTable = (SymbolTable)transaction.GetObject(database.LinetypeTableId, OpenMode.ForRead);
foreach (ObjectId id in symTable)
{
LinetypeTableRecord symbol = (LinetypeTableRecord)transaction.GetObject(id, OpenMode.ForRead);
//TODO: Access to the symbol
MgdAcApplication.DocumentManager.MdiActiveDocument.Editor.WriteMessage(string.Format("\nName: {0}", symbol.Name));
}
transaction.Commit();
}
}
If the command is run, something like the following may be printed out to the command line window.
Command: LinetypeIterator
Name: ByBlock
Name: ByLayer
Name: Continuous
The leading edge AutoCAD .NET Addin Wizard (AcadNetAddinWizard) provides various wizards, coders, and widgets to help program AutoCAD addins in C#, VB.NET or even C++/CLI.
Recent Comments