Identifying whether dim style is Annotative or not

By Virupaksha Aithal

Each Annotative dimension style will have an Xdata with name “AcadAnnotative”. This presence of particular xdata can be used to identify whether dim style is Annotative or not

[CommandMethod("DimStyleAnnotative")]
public void DimStyleAnnotative()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;
    Editor ed = doc.Editor;
 
    using (Transaction Tx = db.TransactionManager.StartTransaction())
    {
        DimStyleTable dimStyleTable = Tx.GetObject(
                                       db.DimStyleTableId,
                                  OpenMode.ForRead) as DimStyleTable;
 
        foreach (ObjectId id in dimStyleTable)
        {
            DimStyleTableRecord style = Tx.GetObject(id, 
                            OpenMode.ForRead) as DimStyleTableRecord;
            ResultBuffer xdata = 
                       style.GetXDataForApplication("AcadAnnotative");
 
            if (xdata != null)
            {
                ed.WriteMessage("dim style " +
                                    style.Name + " is Annotativen");
 
                xdata.Dispose();
            }
            else
            {
                ed.WriteMessage("dim style " +
                                style.Name + " is non Annotativen");
            }
        }
 
        Tx.Commit();
    }
 
}

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading