Music for Your Brain: Advanced Lessons in the Subassembly Composer

Music for Your Brain: Advanced Lessons in the Subassembly Composer

Peter Funk – Autodesk, Inc.

CI4264From the BasicLane to the OverlayMillAndLevel to the DaylightBasinImperial, join Peter as he teaches you the language of the Subassembly Composer to create your own music.

Learning Objectives

At the end of this class, you will be able to:

  • Create a simple subassembly
  • Add subassemblies to a tool palette
  • Create complex subassemblies
  • Share subassemblies

About the Speaker


The Subassembly Composer is a great new tool from Autodesk that is used to create and modify subassemblies for Civil 3D. With Subassembly Composer you can make or modify very simple to very complex subassemblies without the need to program in a traditional environment like VB.NET or C#. This puts the power of the subassembly (the fact that it is a program) in the hands of the engineer without programming. It also allows subassemblies to be distributed and updated within the organization without any installation overhead.

Interface Overview

The interface to the Subassembly Composer was created using the Microsoft Windows Workflow framework for .NET 4.0. This Workflow framework was designed by Microsoft as a way to streamline programming by allowing non-programmers to define the engineering logic (or workflows) and the Workflow engine to take care of the computer science part. The result is the fusion of the power of a compiled program with an easy to use visual framework.

When you start the Subassembly Composer you will see an interface with5 main windows as shown in Figure 1:

  1. Tool Box – The tools that you can use in the flowchart
  2. Flowchart – The engineering logic of the subassembly
  3. Properties – This is where you adjust the values of the tools as they are added to the Flowchart
  4. Preview – A preview of the Subassembly
  5. Settings – This one changes depending on the tab that is selected.

Figure 1 - User Interface

The basic flow of the composer is to drag a tool from the Tool Box on to the flowchart, adjust the properties and see the results in the Preview.

Subassembly Overview

Subassemblies in Civil 3D are created using points, links and shapes. Points are the basic building block and define locations in the plane of the cross section based on an offset and elevation difference from the attachment point of the subassembly. These points are then used in the corridor to label cross sections and to create feature lines along the corridor. Links are drawn between two or more points (the typical link is defined by two points) are used label the slope in the cross section and to create surfaces in the corridor model. Shapes are defined by a series of links that share common end points. Shapes are used to shade cross sections and for area based volume calculations and can produce corridor solids (using the extension on Autodesk Labs).

Create a simple subassembly - Basic lane

To start we’ll make a very simple roadway that allows the user to control the lane width and depth and that use the superelevation parameters on the alignment to control the lane slope.


We start the subassembly by setting points. The first point is typically set at 0,0 (delta X and delta Y) from the attachment point. This will be the starting point for the subassembly.

Points can be set 11 different ways depending on the situation. For the basic lane we’ll add the second point with the slope and Delta X option. The second point will become the outside of the lane and the slope will be the super elevation. We’ll add two additional points to the lane to set the depth of the lane. We’ll use the Delta X and Delta Y option to drop these points right under the two set points.

Figure 2 - Basic Lane Flowchart and Preview

Input Parameters

While making a subassembly with no input parameters is fine (and takes away the chance for error) it makes it a little restrictive. Input Parameters are used to control the values in the subassembly when they are used in an assembly. For this example we’ll add two input parameters, one to control the width of the road, and the other to control the depth of the lane. We could also use the direction parameter to allow the lane to be used on either side of the road.

Figure 3 - Lane Input Parameters

As soon as we add the parameters for Width and Depth we can use them in the subassembly in place of hard coded values. The one thing to watch out for here is that spelling counts!


Up until this point as we added point to flow chart we also added links (this is the default behavior), but now we need to close the bottom of the figure with an additional link from P4 to P3. The order that the points are selected determines the direction of the link. We’ll be using the slope of this link later so we want it defined from the inside to the outside of the lane.


Now that we have a couple of closed shapes we can add Shapes to the subassembly. After adding the shapes to the flow chart, use the green box to set the links in the Preview window. If you hover over the shape and it doesn’t change color, you might need to check your links to make sure they are closed.

Closing shapes/shape rules

One note on shapes: the links that define the shapes need to be created in such a way that they share common end points. This doesn’t mean that they points are at the same location, they have to be the same points. In some cases you will need to add additional points or links to the subassembly to make this happen.


Now that we’re created the geometry, we can go back and add some point, link and shape code information to the subassembly. This is done on each of the objects and is as simple as typing in the code that you want to use inside of quotes. If you don’t use quotes then the Compose things that the value is a variable and will raise an error. FYI, you can allow the user to choose the codes by providing an input parameter for the codes.

Figure 4 - Point and Link Codes

At this point we have a subassembly that we can use inside of Civil 3D. We need to name it and save the PKT file and we can move on to adding to the palette and testing it inside of Civil 3D.

Add subassemblies to a Tool Palette

After creating and saving the subassembly it is time to test it inside of Civil 3D. I typically have a simple drawing with an alignment, profile and surface in it that I use to test my subassemblies. Once you have a drawing like this (or if you have a project even better) you need to either make a new tool palette or add your subassembly to an existing one. If you right click on the title bar of the palette you will see the command “Import Subassemblies…”. Your new PKT file is the source file and you can either import it on to the current palette or you can make a new one from the dialog.

After you import the PKT file, the system will add your subassembly to the “Imported Tools” folder under “Program Data” as a new folder with the same name as the PKT file.

After adding the subassembly to the palette we can add it to an assembly and then apply the assembly to a corridor to test it. In this case we don’t need to set any targets.

CreatingComplex Subassemblies

While the simple subassemblies are nice and can be used to create some pretty interesting things, the real power of the Subassembly Composer is unlocked when you use the geometry tools, making decisions based on conditions and using the API to get additional information about the corridor model

Don’t Use Trigonometry – Intersections Work Better

I have nothing against trigonometry, and all the trig functions you’ll need are available inside of SAC, but in almost every case you don’t need to use them. For example, we want to set a couple of shoulder points on our SA that use a 6:1 slope to the depth of the lane. We’ll do this by using an intersection point from the two points and the slopes that we want. For the slope of the lane we’ll use an API call “L4.Slope” that means use the slope of Link 4. This will produce a point where they two slopes intersect. To finish the shoulder, we’ll add a couple of links and a shape.

NOTE: the Microsoft .NET math library can be used inside of Subassembly composer. For example Math.Atan(1) will return the arc tangent of 1.


Target parameters are used to introduce other parts of the model into the subassembly. For example the Surface Target will allow the subassembly to query surfaces to calculate things like cut and fill.

Surface Targets

Adding a surface target to our subassembly is just a matter of adding it to the Target Parameters. By adding it here it will appear inside of Civil 3D as a Corridor Target that you’ll need to set to make the subassembly work. After you add it, you’ll see a line appear in the Preview window. This line can be moved up and down in the preview to simulate a cut or fill situation.

Figure 5 - Surface Target Added

Offset / Elevations Targets

Offset and elevation targets can also be added to the subassembly to control width and height parameters. We could quickly add an offset parameter to the model and use that to control the width of the lane.

Figure 6 - Lane Width Controlled by Offset Target

Keeping ItClean

If you’re like me after a few minutes of making a subassembly you’ll have a flow chart that goes everywhere. There are a couple of tools that help keep things clean, the Flowchart and the Sequence. The Flowchart allows you to embed additional flowcharts to be used like a sub routine. I use these for my conditionals and switches to keep the different paths separate.

The sequence is nice because it can store a simple set of steps like the building of our lane shape in the first example. You can cut and paste things from a flow chart to either a new flowchart of to a sequence.

Figure 7 - Lane Inside a Sequence


Conditionals are programming for decision points. The first decision that we need for our subassembly is one for cut or fill.


For this decision we’ll use an API callP5.DistanceToSurface(EG) 0 on the shoulder point to see how far it is to the EG surface. If the point is above the surface we’ll fill at 2:1 and if it is below we’ll add a ditch and then daylight at 2:1, using auxiliary points and links to do it.

Auxiliary Points and Links

Auxiliary Points and Links are just like the regular points and links but they don’t create anything inside of the corridor model which is good because they don’t clog up the drawing with extra stuff. We’ll use an auxiliary point and link for the daylight links in this example so that we can dress up the subassembly in a minute.

Another trick that we’ll use is to name the points and links of the daylight the same things. This will allow us to bring the flowchart back together. Notice in the picture how the final links are both named L10.

Figure 8 - Branching and Merging

Advanced elements

Parabolas and Daylight Rounding

After we bring the two legs of the flowchart back together we can add a daylight rounding to both legs. We’ll add the rounding to the auxiliary links and then add a couple of additional links between the edge of the shoulder and the start of the rounding. An alternative would be to add the daylight point to the model as a regular point so you could see where the daylight would be if the rounding wasn’t applied.

Wrap Up

This finishes our lane, shoulder and daylight subassembly. The only thing left to do is to save it and try it inside of Civil 3D to see how it works in action.

API Calls and Really Advanced Subassemblies

Built into Subassembly Composer is an API that allows some pretty advanced calculations to happen as you build the corridor. We’ll use some of these calls to make a simple Mill and Overlay Subassembly next.

Rehab – Mill and Overlay

The mill and overlay that we are going to make does a couple of things

  1. Look at the existing ground surface between a couple of sample points
  2. The existing cross slope of the current road surface will be calculated using linear regression
  3. The lane will be ground along that slope no deeper than some value
  4. The Design slope of the road will be queried from the alignment
  5. An overlay will be added to the road using this new value

The API and the things that we’ve already learned will be used to create this.

Figure 9 - Mill and Overlay Flowchart

First we’ll add a target surface that we can sample. Next we’ll add a new element the “Auxiliary Surface Link” to sample the existing ground surface from an offset of 0 to 12. In the preview it will look pretty uninteresting.


Variables just place holders for values. Up to this point we haven’t needed any of them, but we’ll add one now to hold the existing lane slope. The expression that we’ll use is AL1.LinearRegressionSlope that uses linear regression on all the points in the surface to calculate the best slope to represent the surface. In the figure you’ll see a green line that represents the surface. The API will look at the points (white X) and will calculate the slope that fits best. This is the red line.

Figure 10 - Sample Linear Regression

To add the grind line, we need to find the highest point on the surface and then grind down from there at the slope we just found. There is another API call that will give us this elevation point: AL1.MaxInterceptY(ExistingSlope). Again in the preview window nothing much happens. After setting the elevation of that point, we can add another point at the outside edge using the ground slope and the offset. In the picture, it would appear that the second point from the left would be that point, but it is really the fourth point that produces the critical elevation when projected back to the right.

Super Elevation

There are a couple ways of using super elevation in your subassemblies. One way is to override slope values with the superelevation like we did in the simple lane; the other is to make an API call to find the superelevation. Set another variable to hold the lane slope and access it using the call SE.RightLO to return the superelevation of the right outside lane.

We’ll look at the lane slope and the existing slope and if the lane slope is greater than existing slope we’ll slope from the inside, otherwise we’ll slope from the outside using a decision to make the check. This will prevent the links from crossing.

After adding the top link, we’ll bring the legs back together and add the vertical links and the overlay shape.

Figure 11 - Completed Mill and Overlay in Subassembly Composer

Sharing subassemblies

Sharing subassemblies with other is as simple as sending them the packet file that you created and having them add the subassembly to their palette.

  1. Make sure they have the “Support Pack” installed.
  2. Make send them the Packet File you created
  3. Have them add the Subassembly to their palettes using the import option

Make sure they have right version of the “Support Pack” for Subassembly Composer installed on their machine. The Support Pack provides the engine that is needed to use subassemblies created with Subassembly Composer and will work with either 2011 or 2012 (the Support Pack originally shipped with the 2012 version, but it was updated with the release of Subassembly Composer).

The Packet Files is just a zip file with a different extension. If you open it you will find 7 or 8 files in it:

  1. ATC – The tool configuration file. This is the file that is used to create the tool palette and display the properties of the subassembly.
  2. CFG – configuration file that tells what version of the editor was used to create the PKT file
  3. DLL – A small program that is used by the corridor to call the Subassembly
  4. EMD – Enumerations used by the Subassembly
  5. PNG – Optional Image file for use on the palette
  6. PVD – Preview Data for superelevation
  7. XAML – The “Zammel” file that contains the logic of the subassembly
  8. XML – a packing list for the packet file


This was a quick look at the Subassembly Composer hitting on the basic user interface of as well as some of the more advanced functionally that is available. There still lots of parts of the Composer we didn’t touch on. I recommend that you look at the help file that is on line in the form of a WIKI that we are able to enhance with additional information and examples.