Issues with SurfaceBody.CalculateFacets in Inventor 2025 Add-in (.NET 8 / x64)

Issues with SurfaceBody.CalculateFacets in Inventor 2025 Add-in (.NET 8 / x64)

ewoudQDYF4
Explorer Explorer
75 Views
1 Reply
Message 1 of 2

Issues with SurfaceBody.CalculateFacets in Inventor 2025 Add-in (.NET 8 / x64)

ewoudQDYF4
Explorer
Explorer

 

Hi everyone,

I’m working on an Inventor 2025 add-in in C# (targeting .NET 8, x64) that fingerprints parts by falling back to a mesh-based hash via the SurfaceBody.CalculateFacets API. Although I can successfully compile against Autodesk.Inventor.Interop.dll, at runtime every call to CalculateFacets fails with a type-mismatch error and returns zero vertices:

 

less
 
FOUT in CalculateFacets voor body: Type mismatch. (0x80020005 (DISP_E_TYPEMISMATCH)) [MeshHash] Totaal vertices gevonden: 0 [MeshHash] Geen vertices gevonden, hash blijft leeg.

My environment:

  • Inventor: 2025 (fully updated)

  • Visual Studio: 17.8+, targeting .NET 8 SDK

  • Platform: x64 build

  • Interop settings:

    • Embed Interop Types = False

    • Copy Local = True

What I’ve tried so far:

  1. Confirmed the add-in DLL is loaded in the x64 Inventor process.

  2. Referencing the Inventor 2025 interop DLL from C:\Program Files\Autodesk\Inventor 2025\Bin.

  3. Various overloads, including:

    csharp
     
    body.CalculateFacets( 0.01, out int vertexCount, out int facetCount, out double[] vertexCoords, out double[] normalVectors, out int[] vertexIndices );
  4. Using out object parameters then casting.

  5. Verifying that each SurfaceBody actually has faces.

Questions:

  • Is there a different COM signature or overload for CalculateFacets in Inventor 2025/.NET 8?

  • Do I need to pre-allocate arrays or use a special marshalling attribute?

  • Has anyone successfully used CalculateFacets under .NET 8/x64 with Inventor 2025? A minimal working example would be hugely appreciated.

Attachment:
I’ve included the full SmartCopyExporter.cs source as a TXT attachment for reference.

Thanks in advance for any pointers!

76 Views
1 Reply
Reply (1)
Message 2 of 2

julian_sol
Contributor
Contributor

I have encountered the same issue too. It appears to be a bug in the Inventor API.

In the VBA Editor within Inventor itself this method does work:

Dim vertexCount As Long
Dim facetCount As Long
Dim vertexCoords() As Double
Dim normalVectors() As Double
Dim vertexIndices() As Long

Call oBody.CalculateFacets(tolerance, vertexCount, facetCount, vertexCoords, normalVectors, vertexIndices)


But in C# it gives the error: Type mismatch. (0x80020005 (DISP_E_TYPEMISMATCH)) 

int vertexCount = 0;
int facetCount = 0;
double[] vertexCoords = null;
double[] normalVectors = null;
int[] vertexIndices = null;

body.CalculateFacets(tolerance, out vertexCount, out facetCount, out vertexCoords, out normalVectors, out vertexIndices);


Maybe it's because in VBA it requests a Long and in C# an int?

0 Likes