SketchUp C API

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Macros | Functions
ruby_api.h File Reference

Interfaces for exchanging data between SketchUp's Ruby API and C API. More...

`#include <SketchUpAPI/common.h>`
`#include <SketchUpAPI/model/defs.h>`

## Macros
#define | RUBY_VALUE
| This macro is defining a type matching Ruby's own `VALUE` type and can be used interchangeably.

## Functions
enum SUResult | SUEntityToRuby (SUEntityRef entity, RUBY_VALUE *ruby_entity)
| Converts a C API entity to a Ruby API entity. More...
enum SUResult | SUEntityFromRuby (RUBY_VALUE ruby_entity, SUEntityRef *entity)
| Converts a Ruby API entity to a C API entity. More...
enum SUResult | SUImageRepToRuby (SUImageRepRef imagerep, RUBY_VALUE *ruby_imagerep)
| Converts a C API entity to a Ruby API imagerep. More...
enum SUResult | SUImageRepFromRuby (RUBY_VALUE ruby_imagerep, SUImageRepRef *imagerep)
| Converts a Ruby API imagerep to a C API imagerep. More...

## Detailed Description

Interfaces for exchanging data between SketchUp's Ruby API and C API.

Note
  This is for use only within the SketchUp application.

## Function Documentation

enum SUResult SUEntityFromRuby | ( | RUBY_VALUE | ruby_entity,
|  | SUEntityRef * | entity
| ) |  |

Converts a Ruby API entity to a C API entity.

Since
  SketchUp 2020.2, API 8.2

Parameters

  [in] | ruby_entity | The Ruby API entity reference.
  [out] | entity | The retrieved C API entity reference.

See Also
  SUModelRef

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_ARGUMENT if `ruby_entity` refers to a deleted entity
  - SU_ERROR_INVALID_ARGUMENT if `ruby_entity` is not an entity type
  - SU_ERROR_NULL_POINTER_OUTPUT if `entity` is `NULL`
  - SU_ERROR_OVERWRITE_VALID if `entity` is already a valid reference
  - SU_ERROR_NO_DATA if this isn't called from within SketchUp

enum SUResult SUEntityToRuby | ( | SUEntityRef | entity,
|  | RUBY_VALUE * | ruby_entity
| ) |  |

Converts a C API entity to a Ruby API entity.

Since
  SketchUp 2020.2, API 8.2

Parameters

  [in] | entity | The C API entity reference.
  [out] | ruby_entity | The retrieved Ruby API entity reference.

See Also
  SUModelRef

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if `entity` is an invalid object
  - SU_ERROR_INVALID_ARGUMENT if `entity` is not owned by a model
  - SU_ERROR_NULL_POINTER_OUTPUT if `ruby_entity` is `NULL`
  - SU_ERROR_NO_DATA if this isn't called from within SketchUp

enum SUResult SUImageRepFromRuby | ( | RUBY_VALUE | ruby_imagerep,
|  | SUImageRepRef * | imagerep
| ) |  |

Converts a Ruby API imagerep to a C API imagerep.

Note
  Ruby retains the ownership of the object it should not be released by SUImageRepRelease.

Warning
  The returned C API reference points to an object that is owned by the Ruby runtime and it may be garbage collected. To avoid this, ensure that the Ruby API reference has a longer lifetime than the C API reference.

Since
  SketchUp 2020.2, API 8.2

Parameters

  [in] | ruby_imagerep | The Ruby API imagerep reference.
  [out] | imagerep | The retrieved C API imagerep reference.

See Also
  SUModelRef

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_ARGUMENT if `ruby_imagerep` is not an imagerep type
  - SU_ERROR_NULL_POINTER_OUTPUT if `imagerep` is `NULL`
  - SU_ERROR_OVERWRITE_VALID if `imagerep` is already a valid reference
  - SU_ERROR_NO_DATA if this isn't called from within SketchUp

enum SUResult SUImageRepToRuby | ( | SUImageRepRef | imagerep,
|  | RUBY_VALUE * | ruby_imagerep
| ) |  |

Converts a C API entity to a Ruby API imagerep.

Note
  Ruby takes ownership of the object it should not be released by SUImageRepRelease. It will be released when Ruby garbage collects the Ruby references to it.

Since
  SketchUp 2020.2, API 8.2

Parameters

  [in] | imagerep | The C API imagerep reference.
  [out] | ruby_imagerep | The retrieved Ruby API imagerep reference.

See Also
  SUModelRef

Returns
  - SU_ERROR_NONE on success
  - SU_ERROR_INVALID_INPUT if `imagerep` is an invalid object
  - SU_ERROR_NULL_POINTER_OUTPUT if `ruby_imagerep` is `NULL`
  - SU_ERROR_NO_DATA if this isn't called from within SketchUp