Is there a way to properly save a ComponentDefinition to an .SKP file?

Hi All,

I have been struggling with this for a while now. I’m trying to recreate the Save Local Collection functionality as found in SketchUp in my own code using the C SDK. As far as I can tell there is no function to directly save a ComponentDefinition. Creating an instance and saving that results an extra level of nesting in the saved SKP file.

Is there any way I can take a ComponentDefinition and save that to a file?

Thanks in advance for your suggestions!

I don’t know the C API, but I remember reading something like that somewhere … maybe you can check it out here:

Thanks, I had already combed through the issue tracker, but couldn’t find a usable solution there.

Not currently as it is missing from the C API:

Yes, and worse, … it is bugged:

I am sorry but there is no workaround that I can come up with. We might have (been able to kludge a end around) if the C API had an explode function, but it does not.

This issue is at least 4 years old now, and IMO is the worst glaring C API omission and bug outstanding.

Completely recreating all the definition’s entities within a new model is likely to be quite tedious codewise.

I might also suggest you build your component’s entities in a separate model object and save them out to a component file(s) and later load them with SUModelLoadDefinition, rather than building them within a model’s definition collection.

Thanks Dan, for your detailed reply (as usual :slight_smile: ).

I have been searching for an explode function and couldn’t find anything like it. So your confirmation is both good to hear and a bit disappointing.

The two issues in the tracker had caught my eye as well; I was hoping to create something of my own that would mimic a SUComponentDefinitionSaveAs, but the C SDK is not complete enough to do so.

I even ventured into completely recreating the definitions entities, but that led to more problems than it solved. It can probably be done but is - as you put it - tedious so say the least. Testing it fully would also be a slight challenge.

In my current application the source for my component definitions is user created, so I don’t create the definitions myself, but I do need to same them to file individually. This lack of control over the content and quality of the definitions makes recreating them a gamble.

There is also no means via the C API to copy objects from one entities collection to another. (Also any supplied removal functions immediately invalidate the removed objects so they cannot subsequently be reused.)

All I can suggest is to add your desires and needs to the open issue(s) so as to supply a little “grease to the squeaky wheel”.