What is the proper way to set a Database's active DimStyle using the Managed API? When I set a DimStyle with the sample code below, it is set, but it's values are overridden by the properties of whatever DimStyle was previously set.
private void SetDimStyle(string dimStyleName)
{
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
DimStyleTable dst = (DimStyleTable)trans.GetObject(db.DimStyleTableId, OpenMode.ForRead);
if (dst.Has(dimStyleName))
{
DimStyleTableRecord dstr = (DimStyleTableRecord)trans.GetObject(dst[dimStyleName], OpenMode.ForRead);
if (dstr.ObjectId != db.Dimstyle)
db.Dimstyle = dstr.ObjectId;
}
}
}
That's it. I get the same results whether or not the dimstyle I am setting is just added, or already existed in the drawing.
Thanks!