Creating Wipeouts from Surface Boundaries in Dynamo for Civil 3D

Hello Amigos,

I’m working on a script to create wipeouts based on multiple Civil 3D surfaces. In the first part (as shown in the attached image), I successfully managed to extract the boundaries of the surfaces as closed 2D polylines.

Now, I’d like to extend the script so that it creates wipeouts directly from these polylines. After reading several topics on this forum, I noticed that using [Passthrough, WaitFor][0] could be the solution. I attempted this approach, but I’m not sure if I implemented it correctly.

To simplify debugging, I decided to split the workflow into two scripts for now:

  1. The first script extracts the surface boundaries as 2D polylines.
  2. The second script uses these polylines to create wipeouts.

However, in the second script, I can only get it to work for one polyline at a time. I tried adjusting the Lacing settings, but it didn’t resolve the issue.

Could someone guide me on what I might be doing wrong? Any advice or examples would be greatly appreciated!

Thank you in advance!

Can someone help me? I changed the method from sending the command to using the API. The inputs are a couple of tables with X and Y coordinates. This is the code I’m trying to fix:

# Load the Python Standard and DesignScript Libraries
import sys
import clr

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')

# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

# The inputs to this node will be stored as lists in the IN variables.
x_coords = IN[0]  # List of X coordinates
y_coords = IN[1]  # List of Y coordinates

# Get the active document and editor
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
db = adoc.Database

# Check input validity
if len(x_coords) < 3 or len(y_coords) < 3 or len(x_coords) != len(y_coords):
    raise ValueError("Se requieren al menos 3 puntos y listas X, Y de la misma longitud.")

# Lock document before modifying AutoCAD
with adoc.LockDocument():
    try:
        # Start transaction
        with db.TransactionManager.StartTransaction() as tr:
            # Get Model Space
            block_table = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
            model_space = tr.GetObject(block_table[BlockTableRecord.ModelSpace], OpenMode.ForWrite)

            # Create a collection of 2D points
            point_collection = Point2dCollection()
            for x, y in zip(x_coords, y_coords):
                point_collection.Add(Point2d(x, y))

            # Close the shape by adding the first point at the end
            point_collection.Add(Point2d(x_coords[0], y_coords[0]))

            # Create the Wipeout object
            wipeout = Wipeout()
            wipeout.SetFrom(point_collection, Vector3d.ZAxis)

            # Add the Wipeout to the Model Space
            model_space.AppendEntity(wipeout)
            tr.AddNewlyCreatedDBObject(wipeout, True)

            # Commit transaction
            tr.Commit()

            # Output handle
            OUT = wipeout.Handle

    except Exception as e:
        OUT = str(e)

source: Help

Thanks guys.

Can you attached example drawing

yes, there you go.

I was trying to use the 2d Polylines, to get the X and Y coordinates and then using the API for wipeout().
Drawing test 1.dwg (1.2 MB)

TRY

import sys
import clr

clr.AddReference('AcMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('ProtoGeometry')

from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

from System.Collections.Generic import Dictionary

adoc = Application.DocumentManager.MdiActiveDocument
cdoc = CivilApplication.ActiveDocument

from Autodesk.DesignScript.Geometry import *


def get_sample_line_info(sampleLines):
	
	global adoc
	global cdoc
	
	output = []
	

	if not sampleLines:
		return
	
	if not isinstance(sampleLines, list):
		sampleLines = [sampleLines]

	with adoc.LockDocument():
	    with adoc.Database as db:
	        with db.TransactionManager.StartTransaction() as t:
				#for sampleLine in sampleLines:
				block_table = t.GetObject(db.BlockTableId, OpenMode.ForRead)
				model_space = t.GetObject(block_table[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
				point_collection = Point2dCollection()
				vals = []
				for sam in sampleLines:
					
					point_collection.Add( Point2d(sam.X, sam.Y) )
					vals.append(sam.X)
				point_collection.Add(Point2d(sampleLines[0].X, sampleLines[0].Y))
				
				wipeout = Wipeout()
				wipeout.SetFrom(point_collection, Vector3d.ZAxis)
				
				model_space.AppendEntity(wipeout)
				t.AddNewlyCreatedDBObject(wipeout, True)
				t.Commit()
	return point_collection 		

OUT = get_sample_line_info(IN[0])

WW1

2 Likes

Hi thanks for that,

But looks like works only when selected the polyline, but it doesn’t work when you have more than one.
I got this error message

this is the script for multiple wipeouts

@hbajana

The warning is telling you what the issue is. Sometimes you are using tab for indents, other times you are using spaces. Mixing is not allowed.

1 Like

I did that, and what Jacob said but still not working.

@hbajana
Can you attached your dyn file

there you go
Thanks
Wipeouts from surfaces V1.1.dyn (40.7 KB)

WW1

Wipeouts from surfaces V1.1.dyn (43.1 KB)

Thanks,

It works, I just change the code a little bit in order to get it done for all the surfaces at the same time.

Thank you so much.

1 Like