private void SetDimStyle(string dimStyleName)
{
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
DimStyleTable DimTabb = (DimStyleTable)trans.GetObject(db.DimStyleTableId, OpenMode.ForRead);
if (DimTabb.Has(dimStyleName))
{
DimStyleTableRecord DimTabbRecaord = (DimStyleTableRecord)trans.GetObject(DimTabb[dimStyleName], OpenMode.ForRead);
if (DimTabbRecaord.ObjectId != db.Dimstyle)
{
db.Dimstyle = DimTabbRecaord.ObjectId;
//A similar method might not be needed in the case of text style setting a similar property as above should be enough
db.SetDimstyleData(DimTabbRecaord);
}
}
}
}
VB.NET Code
Private Sub SetDimStyle(ByVal dimStyleName As String)
Dim db As Database = HostApplicationServices.WorkingDatabase
Using trans As Transaction = db.TransactionManager.StartTransaction()
Dim DimTabb As DimStyleTable = DirectCast(trans.GetObject(db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
If DimTabb.Has(dimStyleName) Then
Dim DimTabbRecaord As DimStyleTableRecord = DirectCast(trans.GetObject(DimTabb(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)
if DimTabbRecaord.ObjectId <> db.Dimstyle Then
db.Dimstyle = DimTabbRecaord.ObjectId
'A similar method might not be needed in the case of text style setting a similar property as above should be enough
db.SetDimstyleData(DimTabbRecaord)
End If
End If
End Using
End Sub
Can't find what you're looking for? Ask the community or share your knowledge.