Seems ‘rotate’ is not being exported in the JSON export from the RestApi?
It appears on export the ‘Last Name’ fields should be the same size as the other rectangles, just rotated 33 degrees… Instead it seem the css properties for it are the outer bounding box as if the control wasn’t rotated.
The json snippet for the lastNameField has no ‘rotate’, might expect it in the definition for ‘effect’? Just guessing, not really familiar with where it would be… Also in the json the height property is wrong? Should be
Thanks, will do. In a way it isn’t that important, i’m more a software tester turned dev, i’m writing a little tool that converts my figma drawing to a functional React component. My use case was more to just test different properties, more of an academic issue.
Thanks for your attention.
Oh got it! It returns the absolute bounding box, so this behavior is to be expected, not really a bug. It would’ve been better if it returned all object dimensions though, like rotation and real width/height. Not sure why they made it work this way instead.
Thanks for the response. My main concern is the JSON doesn’t maintain the fidelity of the drawing. I’d be fine if the rotate property isn’t output at all for my use case actually. The issue for me is that as i’m using Figma effectively as a form designer to create React && CSS files from my drawing, forgot to say I am lazy 🙂. For my use case 99.999% of the time i’d be happy with the true width && height were persisted in the JSON not contain a rotate value, that actually would be better for me. But then I’d expect the Height/Width to not be altered if rotate was never emitted. Note in the screen shots provided the CSS value displayed within Figma appear correct, H 24 W 184 with a rotate of 33deg. However, when persisted to JSON the resulting JSON is H 120 and W 184 effectively asserting (24x184) === (120 x 184). Might be me but it seems this would never be desirable. Or thinking about an an easy fix, might be a bit kludgy but how about emitting another secion on the JSON say 'rawControlDimensions" if/when rotate is present? Might be the easiest cleanest way not to break others but still emit the correct values for those who need it?
Anyway thinks for your attention, really do like Figma turning a lot of my friend on to it 🙂
Cheers,
dan:)
I just read the docs, and it looks like you should also be getting size and relativeTransform properties of the node which should be enough. Are you not getting those?
Thanks for a quick response. You do sleep? Double checking the JSON emitted for the element, not seeing either ‘relativeTransform’ nor ‘size’ in the JSON. Double checking to be suse the values i’m seeingm it is the same as reported in the original message. Also want to be clear, the ‘absoluteBoundingBox’ was altered by me when trying to bold the height, that would be the only difference from what i’m seeing persisted and reported in the messages, didn’t want to add confusion, but i’m a noob at the message board options 😎.
Again, thanks for the help, speaking from past experience and knowing my luck, maybe i hit an edge case feel free to look at my drawing, copied one so you could look at it in case. Assuming you could easily access my account the drawing URL would be (created this for you all to look at if needed):
Yeah I just tried it and it seems like the API it doesn’t give out all the fields listed in the docs. I tried getting the full file using /file/:key and then a specific node using /file/:key/nodes=125:27 endpoint. I don’t understand what’s wrong…
Solution.
Ok turns out I just needed to read the docs better. When getting a specific node by id, you also need to specify &geometry=paths query parameter. This returns all the necessary data, such as size and transform matrix. For this specific node:
The full command I used: curl -sH 'X-Figma-Token: YOUR-TOKEN' 'https://api.figma.com/v1/files/6LbL35bbnCvcrWZm6qSPE6/nodes?ids=125:27&geometry=paths' > figma.json
Ah makes sense, now i’m wondering if i might be working into a feature request instead… Would be great to have a query parameter say ‘&css=true’ or “&markup=mcss|ios|android]”? The parameter would ask Figma to emit the markup and desired format.
Ultimately, the CSS is exactly what i’m after, looking at “Inspect” everything is all there and properly deciphered so i can be lazy 😎 Just seems users shouldn’t need to re-invent the wheel as all the info is already available in Figma and should easily be provided if requested… Also for say gradients there doesn’t appear a clear to map the raw data in the model to what the respective markup would be… Not to mention, while i may never happen, what if your persisting model format need to change, while it would always result in the CSS, if one could explicitly look for a “cssFormat” node, we would be protected as the CSS would be a product of what the model would describe…?
Yep, that would be nice. And I saw this requested before in other places. You can create a feature request in the #product-ideas category so people with the same issue could vote for it.
Thanks will create a product request. Really appreciate the help 😎
As promised, in case you’d be curious to add any comments Gleb. Again thanks for the help 😎
After getting the relativeTransform data, how can I find the right angle? I tried