Inventor Customization

Inventor Customization

Reply
Contributor
serge2go
Posts: 15
Registered: ‎09-05-2012
Message 1 of 4 (143 Views)
Accepted Solution

CalculateStrokes generates a COM exception

143 Views, 3 Replies
11-28-2012 09:25 AM

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

Contributor
serge2go
Posts: 15
Registered: ‎09-05-2012
Message 2 of 4 (132 Views)

Re: CalculateStrokes generates a COM exception

11-28-2012 09:02 PM 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.

ADN Support Specialist
Vladimir.Ananyev
Posts: 473
Registered: ‎08-14-2012
Message 3 of 4 (126 Views)

Re: CalculateStrokes generates a COM exception

11-29-2012 03:03 AM 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

Contributor
serge2go
Posts: 15
Registered: ‎09-05-2012
Message 4 of 4 (118 Views)

Re: CalculateStrokes generates a COM exception

11-29-2012 07:50 AM in reply to: Vladimir.Ananyev

Wesome, that did it. Thank you.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.