Saved views api

What is the api for exporting saved views to skp file?

A “saved view” in SketchUp terms are known as a Scene page (ie, SUSceneRef in the C API.)
Each scene is a member of the model’s scene pages collection, accessed with these functions:

The scene pages collection is saved out to the .skp file along with all the model’s other data.
You do not need to do anything special to have scenes saved.

Is the following code correct way to export saved views? Apparently we found that SUSceneSetCamera doesn’t set the camera correctly. It gives all orientation values as “0, 0, 0” if we retrieve it back immediately after setting them as shown in the code below. If model’s camera is already set with SUModelSetCamera then it gives those values on retrieving scene’s camera… Are we missing something in the code?

SUCameraRef camera = SU_INVALID;
SUSceneRef scene = SU_INVALID;
if (SU_ERROR_NONE == SUCameraCreate (&camera) && camera.ptr)

    SUPoint3D position = ConvertPoint (&eye);
    SUPoint3D newTarget = ConvertPoint (&target);
    SUVector3D up_vector = ConvertVector (&up);

    SU_CALL(SUCameraSetOrientation (camera, &position, &newTarget, &up_vector));
    SU_CALL(SUCameraSetPerspective (camera,;

    if (
        SUCameraSetPerspectiveFrustumFOV (camera, fieldOfView);
        SUCameraSetOrthographicFrustumHeight (camera, height);

    if (pName && SU_ERROR_NONE == SUSceneCreate (&scene) && scene.ptr)
        SUSceneSetName (scene, Utf8String (pName).c_str());
        SUSceneSetCamera (scene, camera);
        SUSceneSetUseCamera (scene, true);
        SUModelAddScene (m_pDocument, -1, scene, &out_index);
        //orientation values below come out as whatever is set by SUModelSetCamera 
        or they come out as 0, 0, 0 if SUModelSetCamera is not run before
        SUCameraRef cam;
        SUSceneGetCamera(scene, &cam);
        SUCameraGetOrientation(cam, &position1, &targetPt, &upVector);
        SUModelSetCamera (m_pDocument, &camera);


Help people help you: [How to] Post correctly formatted and colorized code on the forum? - Developers - SketchUp Community

1 Like

Your snippet omits quite a few variable initializations and I also do not see it initializing and unloading the C API.

Again, you are not exporting. You are creating scene pages within the model file.

The scene properties need to be set to save the camera position (same as in the SketchUp application or using the Ruby API.)

The scene page property flags are listed on doc page:
SketchUp C API: SketchUpAPI/model/scene.h File Reference

I see that you did use the SUSceneSetUseCamera() which is analogous to checking the “Camera Location” box in the SketchUp GUI’s Scenes panel.

After making changes in the application (or using the Ruby API) we must update the scene. I will guess here that in the C API this might be the SUSceneSetFlags() function.

The only other thing I could suggest is to add the scene object to the model before trying to set it’s camera properties. If you read the description of SUSceneSetCamera it implies that the properties are copied from the camera argument to the scene’s camera object.

How can this copy be done if the scene has not yet been added to the model ?

I also wonder if checking the return from SUSceneSetCamera when the scene has not yet been added to the model will show an error ? (Your code does not check the return value.)