Problem to create CogoPointGroups

Hello everyone,

I would like to use Dynamo to simplify Cut&Fill calculations in Civil3D 2024.

To do this, I create CogoPoints, which I can only convert into a surface by grouping them into point groups.

In the screenshot, I show how I assign the points I created to a new point group. I don’t get any errors when doing this.

When I then go to the AutoCAD file and check if the points are in my pointgroup, the pointgroup named “abc” has been created. However, this pointgroup has no points, even when I update it.

Can anyone help me with this?

Hi
I sort of recreated your script (with similar but different nodes) and everything worked.
What is the geometry input in your CreateCogoPoints node?

Thanks for your answer.

I used points aswell. Like you I created Points out of coordinates with Point.ByCoordinates.

After that I edited the list a bit with list.clean, list.flatten, list.UniqueItems.

The list look like this: [Point(X = …,Y = …, Z = …, Point(…)).

Finally this edited list is my Input in CogoPoint.ByGeometry.

Can you share your script file (with input file if there is one)? I could take a look because everything you said makes sense and should work

the main thing that makes me wonder is why the output of your CogoPoints show Objects with its Handle while mine shows CogoPoints

Also check this out - https://primer2.dynamobim.org/dynamo-for-civil-3d/sample-workflows/surveying/point-group-management

Yes its really strange that there is a list of objects and not with cagopoints, when you Watch the node.

I posted my hole skript below. There is a lot of stuff in there. The spot I screenshoted is on the far right side.

Kopie autom. DGM außer Polygonnetze.dyn (2.1 MB)

Hello, I have used the same nodes and the final node for creating the group with the provided points works correctly.
It would be helpful if you could specify what you are selecting (blocks, texts, or others) to obtain the coordinates that are later used to generate the points and finally add them to the desired group.
It would also be useful if you could indicate the version of Civil 3D you are using and the packages used in that version.
Best regards,

Hey, thanks for your answer.

I am using Civil3D 2024 and packages like ArkanceSystems and Civil3DToolkit.

In general your script is doing the same as my script. Therefore I copied your skript and be able to create a cogopointgroup. But this pointgroup still does not have points inside. Also when I refresh the group.

Once the CogoGroup is created try to set a new name for the group before running your dynamo file. I recall something like this, it worked on the first group creation but had some conflict once the CogoGroup exists

Now, with Civil 3D 2027 and PythonNet3, it’s easy to use a Python script like this one
Just make sure
IN[0] = Group name
IN[1] = CogoPoint or nested lists of CogoPoints

import clr

clr.AddReference(“AutoCADNodes”)
clr.AddReference(“Civil3DNodes”)

from Autodesk.AutoCAD.DynamoNodes import Document
from Autodesk.Civil.DynamoNodes import CogoPoint
from Autodesk.Civil.DynamoNodes import CogoPointGroup
from System.Collections.Generic import List

IN[0] = Group name

IN[1] = CogoPoint or nested lists of CogoPoints

groupName = str(IN[0]).strip()
inputPoints = IN[1]

if not groupName:
raise Exception(“IN[0]: Group name cannot be empty.”)

if inputPoints is None:
raise Exception(“IN[1]: COGO points input is null.”)

Flatten nested Python lists

def flatten(data):
if isinstance(data, (list, tuple)):
for item in data:
for nestedItem in flatten(item):
yield nestedItem
else:
yield data

Create typed .NET list

cogoPoints = List[CogoPoint]()

for point in flatten(inputPoints):
if point is not None:
if not isinstance(point, CogoPoint):
raise Exception(
“Invalid object in IN[1]: {0}”.format(
point.GetType().FullName
if hasattr(point, “GetType”)
else type(point)._name_
)
)

    cogoPoints.Add(point)

if cogoPoints.Count == 0:
raise Exception(“IN[1]: No valid COGO points were supplied.”)

Create COGO Point Group

OUT = CogoPointGroup.ByCogoPoints(
cogoPoints,
groupName,
Document.Current,
“”
)

This will add a new cogopoint group and assign point numbers to it.

If you want to add a RawDescription within the point group without using point numbers
this will apply adding a RawDescription to all these points and apply this to the group
You can use this Python script
Just make sure

IN[0] = Point Group name
IN[1] = CogoPoint or nested lists of CogoPoints
IN[2] = Raw Description

import clr

clr.AddReference(“AcMgd”)
clr.AddReference(“AcDbMgd”)
clr.AddReference(“AeccDbMgd”)
clr.AddReference(“AutoCADNodes”)
clr.AddReference(“Civil3DNodes”)

from Autodesk.AutoCAD.ApplicationServices import Application
from Autodesk.AutoCAD.DatabaseServices import OpenMode

from Autodesk.AutoCAD.DynamoNodes import Document

from Autodesk.Civil.DynamoNodes import CogoPoint as DynamoCogoPoint
from Autodesk.Civil.DynamoNodes import CogoPointGroup

from Autodesk.Civil.DatabaseServices import StandardPointGroupQuery

from System.Collections.Generic import List

---------------------------------------------------------

Inputs

IN[0] = Point Group name

IN[1] = CogoPoint or nested lists of CogoPoints

IN[2] = Raw Description

---------------------------------------------------------

groupName = str(IN[0]).strip()
inputPoints = IN[1]
rawDescription = str(IN[2]).strip()

---------------------------------------------------------

Validation

---------------------------------------------------------

if not groupName:
raise Exception(“IN[0]: Group name cannot be empty.”)

if inputPoints is None:
raise Exception(“IN[1]: COGO points input is null.”)

if not rawDescription:
raise Exception(“IN[2]: Raw Description cannot be empty.”)

---------------------------------------------------------

Flatten nested lists

---------------------------------------------------------

def flatten(data):
if isinstance(data, (list, tuple)):
for item in data:
for nestedItem in flatten(item):
yield nestedItem
else:
yield data

---------------------------------------------------------

Convert to typed .NET list

---------------------------------------------------------

cogoPoints = ListDynamoCogoPoint

for point in flatten(inputPoints):
if point is None:
continue

if not isinstance(point, DynamoCogoPoint):
    objectType = (
        point.GetType().FullName
        if hasattr(point, "GetType")
        else type(point).__name__
    )

    raise Exception(
        "IN[1] contains an invalid object: {0}".format(objectType)
    )

cogoPoints.Add(point)

if cogoPoints.Count == 0:
raise Exception(“IN[1]: No valid COGO points were supplied.”)

---------------------------------------------------------

First create/update the Dynamo CogoPointGroup wrapper

---------------------------------------------------------

pointGroup = CogoPointGroup.ByCogoPoints(
cogoPoints,
groupName,
Document.Current,
rawDescription
)

if pointGroup is None:
raise Exception(“Civil 3D failed to create the COGO Point Group.”)

---------------------------------------------------------

Assign Raw Description and replace number-based query

---------------------------------------------------------

acadDocument = Application.DocumentManager.MdiActiveDocument
database = acadDocument.Database

with acadDocument.LockDocument():

with database.TransactionManager.StartTransaction() as transaction:

    # Assign Raw Description to selected COGO points
    for dynamoPoint in cogoPoints:

        nativePoint = transaction.GetObject(
            dynamoPoint.InternalObjectId,
            OpenMode.ForWrite
        )

        nativePoint.RawDescription = rawDescription

    # Open native Civil 3D Point Group
    nativePointGroup = transaction.GetObject(
        pointGroup.InternalObjectId,
        OpenMode.ForWrite
    )

    # Create a Raw Description query
    query = StandardPointGroupQuery()

    query.IncludeRawDescriptions = rawDescription
    query.UseCaseSensitiveMatch = False

    # Replace the previous number-based query
    nativePointGroup.SetQuery(query)
    nativePointGroup.Update()

    transaction.Commit()

---------------------------------------------------------

Output

---------------------------------------------------------

OUT = pointGroup