-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new Layer() with existing definition results in sublayer id's being identical #35
Comments
What is const customArtboard = new Artboard({ /* opts */ });
const artboard = new Artboard(null, source_artboard); Does that work, or do we need the ability to throw out IDs from raw JSON in some cases? |
I ran into the same thing. I wanted to use an artboard as a template and duplicate it multiple times. if you use |
Ahhhhh ok I see the issue now. Should each new instance of any model always generate a new id? I'm trying to think of any downsides to this.. |
This would be the idea. I used @jonmadison's approach and it changes all ids.
My workaround is to change all the do_objectIDs in my json and deepClone the object before passing it to the artboard constructor. This worked for me at least. |
If you want to open a PR to add layer types to layerToClass that would be wonderful, if not I can do it tomorrow. We should definitely fix the object IDs, it is not great to have to do work arounds like that. |
when i create a new artboard from an existing artboard:
const artboard = new Artboard(source_artboard);
only the outer layer ID is created anew; all sublayers are identical, resulting in interesting behavior within Sketch: I select a sublayer, and both that sublayer and the duplicated object's sublayer are selected.
My current workaround is creating a newObject function that will create new object Ids for each sublayer:
and instead call it
const artboard = newObject(source_artboard);
It'd be nice if new Artboard(source_json) would do the same. Any reason not to?
The text was updated successfully, but these errors were encountered: