Skip to content
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

(Feature request perhaps?) copy-paste vector-graphics #345

Open
StefPillaert opened this issue Jul 9, 2020 · 14 comments
Open

(Feature request perhaps?) copy-paste vector-graphics #345

StefPillaert opened this issue Jul 9, 2020 · 14 comments
Assignees

Comments

@StefPillaert
Copy link

@StefPillaert StefPillaert commented Jul 9, 2020

In an app I use on windows10, it is possible to copy to clipboard as vectors:
image
In e.g. inkscape, I can paste this (ctrl-V), but this doesn't seems to work in IPE (it says "nothing to paste). Don't know if this would be possible in IPE?
Let me know if I have to give more detailed info

@otfried otfried self-assigned this Jul 15, 2020
@otfried
Copy link
Owner

@otfried otfried commented Jul 15, 2020

What software are you using to copy the vector graphics to the clipboard?

@StefPillaert
Copy link
Author

@StefPillaert StefPillaert commented Jul 15, 2020

Scia Engineer, software for structural engineering. Free for academic educational use. I regularly use this software in my courses, and therefore copy a lot from there to my LateX course material.
Unfortunately, those screenshots need some editing every now and then, which I did until now with Inkscape. For that, the fact that it is vectorized comes in very handy: it is very easy to remove redundant stuff form the "screenshots".
But since my son learned me about Ipe, I try to avoid working with inkscape more and more: inkscape is responding way to slowly, particularly when adding "handwriting" to graphics. Ipe performs so much better for that.
[https://www.scia.net/en/education/scia-engineer-students-professors].

@otfried
Copy link
Owner

@otfried otfried commented Jul 16, 2020

Do you have any idea what format Scia Engineer copies to the clipboard?

There is not really a vector graphics format defined among the standard Windows clipboard data formats: https://docs.microsoft.com/en-us/windows/win32/dataxchg/clipboard-formats

The CF_METAFILEPICT format could be used that way, but I suspect that is not what happens. Perhaps it copies the vector graphics in SVG format?

@StefPillaert
Copy link
Author

@StefPillaert StefPillaert commented Jul 16, 2020

No idea, I just know it works in Inkscape (so svg-format seems likely?). Any way how I can test this?

@otfried
Copy link
Owner

@otfried otfried commented Jul 30, 2020

I've applied for an academic licence to Scia engineer, but they never replied to me.

When I have some more time, I'll make a version of Ipe that produces more debug output, so we can figure out what it places on the clipboard.

@StefPillaert
Copy link
Author

@StefPillaert StefPillaert commented Aug 2, 2020

  • Re. the licence for Scia Engineer: strange, normally, if you provide an academic-related e-mail-address here (https://www.scia.net/en/forms/free-engineering-software-student-license-subscription), they normally send you a reply within a few minutes (hours?).

  • Don't put in too much effort: I can copy-paste vectorised from Scia engineer to inkscape, make the necessary changes there (ungrouping, deleting, detailed editing, changing colours, ....) and then copy-paste from inkscape to IPE. I can't edit this further in IPE, so I have to make sure that what I make in inkscape is "finalised", though, which is a small disadvantage.

  • Note that I can copy-paste vectorised from Scia Engineer to e.g. MS Word, although I cannot edit it further in MS Word: the image is"as a whole", although I copied it as "vector".

  • As mentioned above, I can copy-paste from inkscape to IPE, but it doesn't work the other way arround.

  • When I copy from IPE to MS Word, I get an enormous ammount of text/code, not an image.

  • When I copy-paste from inkscape to MS Word, I get an image.
    I use windows 10.

Stef

@otfried
Copy link
Owner

@otfried otfried commented Aug 13, 2020

KAIST is not on their list of educational institutions. They promised to get back to me about this, but I'm losing hope now.

You say you can paste vector graphics into MS Word. Could you send me such a Word file? If Word preserves the vector graphics, that would be an easy way to test what's going on.

Ipe does not copy to the clipboard except for its own format. It might make sense to copy SVG if this is useful in other software - but the fact that copy-paste from Inkscape gives you an image in Word is discouraging.

@StefPillaert
Copy link
Author

@StefPillaert StefPillaert commented Aug 13, 2020

See attachment. If you want me to ask the people of Scia Engineer either ..

  • to provide you with a licence....

  • to provide more info on how they actually deal with this vector-copy....

... then please let me know: if mostly get rather quick response from their help desk - I'm a "good" client of them, since hundreds of my students use/buy their software.
copypaste as vector from Scia Engineer.docx

@StefPillaert
Copy link
Author

@StefPillaert StefPillaert commented Aug 13, 2020

... but again: I 'd understand perfectly if it would take too much effort to solve this (small) problem.
I'm allready (more than!) glad I can use your magnificent piece of drawing software the way it is now!
Stef

@otfried
Copy link
Owner

@otfried otfried commented Aug 13, 2020

Many thanks for the file, it's quite interesting: the first image is apparently in Windows Metafile Format (basically these are just a sequence of calls to the Win32 API), but the second one (pasted from Inkscape) is a bitmap.

Could you try this version of Ipe:
ipe-7.2.20-win64.zip

When you paste anything into this version, it will pop up a dialog that lists all the formats that it can find on the clipboard, like this:

image

Can you send me a screen shot of this dialog when you paste a drawing from Scia engineer, and when you paste from Inkscape?

@StefPillaert
Copy link
Author

@StefPillaert StefPillaert commented Aug 13, 2020

From Scia Engineer to IPE (as vector):
Scia engineer to IPE
From Inkscape to IPE:
Inkscape to IPE
For completeness sake: from Scia Engineer to IPE, but this time as "raster" (the second option they provide, but not usefull to me, since obviously not editable any more):
Scia engineer to IPE as raster

@otfried
Copy link
Owner

@otfried otfried commented Aug 13, 2020

Thanks, that's very interesting.

So Scia Engineer only exports in Windows Enhanced Metafile format (EMF). This is a Windows-specific vector graphics format tightly coupled to the Win32 GDI API - it doesn't make sense for me to write a parser for this, unless somebody can fund this work.

Inkscape, on the other hand, exports in SVG (plus a bunch of other formats), so in principle Ipe could read the SVG from the clipboard, call svgtoipe.py, and then import the resulting Ipe file.

To import from Scia Engineer, it seems to me that the best solution might be to write a batch script that calls Inkscape to convert EMF to SVG (see https://inkscape.org/~Johannski/%E2%98%85inkscape-batch-convert-svgpdfepsemfwmf-to-epspdfpngsvg for running Inkscape in batch mode), and then calls svgtoipe.py to convert the result to an Ipe file that you can open and copy.

@StefPillaert
Copy link
Author

@StefPillaert StefPillaert commented Aug 14, 2020

examples.zip
Hmmm.... I copy-pasted from Scia Engineer manually to inkscape, did some manipulations in Inkscape, and then saved that file as a .svg (Not exactly the workflow you suggested, but I hope this isn't important?).
Then I ran svgtoipe.py succesfully.
When opening the resulting .ipe, I got this message:
Aantekening 2020-08-14 110645
Probably some parts cannot be converted the rigth way to .ipe...
For completeness, I add the .svg and the .ipe after the conversion:
But, again, it isn't such a big problem, I can live perfectly with the fact that this wouldn't work in IPE. You allready spent soo much time in helping me out...
Thanks,
Stef

@otfried
Copy link
Owner

@otfried otfried commented Aug 14, 2020

Well, that workflow does manually what my suggested batch script would have done automatically.

As you discovered, svgtoipe.py is not perfect. In this case, the problem is that it faithfully translates the SVG paths to Ipe path objects - but Ipe is quite picky about legal path structure, while SVG is very permissive. Your document contains a path with id path2217 and the following structure:

m -49.66431,111.56205 m 180.481,17.87626 m 0,0 v 0 0 0 0

So it starts by setting the current point three times - Ipe doesn't like that.

When I have some time, I need to work on svgtoipe to make sure it cleans all SVG paths so that Ipe will accept them (see also otfried/ipe-tools#46 and and #274).

In any case, here is the file tekening.ipe after I manually fixed the incorrect path:

tekening.zip

It's a gigantic file, I'm not sure how well Ipe can handle these.

If you find other problems with svgtoipe, you could attach example files in the ipe-tools issue tracker, so I have some more test material. I hope to get around to improving svgtoipe in the fall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants