Skip to main content
Solved

Can I change the fillStyleId without importByKeyAsync?

  • November 6, 2022
  • 4 replies
  • 801 views

Lewis_Healey

Hello again!

I am trying to replace an old token (paint style) with a new token without having to import the style by async key (to speed things up). We use a combination of the REST API and Figma’s API to make things performant but I am struggling to find how the data connects.

If get the REST API, the paint style has the below object output

  {
    "key": "364b7f55ed6d667ce2583d93df6b6e6c05757c56",
    "file_key": "tccM0bdIgBt1SFL7spGcy1",
    "node_id": "8146:263",
    "style_type": "FILL",
    "thumbnail_url": "https://s3-alpha-sig.figma.com/checkpoints/b7B/6HE/VXm2Jyd0UAENv0Rr/style_thumbnail_7.png?Expires=1668384000&Signature=SlwH4aiXCyUoB4PCpdnyk8Ki3ATHxULS7QpHOocZFudizrRJKh6QdxuIVodNvLk~car1cfjo1s0QZamKCdHAzYHncAcNk9slRk8rs-q7ZO9mvVMODOc8gYqK9A3PRy6VPm4qTkE-yjPq3WJksPsYqTbR66-E8k8K8VcaMl5wtXDAz6xxxRobL~1z8sc2toXAD0NKVse7D3ZoMZCd-mKdE7z2DQDHTZvd5ZOFP9QwhGX7gzb~~RfbFHd--AY38eNRRxgryavvjlg05lr2fuD5aeZ4cEfrzYeEwS-wVpdBf0vVvu0JjCzAC7gezTcbjjJ~VBI2o2Ie~t9AGqixm6Bqyw__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA",
    "name": "Light/$elevation.surface.hovered",
    "description": "Hovered state of elevation.surface",
    "created_at": "2022-09-25T23:58:41.879Z",
    "updated_at": "2022-09-25T23:58:41.879Z",
    "user": {
        "id": "1092589794519853188",
        "handle": "Lewis Healey",
        "img_url": "https://s3-alpha.figma.com/profile/3906027b-84ff-4007-9b5b-d03ff1713897"
    },
    "sort_position": "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~LO"
}

But when I inspect a node within Figma and look for it’s that same paint style and its fillStyleId, I get “S:364b7f55ed6d667ce2583d93df6b6e6c05757c56,8146:5”. I can see the key inside this string but not sure what the 8146:5 is.

I am guessing a part is the node ID but I am unsure what the number represents after the semicolon. Would love to know how I can know that

Best answer by Lewis_Healey

Ahh ok I see now, you can only use what has already been imported, makes sense! I will importByKey.

Thanks!

View original

4 replies

Gleb
  • Power Member
  • 4708 replies
  • November 6, 2022

This full number is an ID and you can discard as it seems like you don’t need it for anything.


Lewis_Healey
  • Author
  • New Participant
  • 14 replies
  • November 6, 2022

Thanks Gleb! When I try to replace it without that ID, it seems to error “Error: in set_fillStyleId: Cannot set style successfully: Cannot find style”


tank666
  • 4873 replies
  • November 6, 2022

You can change fillStyleId to any id you know (local or imported from a library). Notice how the style ids look like:

To use a style from the library, you definitely need to import it into a file. This way it will get a unique id in the file (a unique id is assigned automatically. That is, you cannot know "S:1a2b…n9,unique-id" in advance). If it’s already imported, you can get the style id from the node, or from pluginData/clientStorage if you’ve saved it there.


Lewis_Healey
  • Author
  • New Participant
  • 14 replies
  • Answer
  • November 6, 2022

Ahh ok I see now, you can only use what has already been imported, makes sense! I will importByKey.

Thanks!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings