Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GetExistingFacets VBA 7 and VB.NET showsdifferent and fails in VB.net

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
saseendrankombath
1714 Views, 6 Replies

GetExistingFacets VBA 7 and VB.NET showsdifferent and fails in VB.net

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.

6 REPLIES 6
Message 2 of 7
jdkriek
in reply to: saseendrankombath

Indeed,

Long Holds signed 64-bit (8-byte) integers (Int64)

Integer Holds signed 32-bit (4-byte) integers (Int32)

 

However,


msdn.microsoft.com
If 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?

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 7
saseendrankombath
in reply to: jdkriek

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)

 

Message 4 of 7

Please find attached error detail

Message 5 of 7

Requesting a Solution from Autodesk to solve this issue !!!!!

Message 6 of 7
ekinsb
in reply to: saseendrankombath

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.

 

  1. Use Integer instead of Long.  This was already discussed.
  2. Be aware that the first index of an array is aways zero.  A lot of VBA code will have declared arrays like:

     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.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 7 of 7
saseendrankombath
in reply to: ekinsb

Thanks Brian. Thanks a lot to helping.

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

Post to forums  

Autodesk Design & Make Report