Active Contributor
Posts: 44
Registered: ‎04-06-2005
Message 1 of 1 (107 Views)

Database DimStyle

107 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
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.