Skip to content

Options

let model = await SketchUpApi.getActiveModel();
// Read unit options
console.log('Length Unit:', model.options.unitOptions.lengthUnit);
console.log('Length Precision:', model.options.unitOptions.lengthPrecision);
console.log('Length Format:', model.options.unitOptions.lengthFormat);
// Read scene options
console.log('Show Transition:', model.options.sceneOptions.showTransition);
console.log('Transition Time:', model.options.sceneOptions.transitionTime);
// Read slideshow options
console.log('Loop Slideshow:', model.options.slideshowOptions.loopSlideshow);
console.log('Slide Time:', model.options.slideshowOptions.slideTime);
let model = await SketchUpApi.getActiveModel();
// Update to meters
await model.options.unitOptions.update({
LengthUnit: SketchUpApi.LengthUnit.Meter
});
// Verify the change
let updatedOptions = await model.options.unitOptions.refresh();
console.log('New Length Unit:', updatedOptions.lengthUnit); // 4 (Meter)
let model = await SketchUpApi.getActiveModel();
// Set metric system with precision
await model.options.unitOptions.update({
LengthUnit: SketchUpApi.LengthUnit.Meter,
LengthPrecision: 3,
AreaUnit: SketchUpApi.AreaUnit.SquareMeter,
VolumeUnit: SketchUpApi.VolumeUnit.CubicMeter
});
// Verify changes
let updated = await model.options.unitOptions.refresh();
console.log('Length Unit:', updated.lengthUnit);
console.log('Length Precision:', updated.lengthPrecision);
console.log('Area Unit:', updated.areaUnit);
console.log('Volume Unit:', updated.volumeUnit);
let model = await SketchUpApi.getActiveModel();
// Enable scene transitions with 5 second duration
await model.options.sceneOptions.update({
ShowTransition: true,
TransitionTime: 5
});
// Verify
let updated = await model.options.sceneOptions.refresh();
console.log('Show Transition:', updated.showTransition);
console.log('Transition Time:', updated.transitionTime);
let model = await SketchUpApi.getActiveModel();
// Configure slideshow to loop with 10 second slides
await model.options.slideshowOptions.update({
LoopSlideshow: true,
SlideTime: 10
});
// Verify
let updated = await model.options.slideshowOptions.refresh();
console.log('Loop Slideshow:', updated.loopSlideshow);
console.log('Slide Time:', updated.slideTime);
let model = await SketchUpApi.getActiveModel();
// Get all option providers
let providers = model.options.toArray();
providers.forEach(provider => {
console.log(`Provider: ${provider.name}`);
// List all key-value pairs in this provider
const options = provider.toArray();
options.forEach(([key, value]) => {
console.log(` ${key}: ${value}`);
});
});