Hello All,
I'm using VB.Net to write my code. I have a section that calculates the first and second point of the dimension, as well as the location of the dimension text. That is then sent to the Sub that actually creates the dimension (see below)
'Add the horizontal and vertical dimensions for the substrate outline
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Using docloc As DocumentLock = doc.LockDocument
Using db As Database = doc.Database
Using tr As Transaction = db.TransactionManager.StartTransaction
Try
dimStyleName = "BASICROMANS_BOXED"
dimSuffix = ""
AddHorDim(db, tr, subHorDimPnt1, subHorDimPnt2, subHorDimLoc, dimStyleName, dimSuffix)
AddVerDim(db, tr, subVerDimPnt1, subVerDimPnt2, subVerDimLoc, dimStyleName, dimSuffix)
tr.Commit()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage(ex.Message & vbCr & ex.StackTrace)
End Try
End Using
End Using
End Using[/size][/size]
This section creates the dimension:
Public Sub AddVerDim(ByVal db As Database, ByVal tr As Transaction, ByVal dimPnt1 As Point3d, ByVal dimPnt2 As Point3d, ByVal dimLoc As Point3d, _
ByVal dimStyleName As String, ByVal dimSuffix As String)
'Get the current database
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Dim BlkTblRec As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
Dim DimTbl As DimStyleTable = CType(tr.GetObject(db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
If Not DimTbl.Has(dimStyleName) Then Return
Dim DimRecord As DimStyleTableRecord = CType(tr.GetObject(DimTbl(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)
'Rotation angle is in radians
Dim RotAng As Double = 1.57079633
Dim RotDim As RotatedDimension = New RotatedDimension(RotAng, dimPnt1, dimPnt2, dimLoc, "<>", DimRecord.ObjectId)
If dimSuffix = "TYP." Then
'Override the dimension text
RotDim.DimensionText = "<> TYP."
End If
BlkTblRec.AppendEntity(RotDim)
db.TransactionManager.AddNewlyCreatedDBObject(RotDim, True)
End Sub
The problem is that no matter where I tell it to place the dimension text, it always comes in centered in the dimension, which causes it to overlap another vertical dimension. I just want to place the dimension text a bit higher than center.
Thanks,
Mark