Export individual component to another file format


#1

Hello All,

I’d like to export individual components in SketchUp to another file format. However the #export method is only defined on the Model class. The ComponentDefinition#save_as method on the other hand appears to only support the .skp format.

Is it possible to do this at all in the Ruby API, or would I need to use the C API to load an exported SketchUp file and export it to another format?


#2

Sledgehammer way…

Start an operation.
Delete everything in the model.
Place an instance of the desired component definition at the ORIGIN.
Perhaps zoom extents.
Depending on the exported file format, you might also want to purge unused materials, layers, definitions - e.g. in DXF/DWG, but it’s perhaps not strictly necessary in some others ?
Now Export the model in the desired file format [using the definition’s name for the exported file].
Only the instance [with its materials and layers] get included in the new file.
Abort the operation.
The model is now unchanged, but the exported file stands.


#3

Since SU2018 exporters options are exposed, some support :selectionset_only option, allowing you to select what you want to export.