A few questions regarding the SketchUp C SDK

I have a few questions regarding the SketchUp C SDK

  1. I can’t find a SUTypedValueGetShort(…) or SUTypedValueSetShort(…) why?
    Can I use another function, if so what should I use?

  2. I can’t find a function to save a component to a file similar the the Save As… feature on the component context menu.
    How can I do this with the SDK?

  3. How can I change the Loaded From property of a component with the SDK?

Thanks in advance for any advice offered.

I would think you can use one of the integer types. There is:
… and …
… along with their setter functions.

Unfortunately, the component save feature in the C API is bugged and we filed an issue in the API Issue Tracker (see below.) What is really needed is a SUComponentDefinitionSaveAs function that works the same as the Ruby API Sketchup::ComponentDefinition#save_as method.

(If you are using the C SDK from within a “live” SketchUp application instance, then you may be able to call the Ruby method from C.)

There is no current way in either the Ruby or C APIs to do this.

You will need to use SUModelLoadDefinition to load the replacement definition, then get and save any properties you need to clone the instance (foremost the instance’s transform, but also perhaps it material and attribute dictionaries,) and then create a new instance at the same location using the properties you saved from the old instance.
You might also need to copy some of the old definition’s behaviors to the new definition.
Lastly, you would remove the old instance, and perhaps the old definition if it no longer has any instances in the model (or other component’s entities.)

Christina logged a feature request issue for both APIs …

1 Like

Dan, thank you for your detailed reply. I look forward to the requested new features/bugs being fixed.
In the meantime I will try your suggestions and see if I can do a work around.

Thanks again.

1 Like