Hi everyone,
I am just getting familiar to the plugin dev. environment, so please don’t be hard on me
I am trying to add an SVG to the artboard instead of generating it from pathdata. The reason I want to go this way is that when generating a path I do not seem to find a way to add 2 paths as a group, so that the user does not have to do that manually. Another advantage (as I see it) to go this way is that I want /and hope/ to potentially grab an svg file and add it to the artboard with a function or a method, just like someone would do it manually, because I have a library of svg files I need to work with, and extracting path data would be cumbersome to me.
Does anyone know how to simply add an svg file to the artboard?
Any feedback would be much appreciated.
2 Likes
Hi Karen –
This is something we want to add to the APIs, but it’s not currently possible to import an SVG file directly.
However, depending on your use case, you might be able to get by with copying the SVG text to the clipboard and letting the user paste it where they want. If text in the clipboard looks like SVG, XD will insert it as an SVG file.
I know that’s not perfect though, so we are thinking about a better solution. It’s going to take some time though.
As far as adding two paths and creating a group, you should be able to do something like this:
// assume that you have paths named path1 and path2, and they've been
// added to the document and you've required the commands module
selection.items = [path1, path2];
commands.group();
Thank you so much @kerrishotts will try the grouping. it’s kind of strange that it works for png but not for svg (for the first question). Thank you anyways!
Drag and drop is coming to XD extensibility early next year. Hopefully that helps!
1 Like
Drag’n’drop won’t necessarily help at all.
What we need is a way to take SVG content (text, perhaps loaded from a file, perhaps generated by the plugin) and create the artboard elements that re-create the SVG.
2 Likes
Hi @kerrishotts,
Any updates on this as of March 2020?
We have an API that returns SVG files, and we’d like to import them into the artboard.
Cheers,
1 Like