SurfaceBody.GetExistingFacets( ToleranceIndex As Double, VertexCount As Long, FacetCount As Long, VertexCoordinates() As Double, NormalVectors() As Double, VertexIndices() As Long )
The above is from Inventor programing Help. This works fine in VBA (Inventor 2014). But when I start using the same in VB.NET (VS 2012) all declaration as long shows as integer and fails on compiling. If I change to integer compile passes but fail on executing in Inventor 2014.
Please find the below snap shots for detail.
Solved! Go to Solution.
Solved by ekinsb. Go to Solution.
Indeed,
Long Holds signed 64-bit (8-byte) integers (Int64)
Integer Holds signed 32-bit (4-byte) integers (Int32)
However,
msdn.microsoft.comIf you are interfacing with components not written for the .NET Framework, for example Automation or COM objects, keep in mind that Long has a different data width (32 bits) in other environments. If you are passing a 32-bit argument to such a component, declare it as Integer instead of Long in your new Visual Basic code.
Are you getting OverflowExceptions?
Overflow exception is only in VBA 7 after declaring as long array and use an integer as array value. if use long value the function works fine.
Dim i As Integer Dim lVertexCount As Long Dim lFacetCount As Long Dim adVertexCoords() As Double Dim adNormalVectors() As Double Dim alVertexIndices() As Long Call oBody.GetExistingFacets(dFacettol, lVertexCount, lFacetCount, adVertexCoords, adNormalVectors, alVertexIndices) For i = 0 To lVertexCount - 1 'this gives overflow For j = 0 To lVertexCount - 1 'this works fine (j as Long)
Although they are very similar, VB.Net does have some big differences when compared to VBA. There's nothing to be fixed in Inventor in this case, it's just a matter of knowing how to use VB.Net. There are a few things to be aware of when converting VBA to VB.Net that could come into play in this case.
Dim stuff(1 to 10) As Double
3. You need to initialize arrays before they can be passed to a method. I think this is what's causing you problems now. For example, instead of:
Dim adVertexCoords() As Double
you need to do this in VB.NET
Dim adVertexCoords() As Double = {}
I took the ZHeightColors VBA sample from the API help and converted it to run in VB.Net. The code for the function is attached.