Inventor API: Change Size of CC Component Placed as Custom

by Vladimir Ananyev

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?

Change Size command

Table View

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.

Download Mod_CC_4

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.


Comments

3 responses to “Inventor API: Change Size of CC Component Placed as Custom”

  1. Jeff Smeker Avatar
    Jeff Smeker

    Hi there, I’m looking to change the length of a content center structural shape based on some variables. this code looked like an interesting starting point. I was able to load it into my VBA project, it compiled ok, but when I attempt to run “CustomMember_ChangeRow”, I get a Error 13 Type Mismatch Error on one of the first lines (Set oDef = oOcc.Definition).
    I have an assembly open with a few content center structural shapes, I see some info populated in some items above this line (i.e. Set oOcc = oAsmDef.Occurrences.Item(oAsmDef.Occurrences.Count) has a value), but I get this error.
    Any idea what could cause this? Thanks for the help!!

  2. Hi Jeff, the code seems to assume that you want to edit the last occurrence in the assembly and so it’s a content center part file occurrence – in your case it’s probably an assembly occurrence?
    You could either modify the code to work with a selected occurrence, or move the cc part occurrence to the last place in the tree

  3. Jeff Smeker Avatar
    Jeff Smeker

    Yup, that was it. Seem like this is only for changing the row of the content center item, I’m looking to automate changing the length. It does change the row, but leaves the file name the same, and I don’t see any options on how to modify the length in this. Any ideas?? Thanks for the help!

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading