# Point Group Management

<figure><img src="https://1734247194-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY5ZuHF3yuXFWp1C46ZSo%2Fuploads%2Fgit-blob-860970db9cbdf8a33d24ec6d1e14a5883672005b%2FSurvey_CreatePointGroups_Player.gif?alt=media" alt=""><figcaption></figcaption></figure>

Working with COGO Points and Point Groups in Civil 3D is a core element of many field-to-finish processes. Dynamo really shines when it comes to data management, and we'll demonstrate one potential use case in this example.

## Goal

> :dart: Create a Point Group for each unique COGO Point description.

## Key Concepts

> * Working with Lists
> * Grouping similar objects with the **List.GroupByKey** node
> * Showing custom output in Dynamo Player

## Version Compatibility

{% hint style="success" %}
This graph will run on **Civil 3D 2020** and above.
{% endhint %}

## Dataset

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

{% file src="<https://1734247194-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY5ZuHF3yuXFWp1C46ZSo%2Fuploads%2Fgit-blob-81ae8ce30aa7a7a105595d3077f62b8f90160d08%2FSurvey_CreatePointGroups.dyn?alt=media>" %}

{% file src="<https://1734247194-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY5ZuHF3yuXFWp1C46ZSo%2Fuploads%2Fgit-blob-56020caa20760d9eef2dd6a67c62f283400c283b%2FSurvey_CreatePointGroups.dwg?alt=media>" %}

## Solution

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

> 1. Get all of the COGO Points in the Document
> 2. Group the COGO Points by description
> 3. Create Point Groups
> 4. Output a summary to Dynamo Player

Let's go!

### Get COGO Points

Our first step to get all of the Point Groups in the Document, then get all of the COGO Points within each group. This will give us a *nested list* or "list of lists," which will be easier to work with later if we flatten everything down to a single list with the **List.Flatten** node.

{% hint style="info" %}
If you're new to working with Lists, take a look at the [2-working-with-lists](https://primer2.dynamobim.org/5_essential_nodes_and_concepts/5-4_designing-with-lists/2-working-with-lists "mention") section.
{% endhint %}

<figure><img src="https://1734247194-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY5ZuHF3yuXFWp1C46ZSo%2Fuploads%2Fgit-blob-b6d5829e6972d7bcf560913c4c888b076f0b8c63%2FSurvey_CreatePointGroups_GetPoints.png?alt=media" alt=""><figcaption><p>Get all Point Groups and COGO Points</p></figcaption></figure>

### Group Points by Description

Now that we have all the COGO Points, we need to separate them into groups based on their descriptions. This is exactly what the **List.GroupByKey** node does. It essentially groups together any items that share the same key.

<figure><img src="https://1734247194-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY5ZuHF3yuXFWp1C46ZSo%2Fuploads%2Fgit-blob-1dc33f106d1fe23c1ddcfaf5d44981bb93c5e073%2FSurvey_CreatePointGroups_GroupPoints.png?alt=media" alt="" width="563"><figcaption><p>Grouping the COGO Points by description</p></figcaption></figure>

### Create Point Groups

The hard work is done! The final step is to create new Civil 3D Point Groups from the grouped COGO Points.

<figure><img src="https://1734247194-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY5ZuHF3yuXFWp1C46ZSo%2Fuploads%2Fgit-blob-c00a6e7ad8cf938ca43602d6f0305bc93ebfd5ac%2FSurvey_CreatePointGroups_CreatePointGroups.png?alt=media" alt="" width="371"><figcaption><p>Create new Point Groups</p></figcaption></figure>

### Output Summary

When you run the graph, there's nothing to see in the Dynamo background preview because we aren't working with any geometry. So the only way to see if the graph executed properly is to check the Toolspace, or to look at the node output previews. However, if we run the graph using **Dynamo Player**, then we can provide more feedback about the graph's results by outputting a summary of the Point Groups that were created. All you have to do is right-click on a node and set it to *Is Output*. In this case, we use a renamed **Watch** node to view the results.

<figure><img src="https://1734247194-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY5ZuHF3yuXFWp1C46ZSo%2Fuploads%2Fgit-blob-70ccd96998b9092870379ff76ce2f158216df4c5%2FSurvey_CreatePointGroups_Output.png?alt=media" alt="" width="437"><figcaption><p>Setting a node to <em>Is Output</em> will display its contents in the Dynamo Player output</p></figcaption></figure>

### Result

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

<figure><img src="https://1734247194-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY5ZuHF3yuXFWp1C46ZSo%2Fuploads%2Fgit-blob-860970db9cbdf8a33d24ec6d1e14a5883672005b%2FSurvey_CreatePointGroups_Player.gif?alt=media" alt=""><figcaption><p>Running the graph using Dynamo Player and seeing the results in the Toolspace</p></figcaption></figure>

{% hint style="info" %}
If Dynamo Player is new to you, take a look at the [dynamo-player](https://primer2.dynamobim.org/dynamo-for-civil-3d/dynamo-player "mention") section.
{% endhint %}

> :tada: Mission accomplished!

## Ideas

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

{% hint style="info" %}
Modify the point grouping to be based on **full description** instead of raw description.
{% endhint %}

{% hint style="info" %}
Group the points by some other **pre-defined categories** that you choose (e.g., "Ground shots," "Monuments," etc.)
{% endhint %}

{% hint style="info" %}
Automatically create TIN Surfaces for points in certain groups.
{% endhint %}
