Q: I may use the Change Size command to change a key parameter for a Content Center part placed as a Custom component. But how can I do it programmatically?
A: If we talk about “Change Size as custom”, there is no existed API to support currently. There is a series of internal logic that are implemented in CC.
For example,
• Get the target CC table row
• Get all parameters you need to change
• Get the new values
• Batch Edit the parameters
• …
• Update Part
In this case Inventor changes existing part document via Parameters API and iProperties API directly – no new part, no file replacement. Of course, it is always better to have an appropriate API function, but in this particular case we are able to implement this workflow ourselves.
We access our CC custom component saved locally, then get its current row in the CC family table and suppose we know the new target row number.
User parameter’s names in the CC component are the same as the corresponding InternalNames of the ContentTableColumns in the ContentFamily. So we may read target parameter’s values from the cells in the target ContentTableRow and then update the user parameters in the file on disk.
We should also update several iProperties – the part number, stock number, MemberId and may be other iProperties as well. Finally we should rename component in the browser (name is usually based on part number) and then update both the part and assembly documents.
It is not easy to implement a general purpose utility that could work with any CC family, but fortunately in most cases you work with several particular families (e.g., structural shapes). This could simplify this specific implementation.
The attached VBA code demonstrates the workflow that mimics the “Change Size” UI command for the CC component placed as Custom. This code reads family data from the last component in the browser assuming that it is a CC member and asks the user to enter the new row number. New model parameters and iProperties values are applied to the member file on disk. New file is not created.
As a ”proof of concept” this code contains a lot of debug printing and was tested with some structural profiles families only — angles, channels, and i-beams. Hope it could be modified to process other CC families.