Components with Sub-Components

I often save components as small assemblies. For example, a robot mounted on a riser with a gripper attached. When I save the parent component (the riser), it includes the robot and gripper. This is much faster than inserting and connecting three separate components every time.

The issue is version control. If I update one of the sub-components, such as modifying the riser model, I have to manually re-save every assembly that contains it. Managing these updates becomes difficult.

Is there a better way to structure this so sub-components point to their original VCIDs instead of being saved as new embedded instances inside the assembly?

There’s no easy way to do this unfortunately. In VC models there’s no true referencing except for geometries in layouts when you save layout without “Include Components” setting. Then geometries are not packed into the layout vcmx but they are resolved from eCat components based on VCID and the geometry URIs. All other objects like properties, behaviors and features are always packed into the main vcmx in that state at the time of saving. So editing those in the referenced models is not reflected in your assembly/layout.

Really for a feature like this you could perhaps try to do some python add-on that replaces old sub-component with the latest one. And it may work decently if components are just geometry. But if you have some interoperability like interfaces and signals connecting to other components and those are edited then the update process leads to conflicts which you need to resolve.

-k

Thanks, that’s what I suspected.

I considered writing a Python add-on to handle this, but I’m not sure what the best entry point would be. Is there any way to programmatically force a sub-component to reload from its original VCID, essentially replacing the embedded instance with the latest version from eCat?

I understand that interface or signal changes would still require manual intervention at the assembly level. My goal would mainly be to streamline simple geometry or property updates without having to re-save every assembly.

I made a quick example you could use a starting point if you want to explore that python add-on route. Add-on and some test models are in the following attachment:

UpdateComponents.zip (2.5 MB)

Place the add-on in “Documents\Visual Components\4.10\My Commands\Python 2” folder and launch the app. You should see “Update Components” button on home tab ribbon.

The way the add-on works is it assumes you have a layout built with some components. Then you have a folder where there are new versions of some of those components. VCID is used to map old versions to new versions. Have the layout open and launch the add-on. Copy-paste the folder path for new models to “ModelFolder” string property and click update. Add-on checks which components can be updated and then updates them by deleting the old version and loading in the new one. Add-on only checks the parent node and position matrix in the replacement process. If you have interface connections, signal connections etc. you need to extend the python logic to reconnect all of those for the updated component.

Here’s a video for details:

-k

1 Like

@keke Thank you, this is great. I think I’ll embed this logic into my parent component so it loads the newest version of any children when imported.

1 Like