### SUGuideLineCreateFinite Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_guide_line_ref.html Creates a finite guide line object defined by start and end points. ```APIDOC ## SUGuideLineCreateFinite ### Description Creates a finite guide line object. The guide line object must be subsequently deallocated with SUGuideLineRelease() unless it is associated with a parent object. ### Signature enum SUResult SUGuideLineCreateFinite(SUGuideLineRef *guide_line, const struct SUPoint3D *start, const struct SUPoint3D *end) ``` -------------------------------- ### SUGuideLineGetData Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_guide_line_ref.html Retrieves the data defining the guide line. ```APIDOC ## SUGuideLineGetData ### Description Retrieves the data defining the line (a point, a direction vector, and a boolean flagging if the line is infinite). ### Signature enum SUResult SUGuideLineGetData(SUGuideLineRef guide_line, struct SUPoint3D *start, struct SUVector3D *direction, bool *is_infinite) ``` -------------------------------- ### SURenderingOptionsGetNumKeys Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_rendering_options_ref.html Gets the number of available rendering options keys. ```APIDOC ## SURenderingOptionsGetNumKeys ### Description Gets the total number of available keys within a rendering options object. ### Parameters - **rendering_options** (SURenderingOptionsRef) - Input - The rendering options object. - **count** (size_t*) - Output - The number of keys available. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if rendering_options is not valid - SU_ERROR_NULL_POINTER_OUTPUT if count is NULL ``` -------------------------------- ### SUOptionsProviderGetNumKeys Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_options_provider_ref.html Gets the number of available option keys. ```APIDOC ## SUOptionsProviderGetNumKeys ### Description Gets the number of available option keys. ### Parameters - **options_provider** (SUOptionsProviderRef) - The options provider object. - **count** (size_t*) - The number of keys available. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if options_provider is not valid - SU_ERROR_NULL_POINTER_OUTPUT if count is NULL ``` -------------------------------- ### SUSnapToBehavior Usage Examples Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/component__definition__snap__to__behavior__private_8h.html Demonstrates how to access the snap behavior property in both C and C++ environments. ```c // Usage from a C compiler: SUSnapToBehavior behavior; SUComponentDefinitionSetBehavior(component_definition, &behavior); if (behavior.component_snap == SUSnapToBehavior_Vertical) { // ... } ``` ```cpp // Usage from a C++ compiler: SUSnapToBehavior behavior; SUComponentDefinitionSetBehavior(component_definition, &behavior); if (behavior.component_snap == SUComponentBehavior::SUSnapToBehavior_Vertical) { // ... } ``` -------------------------------- ### SUGuideLineCreateInfinite Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_guide_line_ref.html Creates an infinite guide line object defined by a point and a direction vector. ```APIDOC ## SUGuideLineCreateInfinite ### Description Creates an infinite guide line object. The guide line object must be subsequently deallocated with SUGuideLineRelease() unless it is associated with a parent object. ### Signature enum SUResult SUGuideLineCreateInfinite(SUGuideLineRef *guide_line, const struct SUPoint3D *point, const struct SUVector3D *direction) ``` -------------------------------- ### Set Dimension Start Point Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_dimension_linear_ref.html Demonstrates connecting a dimension to an arbitrary point, a vertex, or an edge using an instance path. ```cpp // Simple Example: Connect to an arbitrary position in space SUPoint3D point{ xposition, yposition, zposition}; SUDimensionLinearSetStartPoint(dimension, &point, SU_INVALID); // Vertex Example: Connect to vertex entity SUInstancePathRef path = SU_INVALID; SUInstancePathCreate(&path); SUInstancePathSetLeaf(path, SUVertexToEntity(vertex)); SUDimensionLinearSetStartPoint(dimension, NULL, path); // Edge Example: Connect to nearest point on an instance of an edge entity SUPoint3D point{ xposition, yposition, zposition}; SUInstancePathRef path = SU_INVALID; SUInstancePathCreate(&path); SUInstancePathPushInstance(path, instance); SUInstancePathSetLeaf(path, SUEdgeToEntity(edge)); SUDimensionLinearSetStartPoint(dimension, &point, path); ``` -------------------------------- ### SUInstancePathGetInstanceAtDepth Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_instance_path_ref.html Gets a component instance up to path depth level. ```APIDOC ## SUInstancePathGetInstanceAtDepth ### Description Gets a component instance up to path depth level. ### Parameters - **instance_path** (SUInstancePathRef) - [in] The instance path object. - **depth** (size_t) - [in] The depth for getting drawing element up to. - **instance** (SUComponentInstanceRef *) - [out] The component instance from instance path. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if instance_path is not a valid object - SU_ERROR_OUT_OF_RANGE if depth exceeds the depth of instance_path - SU_ERROR_NULL_POINTER_OUTPUT if instance is NULL ``` -------------------------------- ### SUGuidePointGetDisplayAsLine Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_guide_point_ref.html Checks if the guide point should be displayed as a line. ```APIDOC ## SUGuidePointGetDisplayAsLine ### Description Retrieves the boolean indicating if the point should be displayed as a line. ### Parameters - **guide_point** (SUGuidePointRef) - Required - The guide point object. - **as_line** (bool*) - Required - Pointer to store the boolean result. ``` -------------------------------- ### SUGuideLineRelease Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_guide_line_ref.html Releases a guide line object. ```APIDOC ## SUGuideLineRelease ### Description Releases a guide line object. The guide line object must have been created with SUGuideLineCreateFinite() or SUGuideLineCreateInfinite and not subsequently associated with a parent object. ### Signature enum SUResult SUGuideLineRelease(SUGuideLineRef *guide_line) ``` -------------------------------- ### SUDimensionLinearGetStartPoint Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_dimension_linear_ref.html Retrieves the start point of a dimension object. ```APIDOC ## SUDimensionLinearGetStartPoint ### Description Retrieves the start point of a dimension object. The given instance path object must be released using SUInstancePathRelease() when it is no longer needed. ### Signature enum SUResult SUDimensionLinearGetStartPoint(SUDimensionLinearRef dimension, struct SUPoint3D *point, SUInstancePathRef *path) ``` -------------------------------- ### SUEntitiesGetGuideLines Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_entities_ref.html Retrieves the guide lines in the entities object. ```APIDOC ## SUEntitiesGetGuideLines ### Description Retrieves the guide lines in the entities object. ### Parameters - **entities** (SUEntitiesRef) - Input - The entities object. - **len** (size_t) - Input - The number of guide lines to retrieve. - **guide_lines** (SUGuideLineRef[]) - Output - The guide_lines retrieved. - **count** (size_t*) - Output - The number of guide_lines retrieved. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if entities is not a valid object - SU_ERROR_NULL_POINTER_OUTPUT if guide_lines or count is NULL ``` -------------------------------- ### SUEdgeGetStartVertex Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_edge_ref.html Retrieves the starting vertex of an edge object. ```APIDOC ## SUEdgeGetStartVertex ### Description Retrieves the starting vertex of an edge object. ### Signature enum SUResult SUEdgeGetStartVertex(SUEdgeRef edge, SUVertexRef * vertex) ### Parameters - **edge** (SUEdgeRef) - Input - The edge object. - **vertex** (SUVertexRef *) - Output - The vertex object retrieved. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if edge is an invalid edge object - SU_ERROR_NULL_POINTER_OUTPUT if vertex is NULL ``` -------------------------------- ### SUGuidePointCreate Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_guide_point_ref.html Creates a new guide point object at the specified position. ```APIDOC ## SUGuidePointCreate ### Description Creates a guide point object. The guide point object must be subsequently deallocated with SUGuidePointRelease() unless it is associated with a parent object. ### Parameters - **guide_point** (SUGuidePointRef*) - Required - Pointer to the guide point object to be created. - **position** (const struct SUPoint3D*) - Required - The 3D position for the guide point. ``` -------------------------------- ### SUEdgeUseGetStartVertex Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_edge_use_ref.html Retrieves the start vertex of an EdgeUse object. ```APIDOC ## SUEdgeUseGetStartVertex ### Description Retrieves the start vertex of an EdgeUse object. The start vertex of the EdgeUse object may not be the same as the start vertex of the corresponding edge of the EdgeUse object. ### Parameters - **edgeuse** (SUEdgeUseRef) - [in] The EdgeUse object. - **vertex** (SUVertexRef*) - [out] The vertex object retrieved. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if edge is not a valid EdgeUse object - SU_ERROR_NULL_POINTER_OUTPUT if vertex is NULL ``` -------------------------------- ### SUEdgeUseGetStartVertex Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_edge_use_ref.html Retrieves the start vertex of an EdgeUse object. ```APIDOC enum SUResult SUEdgeUseGetStartVertex(SUEdgeUseRef edgeuse, SUVertexRef *vertex); ``` -------------------------------- ### SUDimensionLinearGetStartPoint Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_dimension_linear_ref.html Retrieves the start point and associated instance path of a dimension object. ```APIDOC ## SUDimensionLinearGetStartPoint ### Description Retrieves the start point of a dimension object. The instance path must be released using SUInstancePathRelease() when no longer needed. ### Parameters - **dimension** (SUDimensionLinearRef) - Input - The dimension object. - **point** (struct SUPoint3D*) - Output - The 3d point retrieved. - **path** (SUInstancePathRef*) - Output - The instance path retrieved. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if dimension is not a valid object - SU_ERROR_NULL_POINTER_OUTPUT if point or path are NULL ``` -------------------------------- ### SUDimensionLinearSetStartPoint Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_dimension_linear_ref.html Sets the start connection point of a dimension object. ```APIDOC ## SUDimensionLinearSetStartPoint ### Description Sets the start connection point of a dimension object. Connection points can be set to an arbitrary point in space or connected to an entity in the model using an SUInstancePathRef. ### Signature enum SUResult SUDimensionLinearSetStartPoint(SUDimensionLinearRef dimension, const struct SUPoint3D *point, SUInstancePathRef path) ``` -------------------------------- ### Create and Configure a Scene Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_scene_ref.html Demonstrates the workflow for creating a new scene, setting its name and flags, and adding it to a model. ```c SUScene scene = SU_INVALID; SUSceneCreate(&scene); SUSceneSetName(scene, "Example"); // Must be unique. SUSceneSetFlags(scene, FLAG_USE_ALL); // Set the properties to remember. SUModelAddScenes(model, 1, &scene); // This will also update the scene based on the flags set. // Set scene properties after adding it to the model. // ... SUSceneSetCamera(scene, eye, target, up); ``` -------------------------------- ### SUVector3DGetLength Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_vector3_d.html Gets the length of a vector. ```APIDOC ## SUVector3DGetLength ### Description Gets the length of a vector in inches. ### Parameters - **vector** (const struct SUVector3D*) - Required - The vector object. - **length** (double*) - Required - The output length. ### Returns - SU_ERROR_NONE on success - SU_ERROR_NULL_POINTER_INPUT if vector is NULL - SU_ERROR_NULL_POINTER_OUTPUT if length is NULL ``` -------------------------------- ### SULayerFolderGetLayers Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_layer_folder_ref.html Gets the layers that are in the layer_folder. ```APIDOC ## SULayerFolderGetLayers ### Description Gets the layers that are in the layer_folder. ### Parameters - **layer_folder** (SULayerFolderRef) - Required - The layer folder object. - **len** (size_t) - Required - The number of layers to retrieve. - **layers** (SULayerRef*) - Required - The retrieved layers. - **count** (size_t*) - Required - The total number of layers. ``` -------------------------------- ### SUVector3DAngleBetween Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_vector3_d.html Gets the angle between two vectors. ```APIDOC ## SUVector3DAngleBetween ### Description Calculates the angle between two given vectors. ### Parameters - **vector1** (const struct SUVector3D*) - Required - The first vector object. - **vector2** (const struct SUVector3D*) - Required - The second vector object. - **angle** (double*) - Required - The output angle between the vectors. ### Returns - SU_ERROR_NONE on success - SU_ERROR_NULL_POINTER_INPUT if vector1 or vector2 is NULL - SU_ERROR_NULL_POINTER_OUTPUT if angle is NULL ``` -------------------------------- ### SUGuidePointGetPosition Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_guide_point_ref.html Retrieves the current position of a guide point object. ```APIDOC ## SUGuidePointGetPosition ### Description Retrieves the position of a guide point object. ### Parameters - **guide_point** (SUGuidePointRef) - Required - The guide point object. - **position** (struct SUPoint3D*) - Required - Pointer to store the retrieved position. ``` -------------------------------- ### SUPlane3DIsOn Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_plane3_d.html Gets whether or not the point is on the plane. ```APIDOC ## SUPlane3DIsOn ### Description Gets whether or not the point is on the plane. ### Parameters - **plane** (const struct SUPlane3D *) - Input - The plane. - **point** (const struct SUPoint3D *) - Input - The 3D point. - **is_on** (bool *) - Output - Whether or not the point is on the plane. ### Returns - SU_ERROR_NONE on success - SU_ERROR_NULL_POINTER_INPUT if plane or point are NULL - SU_ERROR_NULL_POINTER_OUTPUT if is_on is NULL ``` -------------------------------- ### SUOptionsProviderGetValue Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_options_provider_ref.html Gets the value of the given option. ```APIDOC ## SUOptionsProviderGetValue ### Description Gets the value of the given option. ### Parameters - **options_provider** (SUOptionsProviderRef) - The options provider object. - **key** (const char*) - The key that indicates which option to get. - **value** (SUTypedValueRef*) - The value to get the current option setting. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if options_provider is not valid - SU_ERROR_NULL_POINTER_INPUT if key is NULL - SU_ERROR_NULL_POINTER_OUTPUT if value is NULL - SU_ERROR_INVALID_OUTPUT if value is invalid ``` -------------------------------- ### Read a SketchUp model from a file Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/index.html Demonstrates loading a .skp file, iterating through entities to access face and edge geometry, and retrieving model metadata. ```cpp #include #include #include #include #include #include #include #include #include #include int main() { // Always initialize the API before using it SUInitialize(); // Load the model from a file SUModelRef model = SU_INVALID; SUModelLoadStatus status; SUResult res = SUModelCreateFromFileWithStatus(&model, "model.skp", &status); // It's best to always check the return code from each SU function call. // Only showing this check once to keep this example short. if (res != SU_ERROR_NONE) { std::cout << "Failed creating model from a file" << std::endl; return 1; } if (status == SUModelLoadStatus_Success_MoreRecent) { std::cout << "This model was created in a more recent SketchUp version than that of the SDK. " "It contains data which will not be read. Saving the model over the original file may " "lead to permanent data loss." << std::endl; } // Get the entity container of the model. SUEntitiesRef entities = SU_INVALID; SUModelGetEntities(model, &entities); // Get all the faces from the entities object size_t faceCount = 0; SUEntitiesGetNumFaces(entities, &faceCount); if (faceCount > 0) { std::vector faces(faceCount); SUEntitiesGetFaces(entities, faceCount, &faces[0], &faceCount); // Get all the edges in this face for (size_t i = 0; i < faceCount; i++) { size_t edgeCount = 0; SUFaceGetNumEdges(faces[i], &edgeCount); if (edgeCount > 0) { std::vector edges(edgeCount); SUFaceGetEdges(faces[i], edgeCount, &edges[0], &edgeCount); // Get the vertex positions for each edge for (size_t j = 0; j < edgeCount; j++) { SUVertexRef startVertex = SU_INVALID; SUVertexRef endVertex = SU_INVALID; SUEdgeGetStartVertex(edges[j], &startVertex); SUEdgeGetEndVertex(edges[j], &endVertex); SUPoint3D start; SUPoint3D end; SUVertexGetPosition(startVertex, &start); SUVertexGetPosition(endVertex, &end); // Now do something with the point data } } } } // Get model name SUStringRef name = SU_INVALID; SUStringCreate(&name); SUModelGetName(model, &name); size_t name_length = 0; SUStringGetUTF8Length(name, &name_length); char* name_utf8 = new char[name_length + 1]; SUStringGetUTF8(name, name_length + 1, name_utf8, &name_length); // Now we have the name in a form we can use SUStringRelease(&name); delete []name_utf8; // Must release the model or there will be memory leaks SUModelRelease(&model); // Always terminate the API when done using it SUTerminate(); return 0; } ``` -------------------------------- ### SULayerGetLineStyle Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_layer_ref.html Get the line style of a layer. ```APIDOC ## SULayerGetLineStyle ### Description Get the line style of a layer. ### Signature enum SUResult SULayerGetLineStyle(SULayerRef layer, SULineStyleRef * line_style) ### Parameters - **layer** (SULayerRef) - [in] The layer object. - **line_style** (SULineStyleRef *) - [out] The line style reference. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if layer is not a valid object - SU_ERROR_NULL_POINTER_OUTPUT if line_style is NULL - SU_ERROR_NO_DATA if the layer has no custom line style. ``` -------------------------------- ### SUModelCreateFromFileWithStatus Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_model_ref.html Creates a model from a SketchUp file on local disk. The resulting model object must be released with SUModelRelease(). ```APIDOC ## SUModelCreateFromFileWithStatus ### Description Creates a model from a SketchUp file on local disk. This model object must be released with SUModelRelease(). ### Parameters - **model** (SUModelRef*) - [out] - The model object created. - **file_path** (const char*) - [in] - The source file path of the SketchUp file. Assumed to be UTF-8 encoded. - **status** (enum SUModelLoadStatus*) - [out] - Returns additional information on the status of a successful operation. ### Returns - SU_ERROR_NONE on success - SU_ERROR_NULL_POINTER_INPUT if file_path is NULL - SU_ERROR_NULL_POINTER_OUTPUT if model or status is NULL - SU_ERROR_OVERWRITE_VALID if model is already a valid object - SU_ERROR_SERIALIZATION if an error occurs during reading - SU_ERROR_MODEL_INVALID if the file is an invalid model - SU_ERROR_MODEL_VERSION if the model version is newer than supported ``` -------------------------------- ### SUOptionsProviderGetNumKeys Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_options_provider_ref.html Gets the number of available option keys for the given options provider. ```APIDOC ## SUOptionsProviderGetNumKeys ### Description Gets the number of available option keys. ### Signature SUResult SUOptionsProviderGetNumKeys(SUOptionsProviderRef options_provider, size_t *count) ``` -------------------------------- ### SUEnvironmentCreateFromFile Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_environment_ref.html Creates an environment object from an SKE, HDR, or EXR file. ```APIDOC ## SUEnvironmentCreateFromFile ### Description Creates an environment object from an SKE, HDR, or EXR file. The image or SKE file will be loaded into the environment's skydome as a cubemap. ### Parameters - **environment** (SUEnvironmentRef*) - Out - The created environment object. - **file_path** (const char*) - In - The path to the SKE, HDR, or EXR file. - **name** (const char*) - In - The name of the environment. ### Returns - SU_ERROR_NONE on success - SU_ERROR_OVERWRITE_VALID if environment already references a valid object - SU_ERROR_NULL_POINTER_INPUT if file_path, name, or environment is NULL - SU_ERROR_INVALID_ARGUMENT if file_path is an empty string - SU_ERROR_SERIALIZATION if the environment could not be created ``` -------------------------------- ### SUStyleGetGuid Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_styles_ref.html Retrieves the GUID of a style object. ```APIDOC ## SUStyleGetGuid ### Description Retrieves the GUID of a style object. ### Signature `enum SUResult SUStyleGetGuid(SUStyleRef style, SUStringRef *guid)` ### Parameters - **style** (SUStyleRef) - [in] The style object. - **guid** (SUStringRef*) - [out] The GUID retrieved. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if style is not a valid object - SU_ERROR_NULL_POINTER_OUTPUT if guid is NULL ``` -------------------------------- ### SUStyleCreate Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_styles_ref.html Creates an empty style object. ```APIDOC ## SUStyleCreate ### Description Creates an empty style object. ### Signature enum SUResult SUStyleCreate(SUStyleRef *style) ``` -------------------------------- ### SUStyleGetGuid Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_styles_ref.html Retrieves the GUID of a style object. ```APIDOC ## SUStyleGetGuid ### Description Retrieves the GUID of a style object. ### Signature enum SUResult SUStyleGetGuid(SUStyleRef style, SUStringRef *guid) ``` -------------------------------- ### SUStyleCreate Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_styles_ref.html Creates an empty style object. ```APIDOC ## SUStyleCreate ### Description Creates an empty style object. ### Signature `enum SUResult SUStyleCreate(SUStyleRef *style)` ### Parameters - **style** (SUStyleRef*) - [out] The style object. ### Returns - SU_ERROR_NONE on success - SU_ERROR_NULL_POINTER_OUTPUT if style is NULL - SU_ERROR_OVERWRITE_VALID if *style already refers to a valid object ``` -------------------------------- ### Write a SketchUp model to a file Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/index.html Demonstrates creating a new model, defining geometry using SULoopInput, and saving the result. Note that geometry is not automatically merged when added via SUEntitiesAddFaces; use SUEntitiesFill for complex geometry. ```cpp #include #include #include #include #include #include #include #include #include int main() { // Always initialize the API before using it SUInitialize(); // Create an empty model SUModelRef model = SU_INVALID; SUResult res = SUModelCreate(&model); // It's best to always check the return code from each SU function call. // Only showing this check once to keep this example short. if (res != SU_ERROR_NONE) return 1; // Get the entity container of the model SUEntitiesRef entities = SU_INVALID; SUModelGetEntities(model, &entities); // Create a loop input describing the vertex ordering for a face's outer loop SULoopInputRef outer_loop = SU_INVALID; SULoopInputCreate(&outer_loop); for (size_t i = 0; i < 4; ++i) { SULoopInputAddVertexIndex(outer_loop, i); } // Create the face SUFaceRef face = SU_INVALID; SUPoint3D vertices[4] = { { 0, 0, 0 }, { 100, 100, 0 }, { 100, 100, 100 }, { 0, 0, 100 } }; SUFaceCreate(&face, vertices, &outer_loop); // Add the face to the entities SUEntitiesAddFaces(entities, 1, &face); // Save the in-memory model to a file SUModelSaveToFile(model, "new_model.skp"); // Must release the model or there will be memory leaks SUModelRelease(&model); // Always terminate the API when done using it SUTerminate(); return 0; } ``` -------------------------------- ### SUTransformation2DIsIdentity Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_transformation2_d.html Gets whether the transformation is an identity transformation. ```APIDOC ## SUTransformation2DIsIdentity ### Description Gets whether the transformation is an identity transformation. ### Parameters - **transform** (const struct SUTransformation2D *) - Input - The transformation object. - **is_identity** (bool *) - Output - Whether the transformation is identity. ### Returns - SU_ERROR_NONE on success - SU_ERROR_NULL_POINTER_INPUT if transform is NULL - SU_ERROR_NULL_POINTER_OUTPUT if is_identity is NULL ``` -------------------------------- ### SUSelectionGetNumElements Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_selection_ref.html Gets the number of items in the selection set. ```APIDOC ## SUSelectionGetNumElements ### Description Gets the number of items in the selection set. ### Parameters - **selection** (SUSelectionRef) - The selection object. - **num_elements** (size_t*) - The number of items in the selection set. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if selection is not a valid object - SU_ERROR_NULL_POINTER_OUTPUT if num_elements is NULL ``` -------------------------------- ### SUPlane3DGetPosition Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_plane3_d.html Gets the position on the plane closest to the origin. ```APIDOC ## SUPlane3DGetPosition ### Description Gets the position on the plane closest to the origin. ### Parameters - **plane** (const struct SUPlane3D *) - Input - The plane from which to get the position. - **position** (struct SUPoint3D *) - Output - The 3D point struct retrieved. ### Returns - SU_ERROR_NONE on success - SU_ERROR_NULL_POINTER_INPUT if plane is NULL - SU_ERROR_NULL_POINTER_OUTPUT if position is NULL ``` -------------------------------- ### Initialize and validate API references Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/common_8h.html Macros for managing and checking the validity of API object references. ```c SUStringRef str = SU_INVALID; if (SUIsValid(result)) return true; if (SUIsInvalid(result)) return false; ``` -------------------------------- ### Implementing Progress Feedback in an Importer Plugin Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/class_sketch_up_plugin_progress_callback.html Demonstrates the main loop of an importer plugin using the progress callback to update status, increment steps, and check for user cancellation. ```cpp progress_callback->SetProgressMessage("Importing 50 things!"); progress_callback->SetStepSize(1.0); for (int steps = 0; steps < 50; ++steps) { progress_callback->Step(); // Do something which builds an skp model if (progress_callback->HasBeenCancelled()) { // Clean up and return return false; } } progress_callback->SetProgressMessage("We're half way there!"); // Do some more larger steps progress_callback->SetPercentDone(75.0); progress_callback->SetProgressMessage("Finishing up!"); // And some more progress_callback->SetPercentDone(100.0); // Success! return true; ``` -------------------------------- ### SUOptionsProviderGetValue Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_options_provider_ref.html Gets the value of a specific option key. ```APIDOC ## SUOptionsProviderGetValue ### Description Gets the value of the given option. ### Signature SUResult SUOptionsProviderGetValue(SUOptionsProviderRef options_provider, const char *key, SUTypedValueRef *value) ``` -------------------------------- ### SUModelCreateFromFile Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_model_ref.html Creates a model from a SketchUp file on local disk. This model object must be released with SUModelRelease(). ```APIDOC ## SUModelCreateFromFile ### Description Creates a model from a SketchUp file on local disk. This model object must be released with SUModelRelease(). ### Signature enum SUResult SUModelCreateFromFile(SUModelRef *model, const char *file_path) ``` -------------------------------- ### SUSceneCreate Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_scene_ref.html Creates an empty scene object. ```APIDOC ## SUSceneCreate ### Description Creates an empty scene object. The created scene will not save any scene properties until the SUSceneFlags bits are set. ### Parameters - **scene** (SUSceneRef*) - Required - The scene object created. ### Returns - SU_ERROR_NONE on success - SU_ERROR_NULL_POINTER_INPUT if scene is NULL - SU_ERROR_OVERWRITE_VALID if face already refers to a valid object ``` -------------------------------- ### SUComponentDefinitionGetLoadTime Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_component_definition_ref.html Gets the load time of the component definition. ```APIDOC ## SUComponentDefinitionGetLoadTime ### Description Gets the load time of the component definition. For an internal component definition, this is the time that it was created. For an external component definition, this is the time that it was added to the model. ### Signature enum SUResult SUComponentDefinitionGetLoadTime (SUComponentDefinitionRef comp_def, struct tm *load_time) ``` -------------------------------- ### SUStylesGetStyleByGuid Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_styles_ref.html Retrieves the style corresponding to the specified Guid. ```APIDOC ## SUStylesGetStyleByGuid ### Description Retrieves the style corresponding to the specified Guid. ### Parameters - **styles** (SUStylesRef) - Input - The styles object. - **guid** (const char*) - Input - The string specifying a style by Guid. - **style** (SUStyleRef*) - Output - Pointer to a SUStyleRef for returning the style. ``` -------------------------------- ### SURenderingOptionsGetKeys Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_rendering_options_ref.html Retrieves keys associated with the rendering options object. ```APIDOC ## SURenderingOptionsGetKeys ### Description Retrieves the keys associated with the rendering options object. ### Parameters - **rendering_options** (SURenderingOptionsRef) - Input - The rendering options object. - **len** (size_t) - Input - The number of keys to retrieve. - **keys** (SUStringRef[]) - Output - The keys retrieved. - **count** (size_t*) - Output - The number of keys retrieved. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if rendering_options is not a valid object - SU_ERROR_NULL_POINTER_OUTPUT if keys or count is NULL - SU_ERROR_INVALID_OUTPUT if any of the strings in the keys array are invalid. ``` -------------------------------- ### SUStylesGetStyleByGuid Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_styles_ref.html Retrieves the style corresponding to the specified Guid. ```APIDOC ## SUStylesGetStyleByGuid ### Description Retrieves the style corresponding to the specified Guid. ### Signature enum SUResult SUStylesGetStyleByGuid(SUStylesRef styles, const char *guid, SUStyleRef *style) ``` -------------------------------- ### SUMeshHelperCreateWithUVHelper Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_mesh_helper_ref.html Creates a tessellated polygon mesh object from a face and a UV helper. ```APIDOC ## SUMeshHelperCreateWithUVHelper ### Description Creates a tessellated polygon mesh object from a face and a UV helper associated with the face. ### Parameters - **mesh_ref** (SUMeshHelperRef*) - Output - The mesh object created. - **face_ref** (SUFaceRef) - Input - The face object. - **uv_helper_ref** (SUUVHelperRef) - Input - The UV helper object. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if face_ref or uv_helper_ref is not a valid object - SU_ERROR_NULL_POINTER_OUTPUT if mesh_ref is NULL - SU_ERROR_OVERWRITE_VALID if mesh_ref already references a valid object ``` -------------------------------- ### SUModelCreateFromBufferWithStatus Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_model_ref.html Creates a model from a SketchUp skp file buffer, providing status information regarding version compatibility. ```APIDOC ## SUModelCreateFromBufferWithStatus ### Description Creates a model from a SketchUp skp file buffer. This model object must be released with SUModelRelease(). Use the status value to check if the file was created with a newer version of SketchUp. ### Parameters - **model** (SUModelRef*) - [out] - The model object created. - **buffer** (const unsigned char*) - [in] - The SketchUp file buffer. - **buffer_size** (size_t) - [in] - The SketchUp file buffer size. - **status** (enum SUModelLoadStatus*) - [out] - Returns additional information on the status of a successful operation. ### Returns - SU_ERROR_NONE on success - SU_ERROR_NULL_POINTER_INPUT if buffer is NULL - SU_ERROR_NULL_POINTER_OUTPUT if model or status is NULL - SU_ERROR_OVERWRITE_VALID if model is already a valid object - SU_ERROR_SERIALIZATION if an error occurs during reading of the file - SU_ERROR_MODEL_INVALID if the file specified by buffer is an invalid model. - SU_ERROR_MODEL_VERSION if the model buffer has a newer version than is supported by the current build of the SDK. ``` -------------------------------- ### SUEntitiesGetGuidePoints Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_entities_ref.html Retrieves the guide points in the entities object. ```APIDOC ## SUEntitiesGetGuidePoints ### Description Retrieves the guide points in the entities object. ### Parameters - **entities** (SUEntitiesRef) - Input - The entities object. - **len** (size_t) - Input - The number of guide points to retrieve. - **guide_points** (SUGuidePointRef[]) - Output - The guide_points retrieved. - **count** (size_t*) - Output - The number of guide_points retrieved. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if entities is not a valid object - SU_ERROR_NULL_POINTER_OUTPUT if guide_points or count is NULL ``` -------------------------------- ### SketchUp C API Functions (p) Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/functions_func_0x70.html A list of available C API functions for SketchUp starting with 'p', covering geometric primitives and polyline entities. ```APIDOC ## SketchUp C API Functions (p) ### Plane3D Functions - SUPlane3DDistanceTo() - SUPlane3DGetNormal() - SUPlane3DGetPosition() - SUPlane3DIsOn() - SUPlane3DProjectTo() - SUPlane3DSetWithCoefficients() - SUPlane3DSetWithPointAndNormal() - SUPlane3DSetWithPoints() - SUPlane3DTransform() ### Point2D Functions - SUPoint2DDistanceToSUPoint2D() - SUPoint2DGetEqual() - SUPoint2DOffset() - SUPoint2DToSUPoint2D() - SUPoint2DTransform() ### Point3D Functions - SUPoint3DDistanceToSUPoint3D() - SUPoint3DGetEqual() - SUPoint3DLessThan() - SUPoint3DOffset() - SUPoint3DTransform() ### Polyline3d Functions - SUPolyline3dAddPoints() - SUPolyline3dCreate() - SUPolyline3dFromDrawingElement() - SUPolyline3dFromEntity() - SUPolyline3dGetNumPoints() - SUPolyline3dGetPoints() - SUPolyline3dRelease() - SUPolyline3dToDrawingElement() - SUPolyline3dToEntity() ``` -------------------------------- ### SUEnvironmentsGetAll Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_environments_ref.html Retrieves every environment associated with an environments object. ```APIDOC ## SUResult SUEnvironmentsGetAll(SUEnvironmentsRef environments, size_t len, SUEnvironmentRef items[], size_t* count) ### Description Retrieves every environment associated with an environments object. ### Parameters - **environments** (SUEnvironmentsRef) - [in] The environments object. - **len** (size_t) - [in] The number of environments to retrieve. - **items** (SUEnvironmentRef[]) - [out] The environments retrieved. - **count** (size_t*) - [out] The number of environments retrieved. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if environments is not a valid object - SU_ERROR_NULL_POINTER_OUTPUT if items or count is NULL ``` -------------------------------- ### SUModelLoadDefinitionWithStatus Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_model_ref.html Loads a component from a file and returns the load status. ```APIDOC ## SUModelLoadDefinitionWithStatus ### Description Loads a component from a file. Use the status value to check if the file was created with a newer version of SketchUp. ### Parameters - **model** (SUModelRef) - In/Out - The model object. - **filename** (const char*) - In - The full path and filename to a SketchUp model. - **definition** (SUComponentDefinitionRef*) - Out - The component definition that is created after load. - **status** (enum SUModelLoadStatus*) - Out - Returns additional information on the status of a successful operation. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if model is not a valid object - SU_ERROR_NULL_POINTER_INPUT if filename is NULL - SU_ERROR_NULL_POINTER_OUTPUT if definition or status is NULL - SU_ERROR_OVERWRITE_VALID if definition is already a valid object - SU_ERROR_MODEL_VERSION if the component file has a newer version than supported - SU_ERROR_SERIALIZATION if loading the file failed ``` -------------------------------- ### SUEnvironmentsGetAll Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_environments_ref.html Retrieves every environment associated with an environments object. ```APIDOC ## SUEnvironmentsGetAll ### Description Retrieves every environment associated with an environments object. ### Signature `SUResult SUEnvironmentsGetAll(SUEnvironmentsRef environments, size_t len, SUEnvironmentRef items[], size_t *count)` ``` -------------------------------- ### SUMeshHelperCreateWithUVHelper Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_mesh_helper_ref.html Creates a tessellated polygon mesh object from a face and a UV helper associated with the face. ```APIDOC ## SUMeshHelperCreateWithUVHelper ### Description Creates a tessellated polygon mesh object from a face and a UV helper associated with the face. ### Signature enum SUResult SUMeshHelperCreateWithUVHelper(SUMeshHelperRef *mesh_ref, SUFaceRef face_ref, SUUVHelperRef uv_helper_ref) ``` -------------------------------- ### SUModelLoadMaterial Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_model_ref.html Loads a material from a SKM file. ```APIDOC ## SUModelLoadMaterial ### Description Loads a material from a SKM file. If a matching material exists in the model, it will be returned instead. ### Parameters - **model** (SUModelRef) - In/Out - The model object. - **file_path** (const char*) - In - The location to load the material from (UTF-8 encoded). - **material** (SUMaterialRef*) - Out - The material object. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if model is not a valid object - SU_ERROR_NULL_POINTER_INPUT if file_path is NULL - SU_ERROR_OVERWRITE_VALID if material is already a valid object - SU_ERROR_SERIALIZATION if the operation fails ``` -------------------------------- ### SUArcCurveGetStartPoint Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_arc_curve_ref.html Retrieves the starting point of the arc curve. ```APIDOC ## SUArcCurveGetStartPoint ### Description Retrieves the starting point of the arccurve. ### Parameters - **arccurve** (SUArcCurveRef) - [in] The arccurve object. - **point** (struct SUPoint3D*) - [out] The arccurve starting point. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if arccurve is not a valid object - SU_ERROR_NULL_POINTER_OUTPUT if point is NULL ``` -------------------------------- ### SUFaceGetUVHelper Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_face_ref.html Creates a UV helper for the face. ```APIDOC enum SUResult SUFaceGetUVHelper(SUFaceRef face, bool front, bool back, SUTextureWriterRef texture_writer, SUUVHelperRef* uv_helper); ``` -------------------------------- ### SUArcCurveGetStartAngle Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_arc_curve_ref.html Retrieves the starting angle of the arc curve. ```APIDOC ## SUArcCurveGetStartAngle ### Description Retrieves the start angle of the arccurve. ### Parameters - **arccurve** (SUArcCurveRef) - [in] The arccurve object. - **angle** (double*) - [out] The arccurve start angle. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if arccurve is not a valid object - SU_ERROR_NULL_POINTER_OUTPUT if angle is NULL ``` -------------------------------- ### GetDescription Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/class_sketch_up_model_importer_interface.html Returns a brief description of the importer for the file drop down box. ```APIDOC ## std::string GetDescription() const ### Description Return a brief description of the importer for the file drop down box. SketchUp uses this description together with all the extensions to form a single entry in the import dialog drop down list. ### Returns - **std::string** - The description retrieved. ``` -------------------------------- ### SUInstancePathCreate Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_instance_path_ref.html Creates an instance path object. ```APIDOC ## SUInstancePathCreate ### Description Creates an instance path object. ### Parameters - **instance_path** (SUInstancePathRef *) - [out] The instance path object created. ### Returns - SU_ERROR_NONE on success - SU_ERROR_NULL_POINTER_INPUT if instance_path is NULL - SU_ERROR_OVERWRITE_VALID if *instance_path refers to a valid object ``` -------------------------------- ### SUModelGetLayerFolders Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_model_ref.html Gets the SULayerFolderRef objects that are owned by the given model. ```APIDOC ## SUModelGetLayerFolders ### Description Gets the SULayerFolderRef objects that are owned by the given model. ### Parameters - **model** (SUModelRef) - Input - The model object. - **len** (size_t) - Input - The number of elements in layer_folders. - **layer_folders** (SULayerFolderRef[]) - Output - An array of layer folder objects. - **count** (size_t*) - Output - The number of elements written into layer_folders. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if model is an invalid object - SU_ERROR_NULL_POINTER_OUTPUT if layer_folders or count is NULL ``` -------------------------------- ### SUSceneGetUseSectionPlanes Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_scene_ref.html Gets whether the scene uses section planes. ```APIDOC SUResult SUSceneGetUseSectionPlanes(SUSceneRef scene, bool* use_section_planes); ``` -------------------------------- ### SUStyleCreateFromFile Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_styles_ref.html Creates a style object from a file at the given path. ```APIDOC ## SUStyleCreateFromFile ### Description Creates a style object from a file at the given path. ### Signature enum SUResult SUStyleCreateFromFile(SUStyleRef *style, const char *path) ``` -------------------------------- ### SUVector3DGetArbitraryAxes Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_vector3_d.html Get arbitrary axes perpendicular to a given vector. ```APIDOC ## SUVector3DGetArbitraryAxes ### Description Calculates two perpendicular axes (x and y) for a given z-axis vector using the arbitrary axis algorithm. ### Parameters - **z_axis** (const struct SUVector3D*) - Required - The vector to use as the z axis. - **x_axis** (struct SUVector3D*) - Required - The computed x axis vector. - **y_axis** (struct SUVector3D*) - Required - The computed y axis vector. ### Returns - SU_ERROR_NONE on success - SU_ERROR_NULL_POINTER_INPUT if z_axis is NULL - SU_ERROR_NULL_POINTER_OUTPUT if x_axis or y_axis is NULL - SU_ERROR_INVALID_ARGUMENT if z_axis is not a valid vector ``` -------------------------------- ### SUTextureWriterGetTextureIdForFace Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_texture_writer_ref.html Gets the texture id of a previously loaded face. ```APIDOC ## SUTextureWriterGetTextureIdForFace ### Description Gets the texture id of a previously loaded face. ### Parameters - **writer** (SUTextureWriterRef) - The texture writer object. - **face** (SUFaceRef) - The face object. - **front** (bool) - The side of the face we are interested in. True if we want texture for the front face, false if we want the texture for the back face. - **texture_id** (long *) - The texture id retrieved. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if writer or face is not a valid object - SU_ERROR_NULL_POINTER_OUTPUT if the face object has a texture, and texture_id is NULL - SU_ERROR_GENERIC if the face object does not have a previously written texture_id ``` -------------------------------- ### SUStyleCreateFromFile Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_styles_ref.html Creates a style object from a file at the given path. ```APIDOC ## SUStyleCreateFromFile ### Description Creates a style object from a file at the given path. ### Signature `enum SUResult SUStyleCreateFromFile(SUStyleRef *style, const char *path)` ### Parameters - **style** (SUStyleRef*) - [out] The style object. - **path** (const char*) - [in] The file path. Assumed to be UTF-8 encoded. ### Returns - SU_ERROR_NONE on success - SU_ERROR_NULL_POINTER_OUTPUT if style is NULL - SU_ERROR_OVERWRITE_VALID if *style already refers to a valid object - SU_ERROR_NULL_POINTER_INPUT if path is NULL - SU_ERROR_SERIALIZATION if style couldn't be created from the file at path ``` -------------------------------- ### SUTextureWriterGetTextureIdForEntity Source: https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_texture_writer_ref.html Gets the texture id of a previously loaded entity. ```APIDOC ## SUTextureWriterGetTextureIdForEntity ### Description Gets the texture id of a previously loaded entity. Acceptable entity types are: SUComponentInstanceRef, SUImageRef, SUGroupRef and SULayerRef. ### Parameters - **writer** (SUTextureWriterRef) - The texture writer object. - **entity** (SUEntityRef) - The entity object. - **texture_id** (long *) - The texture id retrieved. ### Returns - SU_ERROR_NONE on success - SU_ERROR_INVALID_INPUT if writer or entity is not a valid object - SU_ERROR_NULL_POINTER_OUTPUT if texture_id is NULL - SU_ERROR_GENERIC if the entity is not one of the acceptable types or it does not have a previously written texture_id ```