Ad

Wednesday, June 11, 2008

VBA Reports - Direction Fix

When you print out a report that included directions in DDMMSS format and you are using a precision of 4 the report will still print out the .0" value behind the seconds value (S45d34'34.0"E instead of S45d34'34"E). The following only works in 2008 and older. I don't have 2009 installed yet so I don't know if that program still has that problem. To get the .0 removed from the report do the following:

  • Run a report that uses a vba report.
  • Make a copy of the Report_Utilities file, the file may be found at C:\Program Files\AutoCAD Civil 3D 2008\Data\vba\Report_Utilities.dvb
  • Type vbaide at the command line.
  • Go to the Report_Utilities and the Format module.

image

  • Change the code in the section that starts with Select Case angFormat

image

  • Change the code to the following
Select Case angFormat
Case aeccFormatDecimal
sAngle =
CStr(dAng)
sPostfix = sPostfix +
" (d)"
Case aeccFormatDecimalDegreeMinuteSecond
sAngle = sDeg &
"." & sMin & sSec & sCnetSec
sPostfix = sPostfix +
" (dms)"
Case aeccFormatDegreeMinuteSecond
If angPrec < 5 Then
sAngle = sDeg & Chr(176) & sMin & "'" & sSec & """"
Else
sAngle = sDeg & Chr(176) & sMin & "'" & sSec & "." & sCentSec & """"
End If
Case aeccFormatDegreeMinuteSecondSpaced
If angPrec < 5 Then
sAngle = sDeg & Chr(176) & " " & sMin & "' " & sSec & """"
Else
sAngle = sDeg & Chr(176) & " " & sMin & "' " & sSec & "." & sCentSec & """"
End If
End Select
  • Save the file and run the report and see if it works.

Report I was using was Parcel Map Check Report

1 comment:

Anonymous said...

that may help format it correctly but the math still doesn't process correct. There is no coding to allow the DMS values to round up. Take a line at 38d59m59.9s. it will format to 38d59m59s instead of 39d00m00s. This code below will fix that part (it will ingore the precision set in the drawing), but the error north and east, as well as the closure will be incorrect for the selected precision. hopefully 09 will correct this, but for now I have been relying on the "export analysis" within the prospector.

Sample code:
If angFormat <> aeccFormatDecimal Then
iDeg = Int(dAng)
dAng = (dAng - iDeg) * 60
iMin = Int(dAng)
dAng = (dAng - iMin) * 60
dAng = Round(dAng, 1)
dAng = Round(dAng, 0)
iSec = Int(dAng)
iCentSec = 0

If dAng = 60 Then
iSec = 0
iMin = iMin + 1
If iMin = 60 Then
iMin = 0
iDeg = iDeg + 1
End If
End If

LinkWithin

Blog Widget by LinkWithin