The 'More Info' tab of the error message showed what I needed to see. The error is happening when it 'getting' the value of the ComponentOccurrence.ActivePositionalRepresentation property. I don't know why I didn't think of this earlier, but parts do not have positional representations...only assemblies do. Both parts and assemblies have ModelStates and view representations. That's why it is throwing an error when it encounters components that represent parts. The ComponentOccurrence object has properties for all of those, but not all source models have properties for them to pull that data from, leading to errors like that. To eliminate that error, and let the code continue, I will just put that data request within another Try...Catch...End Try statement.
I will also eliminate capturing the ModelState name, and eliminate attempting to add that into the component's name, since I do not recall if there is a way to eliminate it automatically getting included anyways.
I am not 100% sure what is causing the same data to stack-up in the component name when ran multiple times. However, I do have a suspect. I think it may be where I am attempting to get the original 'Index' from the component's name. By default, every component is named like the source model's file name (without file extension), then it has a colon character (:), followed by an Integer, as its index, to keep the names of multiple instances of the same source model unique. That line of code is attempting to capture the portion of the component's original name that is just after its last colon character, expecting it to just be a simple Integer, not a whole bunch of custom stuff. My code was not preserving the colon character though either, which was a mistake on my part. Since this is a very unique and custom situation, we may need to forget about the original/previous index of each component, and come up with a way to use a new indexing system, because we still need there to be an index system, to keep their names unique when there are multiple instances of the same source model. An idea that comes to mind is using a two-factor collection, like a Dictionary, to keep track of each 'source document' FullFileName, and the Index of the last one, as we iterate though the components. If we have not encountered a source document before, then the index for that first component referencing it should start at one. If we have encountered other component occurrences referencing that source document before, then we get the index of the last one we encountered, add one for the current instance's index, then record the new index value for next time.
I am not sure if you ever use the iLogic Log window, or the iLogic Logger resource, but I highly recommend doing so. In order for an iLogic rule to be able to write entries into the iLogic Log window, the tab for that iLogic Log window must be 'visible' (not necessarily the active tab though), before you run any iLogic rules that may be trying to write something to it with the Logger lines of code. Then, when the rule is done, you can click on that iLogic Log tab, to see what entries (if any) the rule may have written to it. There are lots of reasons why you may want to use that Logger resource, but 'debugging', providing progress feedback, and key pieces of information that the rule encounters along the way, are three of the most popular reasons. It became available in the 2019 version of Inventor, and I have been heavily using it ever since, because it has been super useful.
When setting the name of a component by code, if the new name you are trying to set is already being used, it will throw an error. This is one reason why renaming components, or even attempting to 'reset' component names, can be complicated. Normally, 'resetting' their names to their 'default' would be done by iterating through them, and set their names to an 'empty' String, which causes it to automatically adapt its 'default' name. But even doing that can cause an error for the same reasons. I do not know of a way to instantaneously rename all occurrences at the exact same time by code, so that user interface tool can really help for that purpose, and there is no Inventor API or iLogic API equivalent to that tool. One strategy is to use a completely unique 'base name' for all components, and add an Integer type index to the end for each one, to rename all of them a first time, then go back a second time and rename all of them to 'empty' strings, to reset them.
This time, I will attach the updated code as a text file, since it is getting pretty long. Makes it quicker & easier for others to read through the discussion later.
Wesley Crihfield

(Not an Autodesk Employee)