So I was able to grab the width, hight, X, and y value of a frame in Figma. However, Google App Script is asking for start and the end of the the index of the shape in Google App script. how do I manipulate the values of X and Y to get the start and end of the the index I'm not even sure what the start and the end of the box is and how to find it.
How do I work with these the width and the height variables to find the start and end value of a shape in Google App Script
I am using Figma API and Google App Script My end goal is to make Ann exporter from Figma to Google Slides
absoluteBoundingBox: {
x: -460,
y: -333,
width: 586,
height: 586
},
var frameJSON.x = {};
var frameJSON.y = {};
var frameJSON.width = {};
var frameJSON.height = {};
var subRange = textRange.getRange();
Logger.log(
"Sub-range Start: " +
subRange.getStartIndex() +
"; Sub-range End: " +
subRange.getEndIndex() +
"; Sub-range Content: " +
subRange.asString()
);
When you insert a shape with SlidesApp you can getText
to retrieve the TextRange
object in it.
You can then manipulate this object to insert the text you want into your shape.
Here is some sample code:
function insertShapeWithText() {
//sample shape data
var x = 300;
var y = 250;
var width = 100;
var height = 3000;
var text = "Bla bla bla";
var pre = SlidesApp.getActivePresentation();
var slide = pre.getSlides()[0];
var shape = slide.insertShape(SlidesApp.ShapeType.DIAMOND, x, y, width, height);
shape.getText().setText(text);
}