Viewing LineType Appearance

<?xml encoding=”UTF-8″>By Madhukar
Moogala

I have recieved this query, user would like to get appearance of LineTypeRecord or LineTypes through API.

We can use Comments API to gets the Linetype appearance in the form of ascii string.

Code:

public static void LineTypeAppearance()
{
Database database = HostApplicationServices.WorkingDatabase;
var ed = AcCore.Application.DocumentManager.MdiActiveDocument.Editor;
using (Transaction t = database.TransactionManager.StartTransaction())
{
var symTable = (SymbolTable)t.GetObject(database.LinetypeTableId,
OpenMode.ForRead);
foreach (ObjectId id in symTable)
{
var symbol = (LinetypeTableRecord)t.GetObject(id, OpenMode.ForRead);
ed.WriteMessage(string.Format("nName: {0}t Appearance: {1}",
symbol.Name, symbol.Comments));
}
t.Commit();
}
}

Output

Name: BYBLOCK   Desc:
Name: BYLAYER   Desc:
Name: CONTINUOUS      Desc: Solid line
Name: Wall Base|CENTER     Desc: Center ____ _ ____ _ ____ _ ____ _ ____ _ ____
Name: Wall Base|DASHED     Desc: Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _

Comments

One response to “Viewing LineType Appearance”

  1. badziewiak Avatar
    badziewiak

    Hello
    Thank you for this example.
    By the way: Is the line “t.Commit();” necessary in this case? We not making any changes.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading