.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Database DimStyle

0 REPLIES 0
Reply
Message 1 of 1
jimmie_fulton
208 Views, 0 Replies

Database DimStyle

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!
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost