You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Google Apps Script调整Google Slides中的形状Adjustments参数

How to Adjust Shape Control Handles (Yellow Markers) in Google Slides via Apps Script

Great question—this is definitely one of those features that’s intuitive in the UI but not super obvious in the Apps Script docs at first glance. Let’s break this down clearly:

The Short Answer

Google Apps Script does have an equivalent to VBA's Adjustments property for shapes in Slides. You’ll use the Shape.getAdjustments() method, which returns an AdjustmentCollection object. Each item in this collection maps directly to one of those yellow control handles you see in the Slides UI.

Example Code Walkthrough

Let’s use common use cases like adjusting a pie chart slice offset or an arrow’s head width to show how this works:

  1. First, access your target shape and its adjustment handles

    function tweakShapeControls() {
      const presentation = SlidesApp.getActivePresentation();
      const targetSlide = presentation.getSlides()[0]; // Grab the first slide (adjust as needed)
      const targetShape = targetSlide.getShapes()[0]; // Grab the first shape on the slide
      
      const adjustments = targetShape.getAdjustments();
      Logger.log(`This shape has ${adjustments.length} control handles`);
    }
    
  2. Modify a specific adjustment handle
    Each adjustment uses a zero-based index. The index corresponding to each yellow handle varies by shape type—you’ll need to test with your specific shape to find the right one. For example:

    // Adjust the first control handle (index 0) to 20% of its maximum range
    adjustments.get(0).setValue(0.2);
    
    • For pie charts, index 0 typically controls the slice pull-out offset.
    • For arrows, index 0 might control head width, while index 1 controls tail width.

Important Details to Keep in Mind

  • Value ranges depend on the shape: Most adjustments use a 0–1 scale (0 being the minimum, 1 the maximum), but some shapes (like pie charts) allow values beyond 1 for more extreme adjustments.
  • Not all shapes have adjustments: Basic shapes like rectangles or circles won’t have any adjustment handles—only dynamic shapes (arrows, callouts, chart slices) do.
  • Test to find the right index: Use Logger.log to check how many adjustments your shape has, then tweak values one by one to map each index to its corresponding yellow handle.

Why This Was Tricky to Find

The AdjustmentCollection documentation is tucked under the Shape class in Apps Script, so it’s easy to miss if you’re searching for terms like "yellow handles" or "shape controls" instead of "adjustments".

内容的提问来源于stack exchange,提问作者RSM_Tools

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 21:47:33