Creating a Report with Visual Report Designer
Visual Report Designer allows you to create most any report or table using a simple drag-and-drop process. Before you can create a report, you must first understand the structure of a report template and how it interacts with AutoCAD Civil 3D.
Report template documents are organized by ‘bands’ which are bound to classifications (or ‘types’) of drawing/model entities (e.g. points, corridors, surfaces, etc.), and queries are used to determine which entities will be used to populate the report. Reports may also have bands which represent page/group headers and footers, and which may contain summation data for groups of entities.
When a report document is executed against the active drawing, the reporting engine first determines which types of entities the report is bound to. It then retrieves all entities of these types and filters the result using the queries defined for the report. The resulting data is then used to generate a report document using the structure and formatting defined in the report template. When a report is generated, the bands will be repeated for each entity returned by the query operation – bands can therefore be thought of like a ‘row’ in a table.
The final generated report document may be previewed, printed, exported to various document file formats, or inserted directly into the DWG.
Creating a Report Template
To create a report template, you must first open Visual Report Designer from within AutoCAD Civil 3D. To do so, click on the Visual Report Designer icon in the civil+plus ribbon bar:
This will open the main Visual Report Designer window, generally referred to as the ‘report designer.’
Next, we’ll create a new report using the left-most icon in the report designer toolbar:
At this point, we have an empty report template, and the Field List is populated with entity types and fields to add to your report. The report is also divided into header, ‘detail’, and footer bands:
The initial ‘detail’ band is automatically bound to your drawing. To add bands which are bound to specific entity types, you need to add ‘child’ detail report bands by right-clicking on the existing detail band header bar and selecting the proper entity under the ‘Insert Detail Report’ menu option:
For this tutorial, let’s create a report to show information about specific polylines in the drawing. After adding the child detail report band for ‘Polylines’, our report template now looks like this:
We now have the proper containers in place and are ready to add some fields. To do so, we look to the Field List window pane (typically docked on the right side of the report designer window):
Inserting a field into the report template is simple – you just click and drag the field from the list into the appropriate band in the report template. When the field is dropped into the report template, it will automatically create the proper type of control to display the information returned by the selected field, and will automatically bind that control to that field. For example, let’s say we want to see the ‘Object Id’ value for the polyline (this is the ID which AutoCAD uses to identify the entity). To do this, we select the ‘ObjectId’ field and drag it into the report template. This operation creates a new label in the report which is bound to the ObjectId field of the polyline associated with the current instance of the band we placed the field label in.
Let’s add a few more fields, and some static labels. We will repeat the above process to add references to the ‘Length’, NumVerts’, and ‘Closed’ fields. We will then drag/drop three labels from the Tool Box window pane (typically found on the left side of the report designer window) and set the label text by clicking on the label control in the report template and typing the text we want it to display:
Note that if we want, we can change fonts, colors, etc for all labels in the report template.
For this report, we may also want to show an image of each of the polyline entities returned by the report query. To do this, we simply drag the ‘Image’ field from the Field List into the report template, and resize as desired:
The image control will show up as an empty box in the report template – when we run the report, it will show an image of the polyline entity associated with the current instance of the row it is placed in.
Now that we have our report template defined, only one step remains before we can test our work and run the report against the current drawing: we need to save first.
Running the Report
Now that we have defined and saved a report template, we can run it against the current DWG in AutoCAD Civil 3D. There are several ways the report may be run (Insert Report, Insert Report to Layouts, Batch Export Reports, etc). For our current purposes, we will simply preview the report within the report designer. To do this we select the Print Preview tab in the report designer window:
When you select the Print Preview tab, the reporting engine will switch from designer mode and will run or execute the report. This will cause the Edit Queries dialog window to appear:
In this window, you can define a query that will be used to select entities from the drawing for inclusion in the final report document. You can filter by layer, color, linetype, etc, and can define a selection set. It is also possible to select all entities within a specific boundary (defined by a polyline, layout viewport, etc.) – we’ll save this last item as a subject for a future post. For now, let’s just leave the query with the default settings (which will automatically return ALL entities of the specified type). Note that if no items are selected for a ‘selection set’, the selection set will return all appropriate entities from the current drawing. Once the queries are configured as desired, we click the ‘OK’ button to proceed to generate the report document from our drawing entities:
The report document generated includes three copies of the detail report band bound to the Polylines entity collection – one for each polyline returned by the query. Each band contains all of the fields we defined in the report template, including an image of the polyline. From here, we can print the report, export it as a document file (PDF, XLSX, HTML, etc.), or insert it directly to the DWG.
Now that know how to create and execute a basic report, you can delve deeper into the Visual Report Designer reporting engine and feature set to explore the virtually limitless possibilities for creating reports and tables. Some variations of this report include:
- Formatting the labels: size, color, font, etc.
- Adding mode child detail report bands for things such as polyline vertices, etc. (many entities, including polylines, are hierarchical in nature and contain child collections of data)
- Adding document information such as the DWG filename, thumbnail image, etc. to the header and/or footer
- Adding the current username and date to the footer
- Adding summation and sorting features
- Setting up the report to work with the Insert To Layouts command
We’ll continue to add additional posts showing examples some of these and other features of Visual Report Designer. You can also refer to the Visual Report Designer documentation for more information.