Author Topic: Creating Vertical Dimensions (NOT Centered!!)  (Read 2472 times)

0 Members and 1 Guest are viewing this topic.

MGorecki

  • Guest
Creating Vertical Dimensions (NOT Centered!!)
« on: January 05, 2011, 01:01:56 PM »
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)

Code: [Select]
       '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:
Code: [Select]
    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

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Creating Vertical Dimensions (NOT Centered!!)
« Reply #1 on: January 05, 2011, 01:36:33 PM »
Doesn't look like you are adjusting the ' TextPosition ' property of the dimension.  Maybe that is you answer?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MGorecki

  • Guest
Re: Creating Vertical Dimensions (NOT Centered!!)
« Reply #2 on: January 05, 2011, 02:41:49 PM »
Tim!!  Thank you!  Thank you!!  That fixed it.  I had assumed that giving it the dim text location in the command would do it, so I was looking into system variables like "dimupt", but that was a dead end.

Again, thanks.

Mark

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Creating Vertical Dimensions (NOT Centered!!)
« Reply #3 on: January 05, 2011, 03:30:22 PM »
You're welcome Mark.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.