Skip to main content
Participant
August 30, 2022
Question

Script to copy SVG code from selected objects

  • August 30, 2022
  • 1 reply
  • 312 views

Hi all,

I am trying to create my first Illustrator Script and it seems that I need some help.

When selecting and copying two objects (like in the image above) and pasting them into a text editor, the following SVG code will be pasted:

(The path is shortened)

 

The script that I am trying to create should help me manipulating the SVG code so that only the text inside the quotes of d="" will be pasted.

 

The result should look like this:

 

Does anyone have an idea how to solve this?

 

Thanks a lot! 

This topic has been closed for replies.

1 reply

Mylenium
Legend
August 30, 2022

Could probably something as simple as a regex.match("d=\""*"\"") applied before copying to the clipboard as a filter. Just a suggestion and you need to look it up. I'm not that fluent at regex and of course if there are multiple objects/ multiple lines of code you would need to expand it further.

 

Mylenium

Lucas6620Author
Participant
August 30, 2022

Thank you for the tip.

But do you have an idea how I can read the content of my clipboard?