Creating Surfaces in a Different .DWG File Using Civil 3D/Dynamo 2026

Hi everyone,

I need help creating a surface in a different .dwg file using Civil 3D/Dynamo 2026. I’m working with a .dxf file containing 3D faces and can create the surface from them in the current .dxf file, but I want it saved in a separate .dwg one.

What’s the easiest way to achieve this?

Thanks!

Hi @ivega86WRT,

Camber package has a node to Add3DFaces under TinSurface menu.
Under import/export menu (default dynamo nodes) you can find the File System nodes to work around with the files.

Hi @JaLo,

Thank you for your response. I am creating the TIN surfaces (in the current file) from 3D faces using the Python code below. Would it be too much to ask for your help in modifying the code so that I can generate the TIN surfaces in a different, pre-existing .dwg file?

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

clr.AddReference('AcDbMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AutoCADNodes')
clr.AddReference('Civil3DNodes')   

from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
import Autodesk.AutoCAD.DynamoNodes as DA
import Autodesk.Civil.DynamoNodes as DC

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

def create_tin_by_faces(surfaceName, faces):

    if surfaceName is None or faces is None:
        return
    
    if not isinstance(faces, list):
        faces = [faces]
    
    global adoc
    global cdoc

    with adoc.LockDocument():
        with adoc.Database as db:    
            with db.TransactionManager.StartTransaction() as t:
                surfId = TinSurface.Create(db, surfaceName)
                surf = t.GetObject(surfId, OpenMode.ForWrite)
                surfDwgObjs = surf.DrawingObjectsDefinition
                faceIds = ObjectIdCollection()
                for face in faces:
                    faceId = face.InternalObjectId
                    faceIds.Add(faceId)
                surfDwgObjs.AddFrom3DFaces(faceIds, True, "")
                t.Commit()
                pass
    return DC.Selection.SurfaceByName(surfaceName, DA.Document.Current)

OUT = create_tin_by_faces(IN[0], IN[1]),"Pass"

@JaLo I successfully selected a created surface by its name and saved it into a new .dwg file using the code below. However, I am wondering how I can save the surface into an existing .dwg document instead… any thoughts?

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

Add Assemblies for AutoCAD and Civil3D

clr.AddReference(‘AcMgd’)
clr.AddReference(‘AcCoreMgd’)
clr.AddReference(‘AcDbMgd’)
clr.AddReference(‘AecBaseMgd’)
clr.AddReference(‘AecPropDataMgd’)
clr.AddReference(‘AeccDbMgd’)

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 *

Import references from Civil3D

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

The inputs to this node will be stored as a list in the IN variables.

surfaceName = IN[0]
dirname = os.path.dirname(IN[1])

adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

with adoc.LockDocument():
with adoc.Database as db:

    with db.TransactionManager.StartTransaction() **as** t:
        bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
        btrID = bt.get_Item("\*Model_Space")
        btr = t.GetObject(btrID, OpenMode.ForWrite)
        
        
        for oid in btr:
            obj = t.GetObject(oid, OpenMode.ForWrite)
            
            if isinstance(obj, TinSurface) **and** obj.Name == surfaceName:
                tinSurface = obj
                
        
        basept = Point3d.Origin
        cloning = DuplicateRecordCloning.Ignore
        
        with Database(True, False) **as** ndb:
            coll = ObjectIdCollection()
            coll.Add(tinSurface.ObjectId)

            db.Wblock(ndb, coll, basept, cloning)
            
            np = os.path.join(dirname, 'Surface.dwg')
            ndb.SaveAs(np, DwgVersion.Current)
            
            
        
        t.Commit()
        pass

Assign your output to the OUT variable.

OUT = tinSurface

Look into inserting the new DWG as a block / xref into the existing one.

I would love to help, but I have 0 knowledge about python :frowning: