TinSurface from 3D Faces

I regularly receive 3D faces representing existing ground. I’m trying to come up with a way to take those faces and create a Civil 3D TinSurface. Using existing tools, my hope/plan was to extract the geometry of the faces, get the vertices and edges from that geometry within Dyanmo, create COGO from the vertices, create breaklines from the edges, and then creates a surface from those COGO points and breaklines.

I feel like I need to start with the Object.Geometry node, but then I can’t think of a way forward. The node returns values of Face and I’m not sure if it can do anything with a 3D face object. It seems that if I can just get the 3D Face geometry into Dynamo (as a mesh?), then I can start creating points and lines easily enough from there.

Any thoughts or suggestions? Thanks in advance.

Hi
This sounds interesting, but why do you want to create TIN surface from COGO’s and breaklines and not from 3D faces right off?
Because when the surface is created from 3D faces, you can delete those and the dwg-file will be lighter. With Cogo points and breaklines, they need to remain in the dwg all the time.

I sadly not have a solution to your issue but I think that there is a possibility to do the “add 3D faces to surface” by API so it might be interesting way to deal with it.

Regards,
Patrick

2 Likes

Hi @JPhil,

To get the edges and vertices from the Faces, you would do something like this:

However, it will be a very heavy set of operations to deconstruct the faces into vertices and edges and then build the TIN Surface from COGO Points and breaklines. It will be much faster to build the surface from the faces directly using the API. Here’s some code for you to try out in a Python node.

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])
6 Likes

@mzjensen you are a true god :slight_smile:
I will use your code to learn more about how to use the API, thanks for your vaulable input (as always)
/Patrick

No problem!

Works like a charm! Simple enough, I can try to pull apart the Python to figure out this magic you weild. Thanks, again!

2 Likes

Update: there is a node for this in the Camber package starting in v4.0.0.

3 Likes

Good morning everyone, i have tried your nodes and works really well.
I need to work on huge files where surfaces were created in Autocad with 3D faces. I want to convert these in TIN sufaces in Civil 3D. When the TIN surface is created, Civil creates additional triangles, i do not want them, and there is absolutely no time to create characteristic lines, or manually deleting the additional triangles.

There is a way where the 3D faces are transformed in TIN surfaces?

Tin surface created succesfully, but i do not need the triangles in the red area.

3D faces from autocad

EDIT: with an autocad command we converted the 3D faces in a single Autocad surface, we can work also with that to obtain a single TIN surface able to maintain the existing boundaries.

Hi
Try this

1 Like

Thank you, it is close to my problem but with our elements the tunwanted triangles can be very small or incredibly big, so their maximum size can not be used as discrimination without erasing needed triangles.

Can you please open a new thread? Your question is not really about creating the surfaces from 3D faces, it is about deleting triangles and/or adding boundaries, which is a different problem.

i’ll create it, but my problem is converting 3d faces into tin surfaces.

Hi Damiano, can you elaborate on this? I have the same issue, and it’s taking us several hours to solve.

Hi mzjensen. How could we create a tin per 3dface? That would be so handy for the project I am working on.

@David.K1 The Camber package has a node for adding 3D Faces to a surface.

Check out this thread for the rest of the conversation…

Thank you for your reply JPhil, but the solution on that post doesn’t work for me.

I have created a new thread for this. Batch Generate Tins: 3D Solid to Bottom and Top Tins