int data type compatibility

P

Phuff

I'm hoping someone has some suggestions. I'm programming something
which interacts with Autodesk Inventor release 11 SP2. I want to for
loop through a collection and get data fro each item. Although the
collection specifies [int index] it does not seem to be compatible with
..Net's version of int.

for (inti = 0; i < var.DrawingViews.Count; i++)
{
MessageBox.Show(var.DrawingViews.Name);
}

This always returns an invalid parameter exception.
However, this works:

for (inti = 0; i < var.DrawingViews.Count; i++)
{
MessageBox.Show(var.DrawingViews[8].Name);
}

As you can see if you hard code the number it gets cast or converted,
COM side, to whatever data type Inventor wants. I've tried everything.
Int16-64, short-long, and all the unsigned variants. None of them
work. I am aware that I can enumerate through the collection with
foreach and it does in fact work. However, there will undoubtedly be a
point where I will want a dynamic index variable.

Any suggestions? Any type of Win32 type I should marshal in and cast
this int as?

Thanks!
 
P

Phuff

for (inti... is actually for (int i... in the code

thought I would specify before someone tried to correct that.
 
P

Phuff

OKay, I got it figured out. Apparently Autodesk uses 1 based
collections, not 0 based. How annoying.

for (int i = 1; i <= var.DrawingViews.Count; i++)...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top