Options
Reading current options
Section titled “Reading current options”let model = await SketchUpApi.getActiveModel();
// Read unit optionsconsole.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 optionsconsole.log('Show Transition:', model.options.sceneOptions.showTransition);console.log('Transition Time:', model.options.sceneOptions.transitionTime);
// Read slideshow optionsconsole.log('Loop Slideshow:', model.options.slideshowOptions.loopSlideshow);console.log('Slide Time:', model.options.slideshowOptions.slideTime);Setting SketchUp units to meters
Section titled “Setting SketchUp units to meters”let model = await SketchUpApi.getActiveModel();
// Update to metersawait model.options.unitOptions.update({ LengthUnit: SketchUpApi.LengthUnit.Meter});
// Verify the changelet updatedOptions = await model.options.unitOptions.refresh();console.log('New Length Unit:', updatedOptions.lengthUnit); // 4 (Meter)Configuring multiple unit settings
Section titled “Configuring multiple unit settings”let model = await SketchUpApi.getActiveModel();
// Set metric system with precisionawait model.options.unitOptions.update({ LengthUnit: SketchUpApi.LengthUnit.Meter, LengthPrecision: 3, AreaUnit: SketchUpApi.AreaUnit.SquareMeter, VolumeUnit: SketchUpApi.VolumeUnit.CubicMeter});
// Verify changeslet 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);Updating scene transition options
Section titled “Updating scene transition options”let model = await SketchUpApi.getActiveModel();
// Enable scene transitions with 5 second durationawait model.options.sceneOptions.update({ ShowTransition: true, TransitionTime: 5});
// Verifylet updated = await model.options.sceneOptions.refresh();console.log('Show Transition:', updated.showTransition);console.log('Transition Time:', updated.transitionTime);Configuring slideshow settings
Section titled “Configuring slideshow settings”let model = await SketchUpApi.getActiveModel();
// Configure slideshow to loop with 10 second slidesawait model.options.slideshowOptions.update({ LoopSlideshow: true, SlideTime: 10});
// Verifylet updated = await model.options.slideshowOptions.refresh();console.log('Loop Slideshow:', updated.loopSlideshow);console.log('Slide Time:', updated.slideTime);Listing all available options
Section titled “Listing all available options”let model = await SketchUpApi.getActiveModel();
// Get all option providerslet 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}`); });});