Simple FOR LOOP crashes with a Parameter error for this one Component for no known reason

Simple FOR LOOP crashes with a Parameter error for this one Component for no known reason

Anonymous
Not applicable
631 Views
4 Replies
Message 1 of 5

Simple FOR LOOP crashes with a Parameter error for this one Component for no known reason

Anonymous
Not applicable

Hello,

 

I am having an issue, and I do not know what is causing it. See image "Parameter is incorrect". When my For Loop is looping it always hangs up on the same part "Jumper WP:16". It gives me a "parameter is incorrect" see image "Parameter is incorrect". It handles every other part just fine but this one. I have no idea what is going on.

See my browser tree "Parameter is incorrect - 3" image so you can see how the assembly model is built. I also put an image of the Visual Studio Autos window, so you can see nothing strange is going on. See image "Parameter is incorrect - 2". At first, I thought it did not like the 2 digit place for the component count, but it did count some with 2 digits. Any help would be grateful. 

 

Thanks,

 

Mike Munson

Inventor 2018 Pro

Visual Studio 2017

0 Likes
Accepted solutions (1)
632 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

In you second picture it says X = 21, but I only count 20 occurrences in your third picture. I think it's trying to get an occurrence that doesn't exist. I'm not sure where your CenterLineToolModule.AssyCompOccCount is getting it's number, but you might want to run a test and see what it equals.

Message 3 of 5

Anonymous
Not applicable

I will take a look. It is actually counting AllLeafOccurences. Maybe, I need to change my approach. Thanks for your help.

0 Likes
Message 4 of 5

Anonymous
Not applicable
Accepted solution

I think leaf occurrences will include occurrences in your sub assemblies as well. I think you want something like AssemblyDocument.ComponentDefinition.Occurrences.Count for just the occurrences in your top assembly. If you are trying to check for sketches in the occurrences in sub assemblies as well, you will probably need a different approach.

Message 5 of 5

Anonymous
Not applicable

I got it. I needed to go to the AllLeafOccurences, so I was not going deep enough. Thanks again.

0 Likes