Since that one iteration is doing multiple things (accessing Property values, String manipulations, PartFeature renaming, then AttributeSet creation), it is most likely not the task of adding an AttributeSet to each PartFeature that is taking the bulk of the time. It is most likely the PartFeature renaming part that is the most time consuming. I'm pretty sure the act of changing a feature's name will cause multiple other 'background process' to get triggered and processed. As for possible strategies for reducing that processing time, I have a couple ideas, but not sure how effective they will be for you in this situation. The type of document (part or assembly) you are dealing with may also play an important role.
- If it's an assembly, then one thing you may want to try is turning the DeferUpdate setting on. That setting is in the Application Options, on the Assembly tab, right at the top. When that setting is turned on (checkbox checked), then some types of changes will not be visually seen immediately when they would normally happen, but will wait until you explicitly click the Update button, then things will visually update. This setting can also be reached by code with the AssemblyOptions.DeferUpdate property, which can be reached from the Application.AssemblyOptions property. However, you may want to set that back the way it was when your process is done, even if an error interrupts the process.
- You can try setting the Application.ScreenUpdating property's value to False, temporarily while your process is working, then back to True when done. Again, this one is dangerous to leave off if an error interrupts your code, so you may need to incorporate a Try...Catch...Finally...End Try statement into your code, and put the 'risky' part on the 'Try' side, and the code to turn that setting back on in the Finally part, so that it will always get executed, even if an error happens.
- The Application.SilentOperation property is another similar type of setting, which will help eliminate any Inventor dialogs from popping-up while your code is working, but that does not seem like it would help much in this exact situation.
There maybe a couple other little tips like that floating around also, but those are the ones that immediately came to mind.
Wesley Crihfield

(Not an Autodesk Employee)