![]() var file = File.openDialog() Ĭontents = contents.replace(/id="/g, 'class="') The second script makes vice versa: replaces 'id' with 'class', adds '_class' to the file name and saves the file into the same folder. The first script opens your svg file, replaces 'class' to 'id', adds to the file name '_id' and saves the new svg file into the same folder: var file = File.openDialog() Ĭontents = contents.replace(/class="/g, 'id="') So if all you need is to replace 'id' to 'class' and back, it can be done pretty easy with Extendscript. add classname prefix for indexed elements of same type ![]() split ids with multiple classes seperated by '-' delimiter * run this convert layer IDs after svg was edited in AI and saved againĬonst elements = svg.querySelectorAll('') Example 2: restore classes after editing in AIĬonst svgAi = document.querySelector('#svgAi') } Optimize SVG for editing in AI: (Classes will be converted to IDs) Let classList = className ? className.split(' ') : Ĭonsole.log('id "' + newID + '" is not unique.') ĬlassList = classList + '-' + i + '-' + classList ![]() Let className = el.getAttribute('class') Let svgID = svg.id ? svg.id : svgClass.split(' ').join('-') Let svgClass = svg.getAttribute('class') * run this once to store classnames in layer IDs before reediting in AI This is what is generated with the solution suggested in the comment:Ĭonst svgWeb = document.querySelector('#svgWeb') I have to modify this image with Adobe Illustrator, but when I save I have:Īnd names of classes are not there anymore. Note the class names, for example antenna-left.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |