Type mismatch when calling CalculateFacetsAndTextureMap

By Adam Nagy

When calling CalculateFacets or CalculateFacetsAndTextureMap the following way you'll get a Type mismatch exception:

Inventor.Application inv = (Inventor.Application)
  Marshal.GetActiveObject("Inventor.Application");
 
// Select a face before runnig this code
Face face = inv.ActiveDocument.SelectSet[1]; 
 
double tolerance = 0.1;
int vertexCount = 0;
int facetCount = 0;
double[] vertexCoordinates;
double[] normalVectors;
int[] vertexIndexes;
double[] textureCoordinates;
face.CalculateFacetsAndTextureMap(
  tolerance, out vertexCount, out facetCount, 
  out vertexCoordinates, out normalVectors, 
  out  vertexIndexes, out textureCoordinates);

You'd need to initialize the input parameters – including the arrays. In case of VB.NET those parameters are underlined warning you about this, but C# does not seem to do that. The following code works fine:

Inventor.Application inv = (Inventor.Application)
  Marshal.GetActiveObject("Inventor.Application");
 
Face face = inv.ActiveDocument.SelectSet[1]; 
 
double tolerance = 0.1;
int vertexCount = 0;
int facetCount = 0;
double[] vertexCoordinates = new double[]{};
double[] normalVectors = new double[]{};
int[] vertexIndexes = new int[]{};
double[] textureCoordinates = new double[]{};
face.CalculateFacetsAndTextureMap(
  tolerance, out vertexCount, out facetCount, 
  out vertexCoordinates, out normalVectors, 
  out  vertexIndexes, out textureCoordinates);

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading