Copy/Duplicate 3D surface to flat surface

Copy/Duplicate 3D surface to flat surface

nizamthonichal
Advocate Advocate
1,056 Views
3 Replies
Message 1 of 4

Copy/Duplicate 3D surface to flat surface

nizamthonichal
Advocate
Advocate

I made a civil3D surface based on different level.  I would like to make the duplicate flat surface between the lowest & highest level from the existing surface. The new surface boundary should be the same of the existing surface boundary.

0 Likes
1,057 Views
3 Replies
Replies (3)
Message 2 of 4

hippe013
Advisor
Advisor

Maybe something like this.

 

<CommandMethod("MakeFlatSurface")>
        Public Sub CmdMakeFlatSurface()
            Dim aDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim ed As Editor = aDoc.Editor
            Dim db As Database = aDoc.Database
            Dim opt As New PromptEntityOptions(vbCrLf + "Select Surface: ")
            opt.SetRejectMessage(vbCrLf + "Must be a surface.")
            opt.AddAllowedClass(GetType(TinSurface), True)
            Dim res As PromptEntityResult = ed.GetEntity(opt)
            If res.Status = PromptStatus.OK Then
                Using tr As Transaction = db.TransactionManager.StartTransaction
                    Dim surf As TinSurface = tr.GetObject(res.ObjectId, OpenMode.ForRead)
                    Dim borders As ObjectIdCollection = surf.ExtractBorder(Autodesk.Civil.SurfaceExtractionSettingsType.Plan)
                    Dim elev As Double = surf.GetGeneralProperties.MeanElevation
                    Dim styleId As ObjectId = cvlDoc.Styles.SurfaceStyles.Item(0)
                    Dim newSurfaceId As ObjectId = TinSurface.Create("MyFlatSurface", styleId)
                    Dim newSurface As TinSurface = tr.GetObject(newSurfaceId, OpenMode.ForWrite)
                    Dim verts As TinSurfaceVertexCollection = surf.Vertices
                    For Each vert As TinSurfaceVertex In verts
                        Dim p As New Point3d(vert.Location.X, vert.Location.Y, elev)
                        newSurface.AddVertex(p)
                    Next
                    newSurface.BoundariesDefinition.AddBoundaries(borders, 1.0, SurfaceBoundaryType.Outer, True)
                    tr.Commit()
                End Using
            End If
        End Sub
Message 3 of 4

nizamthonichal
Advocate
Advocate

Hi Sir,

Thank you for the respond, I m not experienced a Civil3D user.  I think which you reply is the program in Visual Basic,  I dno't know how to run the program in Civil3D.  Can you help me.

 

Regards

Nizamuddin

0 Likes
Message 4 of 4

hippe013
Advisor
Advisor

There are quite a bit of resources here. This would be a good place to start.

https://knowledge.autodesk.com/support/civil-3d/learn-explore/caas/CloudHelp/cloudhelp/2017/ENU/Auto...

0 Likes