Load Component From another file

I am try to find out the function, that allowed to load Component from another model in C API.

I have a set of file with some components, which I need, but when I try to use this components in base model - it is doesn’t work.
In the Ruby API it possible by using Sketchup::DefinitionList#load.

I found topic with same problem, but there is no solution.

Maybe is there another bypass way to use a component in two models?

The only way is to save the component to file and load that component in another file. Any attempt to share entities between models will either result in crashes or corrupted models.

Unfortunately we don’t have SUComponentDefinitionSaveFile - that is on our list to include in a future release.

Meanwhile you can use SUComponentInstanceSaveAs. But beware - this function has some unexpected side-behaviours: it bakes the instance transformation into the definition transformation. It also makes that instance unique.

See open issues:

So I would suggest you use SUComponentInstanceSaveAs on a model which you don’t need to save afterward. And you might want to reset the instance transformation in order to save the definition without the instance transformation applied.

1 Like

Hi, Thomas

Can you please consistently describe the functions, which I should use.

If you offer to save a component in file, and after that open it as a base model - it doesn’t fit to me, because I need to load several components in my model.
Or I misunderstood.
Thank you.

From your source model, use SUComponentInstanceSaveAs to export the components you need to “copy” (but remember what I mentioned about the instance transformation when using SUComponentInstanceSaveAs). Then in the target model use SUModelLoadDefinition to load the exported components as new definitions.

Perhaps, SUModelLoadDefinition appeared recently.
I found it in Online Documentation, but can’t find in downloaded API.

Where can I download a newest version API?

https://extensions.sketchup.com/sketchup-sdk
This link contains SDK_WIN_x64_2019-0-753 version.

Hmm. Looks like this is an error in the new extension warehouse. It should return the latest version I believe. @ChrisFullmer is this an error?

1 Like

Ackh! We’ll get that fixed (again) ASAP!

1 Like

Got it. The link has been updated. Thank you so much

2 Likes