Inventor Customization

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

CalculateStrokes generates a COM exception

131 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
Posts: 15
Registered: ‎09-05-2012
Message 2 of 4 (120 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
Posts: 421
Registered: ‎08-14-2012
Message 3 of 4 (114 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
Posts: 15
Registered: ‎09-05-2012
Message 4 of 4 (106 Views)

Re: CalculateStrokes generates a COM exception

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

Wesome, that did it. Thank you.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube