Active Contributor
44 Posts
0 Kudos
Registered: ‎04-06-2005
Post 1 of 1

Database DimStyle

109 Views, 0 Replies
01-16-2006 01:10 PM
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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post