Get a reference to the Artboard that a SceneNode is part of
Use Case:
Gillian is making a plugin that lists all the scene nodes in a drop down list. Since there are many scene nodes Gillian wants to preface the scene node name with the artboard name.
He uses the artboard
property on the SceneNode
class to get a reference to the artboard and make his dropdown list names more specific.
This is such an easy piece of code I don’t think we need to burden the API with it.
let artboard = node.parent
while (!(artboard instanceof Artboard))
artboard = artboard.parent
2 Likes
It’s not about easy. I wrote a function too but if you have 200 items on an artboard and you have 20 artboards and you go through all the items and when you do you call getIsArtboard()
each time you are wasting cycles. Also, the function may be easy but JavaScript is interpreted meaning it is 8x-12x slower than native (last I checked).
Perhaps, but there are so many other things like this that “would be nice to have” that if you lard up the API with them all, you have an unwieldy surface.
JS speed aside, going up 1-2 levels on average to find a node’s artboard has to be in the very low microseconds.
1 Like