Dynamo
Primer for v2.0
English
English
  • About
  • Introduction
    • What is Dynamo & How Does It Work?
    • Primer User Guide, Dynamo Community & Platform
  • Setup for Dynamo
  • User Interface
    • Workspace
    • Library
  • Nodes and Wires
  • Essential Nodes & Concepts
    • Index of Nodes
    • Geometry for Computational Design
      • Geometry Overview
      • Vector, Plane & Coordinate System
      • Points
      • Curves
      • Surfaces
      • Solids
      • Meshes
    • The Building Blocks of Programs
      • Data
      • Math
      • Logic
      • Strings
      • Color
    • Designing with Lists
      • What's a List
      • Working with Lists
      • Lists of Lists
      • n-Dimensional Lists
    • Dictionaries in Dynamo
      • What is a Dictionary
      • Dictionary Nodes
      • Dictionaries in Code Blocks
      • Revit Use-Cases
  • Custom Nodes & Packages
    • Custom Nodes
      • Custom Node Introduction
      • Creating a Custom Node
      • Publishing to Your Library
    • Packages
      • Package Introduction
      • Package Case Study - Mesh Toolkit
      • Developing a Package
      • Publishing a Package
      • Zero-Touch Importing
  • Dynamo for Revit
    • The Revit Connection
    • Selecting
    • Editing
    • Creating
    • Customizing
    • Documenting
  • Dynamo for Civil 3D
    • The Civil 3D Connection
    • Getting Started
    • Node Library
    • Sample Workflows
      • Roads
        • Light Pole Placement
      • Land
        • Service Placement
      • Utilities
        • Rename Structures
      • Rail
        • Clearance Envelope
      • Surveying
        • Point Group Management
    • Advanced Topics
      • Object Binding
      • Python and Civil 3D
    • Dynamo Player
    • Useful Packages
    • Resources
  • Dynamo in Forma Beta
    • Set Up Dynamo Player in Forma
    • Add and Share Graphs in Dynamo Player
    • Run Graphs in Dynamo Player
    • Dynamo compute service differences with Desktop Dynamo
  • Coding in Dynamo
    • Code Blocks and DesignScript
      • What's a Code Block
      • DesignScript Syntax
      • Shorthand
      • Functions
    • Geometry with DesignScript
      • DesignScript Geometry Basics
      • Geometric Primitives
      • Vector Math
      • Curves: Interpolated and Control Points
      • Translation, Rotation, and Other Transformations
      • Surfaces: Interpolated, Control Points, Loft, Revolve
      • Geometric Parameterization
      • Intersection and Trim
      • Geometric Booleans
      • Python Point Generators
    • Python
      • Python Nodes
      • Python and Revit
      • Setup Your Own Python Template
    • Language Changes
  • Best Practices
    • Graph Strategies
    • Scripting Strategies
    • Scripting Reference
    • Managing Your Program
    • Efficiently Working With Large Data Sets In Dynamo
  • Sample Workflows
    • Getting Started Workflows
      • Parametric Vase
      • Attractor Points
    • Concept Index
  • Developer Primer
    • Build Dynamo from Source
      • Build DynamoRevit from Source
      • Managing and Updating Dependencies in Dynamo
    • Developing for Dynamo
      • Getting Started
      • Zero-Touch Case Study - Grid Node
      • Executing Python Scripts in Zero-Touch Nodes (C#)
      • Going Further with Zero-Touch
      • Advanced Dynamo Node Customization
      • Using COM (interop) types in Dynamo Packages
      • NodeModel Case Study - Custom UI
      • Updating your Packages and Dynamo Libraries for Dynamo 2.x
      • Updating your Packages and Dynamo Libraries for Dynamo 3.x
      • Extensions
      • Defining Custom Package Organization for Dynamo 2.0+
      • Dynamo Command Line Interface
      • Dynamo Integration
      • Developing For Dynamo For Revit
      • Publish a Package
      • Build a Package from Visual Studio
      • Extensions as Packages
    • Pull Requests
    • Testing Expectations
    • Examples
  • Appendix
    • Frequently Asked Questions
    • Visual Programming and Dynamo
    • Resources
    • Release Notes
    • Useful Packages
    • Example Files
    • Host Integration Map
    • Download PDF
    • Dynamo Keyboard Shortcuts
Powered by GitBook
On this page
  • Goal
  • Key Concepts
  • Version Compatibility
  • Dataset
  • Solution
  • Get Excel Data
  • Get Corridor Feature Lines
  • Generate Coordinate Systems
  • Create Block References
  • Result
  • Bonus: Visualizing in Dynamo
  • Ideas
Edit on GitHub
Export as PDF
  1. Dynamo for Civil 3D
  2. Sample Workflows
  3. Roads

Light Pole Placement

PreviousRoadsNextLand

Last updated 1 year ago

One of Dynamo's many great use cases is dynamically placing discrete objects along a Corridor model. It is often the case that objects need to be placed at locations that are independent of the inserted Assemblies along the Corridor, which is a very tedious task to accomplish manually. And when the horizontal or vertical geometry of the Corridor changes, then a significant amount of re-work is introduced.

Goal

Key Concepts

  • Reading data from an external file (Excel in this case)

  • Organizing data in Dictionaries

  • Using Coordinate Systems to control position/scale/rotation

  • Placing Block References

  • Visualizing geometry in Dynamo

Version Compatibility

This graph will run on Civil 3D 2020 and above.

Dataset

Start by downloading the sample files below and then opening the DWG file and Dynamo graph.

It is best if the Excel file is saved in the same directory as the Dynamo graph.

Solution

Here's an overview of the logic in this graph.

  1. Read the Excel file and import the data into Dynamo

  2. Get Feature Lines from the specified Corridor Baseline

  3. Generate Coordinate Systems along the Corridor Feature Line at the desired stations

  4. Use the Coordinate Systems to place Block References in Model Space

Let's go!

Get Excel Data

In this example graph, we're going to use an Excel file to store the data that Dynamo will use to place the light pole Block References. The table looks like this.

Using Dynamo to read data from an external file (such as an Excel file) is a great strategy, especially when the data needs to be shared with other team members.

The Excel data is imported into Dynamo like this.

Now that we have the data, we need to split it up by column (Corridor, Baseline, PointCode, etc.) so that it can be used in the rest of the graph. A common way to do this is to use the List.GetItemAtIndex node and specify the index number of each column that we want. For example, the Corridor column is at index 0, the Baseline column is at index 1, etc.

Seems fine, right? But there's a potential issue with this approach. What if the order of the columns in the Excel file changes in the future? Or a new column is added between two columns? Then the graph will not function properly and require an update. We can future-proof the graph by putting the data into a Dictionary, with the Excel column headers as the keys and the rest of the data as the values.

If Dictionaries are new to you, take a look at the Dictionaries in Dynamo section.

This makes the graph more resilient because it allows for flexibility in changing the order of the columns in Excel. As long as the column headers stay the same, then the data can simply be retrieved from the Dictionary using its key (i.e., the column header), which is what we do next.

Get Corridor Feature Lines

Now that we have the Excel data imported and ready to go, let's start using it to get some information from Civil 3D about the Corridor models.

  1. Select the Corridor model by its name.

  2. Get a specific Baseline within the Corridor.

  3. Get a Feature Line within the Baseline by its point code.

Generate Coordinate Systems

What we're going to do now is generate Coordinate Systems along the Corridor Feature Lines at the station values that we specified in the Excel file. These Coordinate Systems will be used to define the position, rotation, and scale of the light pole Block References.

If Coordinate Systems are new to you, take a look at the Vector, Plane & Coordinate System section.

Note the use of a Code Block here to rotate the Coordinate Systems depending on which side of the baseline they are on. This could be achieved using a sequence of several nodes, but this is a good example of a situation where it's easier to just write it out.

If Code Blocks are new to you, take a look at the Code Blocks and DesignScript section.

Create Block References

We're getting close! We have all the information we need to be able to actually place the Block References. The first thing to do is get the Block definitions that we want using the BlockName column in the Excel file.

From here, the last step is to create the Block References.

Result

When you run the graph, you should see new Block References show up in Model Space along the Corridor. And here's the cool part - if the graph's execution mode is set to Automatic and you edit the Excel file, the Block References update automatically!

You can read more about graph execution modes in the User Interface section.

Here's an example of running the graph using Dynamo Player.

If Dynamo Player is new to you, take a look at the Dynamo Player section.

Bonus: Visualizing in Dynamo

It can be helpful to visualize the Corridor geometry in Dynamo to provide context. This particular model has the Corridor solids already extracted in Model Space, so let's bring those into Dynamo.

But there's something else we need to consider. Solids are a relatively "heavy" geometry type, which means that this operation will slow down the graph. It would be nice if there was a simple way to choose if we wanted to view the solids or not. The obvious answer is to just unplug the Corridor.GetSolids node, but that will produce warnings for all of the downstream nodes, which is a little messy. This is a situation where the ScopeIf node really shines.

  1. Notice that the Object.Geometry node has a gray bar at the bottom. This means that the node preview is turned off (accessible by right-clicking on the node), which allows the GeometryColor.ByGeometryColor to avoid "fighting" with other geometry for display priority in the background preview.

  2. The ScopeIf node basically allows you to selectively run an entire branch of nodes. If the test input in false, then every node connected to the ScopeIf node will not run.

Here's the result in the Dynamo background preview.

Ideas

Here are some ideas for how you could expand the capabilities of this graph.

Add a rotation column to the Excel file and use it to drive the rotation of the coordinate systems.

Add horizontal or vertical offsets to the Excel file so that the light poles could deviate from the Corridor Feature Line if needed.

Instead of using an Excel file with station values, generate the station values directly in Dynamo using a start station and typical spacing.

Place light pole Block References along a Corridor at station values specified in an Excel file.

Mission accomplished!

🎯
🎉
234KB
Roads_CorridorBlockRefs.dyn
54MB
Roads_CorridorBlockRefs.dwg
12KB
LightPoles.xlsx
The Excel file table structure
Importing the Excel data into Dynamo
Putting the Excel data into a Dictionary
Retrieving data from the Dictionary
Getting Coordinate Systems along the Corridor Feature Lines
Getting the Block definitions that we want from the Document
Creating the Block References in Model Space
Making updates to the Excel file and quickly seeing the results in Civil 3D
Running the graph using Dynamo Player and seeing the results in Civil 3D
Visualizing the Corridor geometry in Dynamo