|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
int data type compatibilitywhich 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[i].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! for (inti... is actually for (int i... in the code
thought I would specify before someone tried to correct that. Phuff wrote: Show quote > 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[i].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! 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++)... Phuff wrote: Show quote > 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[i].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! |
|||||||||||||||||||||||