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.
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
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
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
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