Friday, July 19, 2013

Simple Civil 3D Report Customization

Everyone probably knows that Civil 3D comes with a host of built in reports which are available under Toolspace / Toolbox.  Some of these were developed in dotnet and others are simple XSL stylesheets.  Unfortunately, neither report type lends itself to customization by average end users.  The Edit Report Settings feature allows for some very minor customizations, but it is extremely limited.  For example, when using Imperial Units, the Parcel Inverse Report will report areas in Square Feet only.



This post will detail how to add Acres or a combination of Square Feet and Acres to the inverse report by adding a few lines of code.

The source files for all of the XSL reports can be found here:  C:\ProgramData\Autodesk\C3D 20xx\yourlanguage\Data\Reports\xsl   The filenames themselves are easy enough to decipher.  Before editing our file, Parcel_Inverse.xsl, I strongly suggest that you make a backup copy of the original Autodesk supplied file.  In practice, I would make a backup and name it Parcel_Inverse.xsl.ootb (ootb is an extension that I use to communicate to myself that this is an unaltered "out of the box" file).

[In a future post, I'll discuss a method for organizing custom reports without having to continually modify files on one or more C drives.  By using a little organization, we can make customization much more workgroup friendly and upgrade friendly.]

Once you've made a backup copy, let's open Parcel_Inverse.xsl.  This is a simple text file which can be edited with any text editor.  I prefer to use Notepad++ because it highlights code in virtually every language that I use.  If you don't want to install another text editor, Notepad will do just fine, albeit in all-black text.

Locate this line in two places: 

<td><xsl:value-of select="landUtils:FormatNumber(string($ParcelArea), string($SourceAreaUnit), 'squareFoot', string($Parcel.2D_Area.precision), string($Parcel.2D_Area.rounding))"/></td>


Immediately after each instance of the line above, paste the following:
<!--Custom Code 2013-07-18 (rs) START -->
<tr>
<td width="33%">&#160;</td>
<td>Acres</td>
<td> <xsl:value-of select="landUtils:FormatNumber(string($ParcelArea), string($SourceAreaUnit), 'acre', string($Parcel.2D_Area.precision), string($Parcel.2D_Area.rounding))"/></td>
</tr>
<!--Custom Code 2013-07-18 (rs) END -->

As I mentioned, you'll have to do this in two places.  Once to accommodate when your report settings are set to "Default," which inherits the DWG file's area unit , and then again to accommodate when your report settings are set explicitly to "Square Feet."

As of this post, using the Autodesk-supplied file that came with Civil 3D 2014, the  custom code above should be pasted immediately after line 68 and then again after line 78.

Once this is complete, save the file and reexecute the report from the toolbox.  Hopefully, you'll see Acres listed immediately below Square Feet.

No comments: