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: 

CalculateStrokes generates a COM exception

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
serge2go
317 Views, 3 Replies

CalculateStrokes generates a COM exception

Hi,

 

Here is my C# code:

 

private void Button1Definition_OnExecute(NameValueMap context)
{
try
{
// get current document
PartDocument oCurrentDoc = m_inventorApplication.ActiveDocument as PartDocument;
PartComponentDefinition oCompDef = oCurrentDoc.ComponentDefinition;

SurfaceBody body = oCompDef.SurfaceBodies[1];
if (body == null)
return;


int VertexCount, SegmentCount;
int[] VertexIndices;
double[] VertexCoordinates;

double v = body.get_Volume(90); // <---- returns fine
body.CalculateStrokes(.1, out VertexCount, out SegmentCount, out VertexCoordinates, out VertexIndices);

 

}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.ToString());
}

}

 

The line:

body.CalculateStrokes(.1, out VertexCount, out SegmentCount, out VertexCoordinates, out VertexIndices);

 

ALWAYS generates a COMException 0x80020005 (Type mismatch). I am trying to figure out if my paramaters are wrong... Any help is greately appreciated.

 

Thank you.

-Serge

3 REPLIES 3
Message 2 of 4
serge2go
in reply to: serge2go

I updated my copy of winodw 7 with all system updated (optional or not). I went ton Autodesk's website and dwonloaded Inventor 2013 SP2, installed it, no luck. I would really appreciate if someone would maybe take a lo look at the project.... If it is not something obvious with the code, then maybe the project settings??? But then again, I used the project wizzard with no specai modifications... Ayways, please let me know if I can provide you need more information.

Message 3 of 4
Vladimir.Ananyev
in reply to: serge2go

Please use initialized arrays:

int VertexCount;
int SegmentCount;
int[] VertexIndices = {};
double[] VertexCoordinates = {};
 
body.CalculateStrokes(.1, 
       out VertexCount, 
       out SegmentCount, 
       out VertexCoordinates, 
       out VertexIndices);

 This works for me.

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 4 of 4
serge2go
in reply to: Vladimir.Ananyev

Wesome, that did it. Thank you.

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

Post to forums  

Autodesk Design & Make Report