Hi Hallex,
Thanks for the link. I think I have it figured out. This code works for me.
Public Sub AddHorDim(ByVal dimPnt1 As Point3d, ByVal dimPnt2 As Point3d, ByVal dimLoc As Point3d, ByVal dimType As String)
'Get the current database
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Dim DimStyleName As String
DimStyleName = "BASIC"
Select Case dimType
Case "A"
DimStyleName = "BASIC"
Case "B"
DimStyleName = "BASIC_1pl_decimal"
Case "C"
DimStyleName = "BASIC_BOXED"
Case "D"
DimStyleName = "BASIC_PAREN"
End Select
'Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim acDimStylTbl As DimStyleTable = acTrans.GetObject(acCurDb.DimStyleTableId, OpenMode.ForRead)
'Open the Block table for read
Dim acDimStylTblRec As DimStyleTableRecord
acDimStylTblRec = New DimStyleTableRecord()
acDimStylTblRec.Name = DimStyleName
acDimStylTblRec = acTrans.GetObject(acDimStylTbl(DimStyleName), OpenMode.ForWrite)
acCurDb.Dimstyle = acDimStylTbl(DimStyleName)
acCurDb.Dimstyle = acDimStylTblRec.ObjectId
acCurDb.SetDimstyleData(acDimStylTblRec)
'Commit the changes
acTrans.Commit()
End Using
'' Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
'Open the Block table for read
Dim acBlkTbl As BlockTable
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
'Open the Block table record Model space for write
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
'Create the rotated dimension
'To add a horizontal dimension, use a rotation angle of 0.0
Dim acRotDim As RotatedDimension = New RotatedDimension()
acRotDim.SetDatabaseDefaults()
acRotDim.XLine1Point = dimPnt1
acRotDim.XLine2Point = dimPnt2
acRotDim.DimLinePoint = dimLoc
'Rotation angle is in radians
acRotDim.Rotation = 0.0
'Add the new object to Model space and the transaction
acBlkTblRec.AppendEntity(acRotDim)
acTrans.AddNewlyCreatedDBObject(acRotDim, True)
'Commit the changes
acTrans.Commit()
End Using
End Sub