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: 

Bounded Volumes

7 REPLIES 7
Reply
Message 1 of 8
Ed.McGriskin
603 Views, 7 Replies

Bounded Volumes

 

I am trying to write some code that will perform the bounded volumes routine following the selection of some polylines and the volume surface. The issue I am having is that the bounded volumes expects a variant array of doubles which no longer exists in VB.Net. Anyone have any tips/pointers for dealing with this?


Thanks,

Ed McGriskin, P.Eng.
Project Engineer @ HUSSON
Remember to accept the solution so others can find the solution also.
7 REPLIES 7
Message 2 of 8

Hi,

 

You probably need to create an array of objects and resize to the correct size. Which method are you using here?

 

Augusto Goncalves

Autodesk Developer Network

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 3 of 8

Hi Augusto,

 

Here is the code I use to create the array and try to pass to the Bounded Volumes. I am an amateur programmer so it may not be the prettiest or most correct but does generally it seems to work. The oCutFillSurface1 is a Tin Volume Surface selected earlier in the program. 

 

'Get the polyline from the object ID stored in DataTable.
oBound = Table.Rows(i).Item(8)
oPolyline = g_oCivil3DDoc.ObjectIdToObject(oBound)

If TypeOf oPolyline Is Autodesk.AutoCAD.Interop.Common.AcadPolyline Then
                        Dim oCounter As Integer = 0
                        Dim oArrayCount As Integer = 0
                        oPolyline1 = oPolyline

                        'Create the x,y coordinate array.
                        oArray = oPolyline1.Coordinates
                        oCount = oArray.Length / 2

                        'Creating an x,y,z coordinate array with z=0.
                        For j = 0 To oArray.Length + oCount - 1
                            If oCounter = 2 Then
                                oPoints.Add(0)
                                oCounter = 0
                            Else
                                oPoints.Add(oArray(oArrayCount))
                                oCounter = oCounter + 1
                                oArrayCount = oArrayCount + 1
                            End If
                        Next
                        oArray = oPoints.ToArray

                        oCutFillSurface1.Statistics.BoundedVolumes(oArray, oCut, oFill, oNet)

 

At this point I reviewed the following error.

 

System.ArgumentException was caught
  Message=Value does not fall within the expected range.
  Source=Autodesk.AECC.Interop.Land
  StackTrace:
       at Autodesk.AECC.Interop.Land.IAeccTinVolumeSurfaceStatistics.BoundedVolumes(Object varPoints, Double& pCut, Double& pFill, Double& pNet)
       at EarthworkCalc.Form1.Button6_Click(Object sender, EventArgs e)
  InnerException:

 

Thanks in advance for your help.

Ed McGriskin, P.Eng.
Project Engineer @ HUSSON
Remember to accept the solution so others can find the solution also.
Message 4 of 8

Hi,

 

Try with:

Dim oArray As New List(Of Object)

 

And:

oCutFillSurface1.Statistics.BoundedVolumes(oArray.ToArray, oCut, oFill, oNet)

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 5 of 8

Still running into the same issue.

Ed McGriskin, P.Eng.
Project Engineer @ HUSSON
Remember to accept the solution so others can find the solution also.
Message 6 of 8
Ed.McGriskin
in reply to: Ed.McGriskin

I have completed some more testing to make sure that the issue is not with the surface and I am able to do other manipulations and pull other statistics from the surface.

 

As far as I can tell with my limited expertise is that the issue has to do with the array containing the coordinates and how the bounded volumes interprets that array.

Ed McGriskin, P.Eng.
Project Engineer @ HUSSON
Remember to accept the solution so others can find the solution also.
Message 7 of 8

Hi,

 

Sorry I do not have resource to prepare a sample project and test your app, if you care to provide a more ready to use code, I can try it further.

 

Usually these errors related to Variants on VB.NET are related to a cast conversion, mainly because the way it receive the data. Also it could be related to data it self, like the last point on the collection being equals the first, but as you said the same code worked on VBA, I´m suspecting it the first case.

 

Regards,
Augusto Goncalves

Autodesk Developer Network

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 8 of 8

I have actually managed to figure out the issue I was having.

 

First, your post mentioned that the first point has to be the same as the last point. I didnt have this in my original code and made that fix.

 

The second thingwas I changed the oArray variable to

 

Dim oArray As New List(Of Double)

 

This has fixed the problem.


Thanks for your help.

Ed McGriskin, P.Eng.
Project Engineer @ HUSSON
Remember to accept the solution so others can find the solution also.

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report