Definition from file in C API

Is there a way to create a SUComponentDefinitionRef from a *.skp file? Or add a definition to a SUModelRef from a file? Or even create a SUComponentDefinitionRef from a SUModelRef?

Something similar to model.definitions.load(path) in the Ruby API.

1 Like

Did not see the comments on this one, thanks Dan.

1 Like

I’ve recently started working with the SketchUp C API and the need of creating a SUComponentDefinitionRef from a skp file just came up. I found this question and tracking the issue I’ve seen it’s still open. Did you find any temporary solution to address it in the meantime?

We ended up having to load the .skp as a separate model, and copy its whole content in a new definition in the original model. Quite cumbersome…

But since then, SUModelLoadDefinition has been added in 2019.2. You should use that :slight_smile:

3 Likes

Will do, thanks @jiminybillybob!

I managed to make this work, but now I’m guessing how to do the opposite operantion, i.e. saving a definition to a file, in the same way as the save_as method in the Ruby API.

I loaded the definition into a new empty model, converted it to an Entity, changed some attributes and reconverted it to a new Component Definition. I checked that everything went well, but I don’t know how to save this definition to a file, other than saving the whole model with the definition inside. Is it possible at all?

Nevermind, I can work with SUComponentInstanceSaveAs in the meantime. :+1:

Just beware that to modified the instance and definition you are exporting.