Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem reading aecctinsurface boundary

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
wang890
525 Views, 6 Replies

Problem reading aecctinsurface boundary

using com api for this one.

 

i am trying to read tin surface boundary. but it gives unspecified error on the surface which has a boundary. the ones with 0 boundary returns 0 ok.

 

  For Each oBdry As AeccSurfaceBoundary In oBaseSurface.Boundaries

            If oBdry.Type = AeccBoundaryType.aeccBoundaryOuter Then
                Dim oBdry3D As Acad3DPolyline = oBdry.BoundaryEntity

                Exit For
            End If

        Next

 get surface ok but when iterating through surface boundary the oBaseSurface.Boundaries gives "unspecified error".

 

hope i can use com api for this if not then i will use .net. can figure it out but takes longer and not not all functions available compared to com api.

 

thanks guys.

Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19
6 REPLIES 6
Message 2 of 7
Jeff_M
in reply to: wang890

The BoundaryEntity returns an AcadEntity, not necessarily an Acad3dPolyline.In a quick test, using the AcadEntity, it works just fone for me.

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 7
wang890
in reply to: Jeff_M

oh actually it's not getting stuck at the line which i am hooking up 3dpoly to the boundary object. it's still being stuck at

 

ForEach oBdry AsAeccSurfaceBoundaryIn oBaseSurface.Boundaries

Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19
Message 4 of 7
Jeff_M
in reply to: wang890

Can you post usable code to test? As I said, it works fine for me (using c#).

Jeff_M, also a frequent Swamper
EESignature
Message 5 of 7
wang890
in reply to: Jeff_M

i think at some point i shoudl switch to c#. now the .net api help is online( annoying) also all in c#. i can understand ok but still have some differences.

 

the commented stuff if you turn on will give the error. below the commented stuff is my work around. extractboundary() instead.

 

 Private Sub btnCalculate_Click(sender As System.Object, e As System.EventArgs) Handles btnCalculate.Click

        Dim oSurfaces As AeccSurfaces = oAeccDb.Surfaces
        Dim oTinVolumeSurface As AeccTinVolumeSurface = Nothing
        Dim oBaseSurface As AeccTinSurface = Nothing
        Dim oComparisonSurface As AeccTinSurface = Nothing

        Dim sBaseSurfaceName As String = ""
        Dim sComparisonSurfaceName As String = ""

        oBaseSurface = oSurfaces.Item(CInt(lvwSurfaces.SelectedItems(0).SubItems(1).Text))
        'Dim oContours As Object = oBaseSurface.ExtractContour(AeccDisplayOrientation.aeccDisplayOrientationModel, AeccSurfaceFilterType.aeccSFMajorContours, _
        '                                                    oBaseSurface.Statistics.MinElevation, _
        '                                                    oBaseSurface.Statistics.MaxElevation)

        'For Each oBdry As AeccSurfaceBoundary In oBaseSurface.Boundaries
        '    oBaseSurface.

        '    If oBdry.Type = AeccBoundaryType.aeccBoundaryOuter Then
        '        Dim obj As AcadEntity = oBdry.BoundaryEntity
        '        Dim oBdry3D As Acad3DPolyline
        '        If TypeOf oBdry3D Is Acad3DPolyline Then
        '            oBdry3D = CType(obj, Acad3DPolyline)
        '            Exit For
        '        End If
        '    End If
        'Next

        For d As Double = nudMinElev.Value To nudMaxElev.Value Step nudElevStep.Value

            Dim obj As Object = oBaseSurface.ExtractBorder(AeccDisplayOrientation.aeccDisplayOrientationModel)
            Dim oBdry3D As Acad3DPolyline = obj(0)

            Dim oTinData As New AeccTinCreationData
            With oTinData
                .BaseLayer = "0"
                .Name = d.ToString
                .Layer = "0"
                .Style = oAeccDb.SurfaceStyles.Item(0).Name
            End With

            Dim oSurface As AeccTinSurface = oSurfaces.AddTinSurface(oTinData)
            Dim oPoly(0) As Acad3DPolyline
            oPoly(0) = Convert3To2DPolylinesWithElevation(oBdry3D, d)

            oSurface.Breaklines.AddStandardBreakline(oPoly, "br", 10)
            oSurface.Boundaries.Add(oPoly(0), "bdry", AeccBoundaryType.aeccBoundaryOuter, True, 10)

        Next



    End Sub


  Public Function Convert3To2DPolylinesWithElevation(o3DPoly As Acad3DPolyline, dElev As Double) As Acad3DPolyline

        Dim Coords As Object
        Dim objPol As Acad3DPolyline

        Coords = o3DPoly.Coordinates
        Dim dPLCoord(0) As Double
        Dim j As Integer = 0
        For i As Integer = 0 To UBound(Coords)

            If (i + 1) Mod 3 <> 0 Then
                ReDim Preserve dPLCoord(j)
                dPLCoord(j) = Coords(i)
                j += 1
            Else
                ReDim Preserve dPLCoord(j)
                dPLCoord(j) = dElev
                j += 1
            End If
        Next

        objPol = oAcadDoc.ModelSpace.Add3DPoly(dPLCoord)
        objPol.Closed = True
        
        Return objPol

    End Function

 

 

Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19
Message 6 of 7
Jeff_M
in reply to: wang890

Not quite usable code...normally, if you want to get help finding a problem, you would post cod ethat can be copied into the IDE and, with minimal work, be able to actually run it. Posting things from a form, that rely on other things from the form, does not really satisfy that.

 

So, I had to create my own (which took a bit since I don't use VB much at all), which works fine. This leads me to thnk there is something else in your code causing it to fail. Which is why it is important to post the code as it is failing for you. Here's my working code:

    Public Shared Sub surftestvb()
        Dim acadApp As Autodesk.AutoCAD.Interop.IAcadApplication
        acadApp = CType(Application.AcadApplication, Autodesk.AutoCAD.Interop.IAcadApplication)

        Dim aeccApplication As AeccUiLandLib.AeccApplication = New AeccUiLandLib.AeccApplication
        aeccApplication.Init(CType(acadApp, Autodesk.AutoCAD.Interop.AcadApplication))
        Dim aeccDoc As AeccUiLandLib.IAeccDocument = CType(aeccApplication.ActiveDocument, AeccUiLandLib.IAeccDocument)
        Dim oSurf As AeccLandLib.AeccSurface = aeccDoc.Surfaces.Item(0)
        Dim oBndyEnt As AcadEntity = Nothing
        For Each oBndy As AeccLandLib.AeccSurfaceBoundary In oSurf.Boundaries
            If oBndy.Type = Autodesk.AECC.Interop.Land.AeccBoundaryType.aeccBoundaryOuter Then
                oBndyEnt = oBndy.BoundaryEntity
            End If
        Next
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nFound a {0} entity at surface boundary!", oBndyEnt.ObjectName)
    End Sub

 

Jeff_M, also a frequent Swamper
EESignature
Message 7 of 7
wang890
in reply to: wang890

Thanks Jeff I think this will do. Sorry for the trouble.

So next time I should just attach the original vb files for the entire form?

Might be something wrong with the surface itself. I will test more with your code. Consider this solved.
Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report