- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Glad to hear I was able to help you out. Yes, that code was pretty basic. There a several ways the code could be laid out differently to suit your custom needs. A better process might have been to make sure there was an 'unlocked' view representation available in both the main assembly and in the sub assembly, and if they did not exist yet, create them. Then in the sub assembly, record which view rep is currently active, if it's not the one we want, then activate the one we want, then set the component's visibility to off, then switch back to the original view rep, then update and save the sub assembly. Then back in the main assembly, activate the unlocked view rep we want to use there (if not already active), then set the view rep of the sub assembly (as a component) to the one we used within it, then update/save the main assembly. The view reps can complicate these types of situations, especially if trying to maintain 'associative' settings of those view reps. Those components can also be suppressed or have their BOMStructure property set to Reference, so they won't get listed in certain BOM outputs, and those settings could also be stored in the ModelStates.
If you are in need of a more robust solution, or one that loops through multiple layers of sub assemblies and components, that can be done too, but of course it adds to the complexity.
Wesley Crihfield
(Not an Autodesk Employee)