Loading Sketchup Models
HOOPS Visualize is able to load SketchUp models using the SketchUp SDK library. SketchUp functionality is limited to Windows platforms.
All SketchUp-related classes are members of the HPS::Sketchup
container class. The SketchUp API is abstracted away from you by HOOPS Visualize. If you have a need to access the SketchUp API directly, you need to include the Sketchup SDK itself in your development environment.
Prerequisites
Steps for loading SketchUp models are delineated below:
Step 1: Get SketchUp
In order to use the SketchUp functionality, you must obtain the SketchUp libraries SketchUpAPI.dll and SketchUpCommonPreferences.dll from the developer (these are distributed with the SketchUp SDK) and include them in your build. The supported version of the SketchUp SDK is noted in the release notes.
Step 2: Include SketchUp Header
To utilize the SketchUp importer, you need to include sprk_sketchup.h in your source.
Import Example
HOOPS Visualize uses the same basic framework to import SketchUp files as it does for other file types. The main difference is the use of functions from the HPS::Sketchup
container class.
HPS::Sketchup::ImportOptionsKit iok;
iok.SetTarget(myModel); // HPS::Model import location
iok.SetView(myView); // HPS::View will have the main camera - optional
HPS::Sketchup::ImportNotifier notifier = HPS::Sketchup::File::Import(filename, iok);
notifier.Wait(); // wait for this model to finish loading
HPS.Sketchup.ImportOptionsKit iok = new HPS.Sketchup.ImportOptionsKit();
iok.SetTarget(myModel); // HPS.Model import location
iok.SetView(myView); // HPS.View will have the main camera - optional
HPS.Sketchup.ImportNotifier notifier = HPS.Sketchup.File.Import(filename, iok);
notifier.Wait(); // wait for this model to finish loading
In the code sample, SetView
has been called. This sets the view’s camera to the same setting as the main camera in the model file. The main camera is the camera that was active when the file was saved.
Units
Units
and NamedOptions
are imported as user data in a segment called “model_information”, which will be created as a subsegment of the segment where the model is imported. All NamedOptions
will be present as key-value pairs.
There will also be two user data pertaining to units in that segment. One is called “length unit” and its value can be one of the following:
inches
feet
millimeters
centimeters
meters
undefined
The second one is called “length format” and its value can be one of the following:
decimal
architectural
engineering
fractional
undefined
Supported Entities
HOOPS Visualize is able to import the following entities from a SketchUp model:
Group
Components definition
Component instance
Faces
Edges
Curves
Texture
Material
Surfaces
FreeHand curves
Attributes as user data
Metadata
Scenes
Visibility
Layers (see below)
Special Notes Regarding Layers
The importer is able to read geometry assigned to a layer, however, layers themselves as a concept are not imported. Thus, associations between layers and geometric data are lost. Visibility settings for geometry which were present on the active layer at the time the model was saved will be used for those entities when loaded by HOOPS Visualize.