SVG class doesn't return the name
Closed this issue · 2 comments
When importing a single SVG file, the SVG
class doesn't return the name of the file.
tools.ImportSVG('path-to-file.svg').then(svg => {
// SVG was imported
// Variable 'svg' is instance of SVG class
console.log(svg.toString());
}).catch(err => {
console.error(err);
});
The SVG
class only has the following methods on it:
toString()
toMinifiedString()
getBody()
getDimensions()
And these following two properties:
width
height
It would be helpful to have a new method getName()
or a new property name
that will return the relevant SVG file name like the Collection
class does.
I don't see point in having a name for SVG instance.
If you are using single SVG instance, you should know where you've imported it from, you have unique variable, so no point in having a name.
If you are importing multiple icons, use Collection class to store them by names. In Collection class you can rename them.
However, because it is JavaScript, you can add custom properties to instances, so you can just add name property yourself:
tools.ImportSVG('path-to-file.svg').then(svg => {
svg.name = 'icon-name';
}).catch(err => {
console.error(err);
});
Sorry about that @cyberalien. I didn't know that I could add a custom property to an instance like that. Thanks for the awesome work you did 👏