SUAPI-CppWrapper
C++WrapperforSketchUpCAPI
|
================
SketchUp C API is made for the C programming language:
For C++ programmers, the non-object-orientated nature of the C API means simple operations for retrieving objects through is time consuming. This project provides a wrapper class for every SketchUp C API object that considerably shortens the amount of code required to perform simple tasks.
For example, to get an array of faces from an entities object, you could write this:
With the C++ Wrapper, to achieve the above, you just need to write this:
Added to this benefit, the wrapper classes have helper functions to help with geometric manipulations, much in the style of the SketchUp Ruby API
The project is documented in Doxygen, accessible here: https://tommykaneko.github.io/Sketchup-API-C-Wrapper/html
Navigate to the Sketchup-API-C-Wrapper project folder in Terminal and perform these commands:
If you get an error, it's probably because you haven't fetched the googletests submodules, so do this and try again:
The project uses GoogleTest for unit testing. It's included as a submodule so make sure to also initialize those when checking out the project.
The tests are located under /tests/
. One file per testcase. One testcase per class being tested.
Keep tests small, keep their name descriptive.
Alternativly you can use the Google Test Adapter extension which provides overview of the tests from the UI. Makes it easy to run induvidual tests.
Coming soon.
The aims of this set of wrapper classes are:
Each C++ Wrapper class object holds its equivalent C API class object as a member variable (ie - CW::Face holds SUFaceRef). Further variables should be kept to a minimum, if at all.
With the use of the C++ Wrapper, the SketchUp API should "feel" like a native C++ API. This means the idea of "releasing" objects that are not attached to a model object, for example, should not have to be considered by the programmer. Instead, the wrapper class will deal with releasing of an object when the object goes out of scope.
The only exception to this rule is if the wrapped object (CW::Face
, for example), is converted to a regular C object ( SUFaceRef
, for example), in which case it can be assumed that the programmer is taking charge of the C object and will be dealing with any releasing.
Method names take inspiration mostly from the SketchUp Ruby API. That said, these are not wholy consistent, and some liberties have been taken to make the method names make sense.