Macros in Inkscape

Introduce yourself, get to know each other.
amit
Posts: 4
Joined: Thu Oct 15, 2015 7:03 pm

Macros in Inkscape

Postby amit » Thu Oct 15, 2015 7:14 pm

Hello Everyone,

I want to know that can we write macros in Inkscape? If yes, please tell me how to write a macro for saving a image in more than one format as we can do the same in MS Excel and MS Powerpoint. Please reply.

Thanks and Regards
Amit

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Macros in Inkscape

Postby Moini » Thu Oct 15, 2015 11:36 pm

Hi Amit,

while there are no 'macros', there are some other options (depending on the file formats you want to save to):

- you could write an extension. A short tutorial is available here: https://medium.com/@xaviju/inkscape-ext ... 72dda360fe and you will need to look into existing extensions to learn.

- you can (more quickly) write a simple shell script. Inkscape has a command line interface that allows for exporting to other file formats (png, eps, ps, pdf). If those four (+ those you can access via extensions you have installed) are enough for you, this is the fastest option.
See https://inkscape.org/en/doc/inkscape-man.html for more info. Imagemagick (http://www.imagemagick.org) could help with converting from png to other raster formats. Pngquant (https://pngquant.org/) can help keep png file sizes small.

- or (if you want to export to vector formats only), there's also uniconvertor: http://sk1project.org/modules.php?name= ... iconvertor

Regards,
Moini
Last edited by Moini on Fri Oct 16, 2015 4:15 am, edited 1 time in total.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

amit
Posts: 4
Joined: Thu Oct 15, 2015 7:03 pm

Re: Macros in Inkscape

Postby amit » Fri Oct 16, 2015 3:17 am

thanks Moini

I am using svg and emf formats at the same time. So I want to write an extension which directly saves the file in these two extensions automatically.

Please help me in this regard

Thanks and Regards
Amit

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Macros in Inkscape

Postby Moini » Fri Oct 16, 2015 4:14 am

Sorry, Amit - I don't know how to go about this in detail. Maybe someone else here does?

Edit: Uniconvertor 'speaks' WMF, would that work, too?
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Macros in Inkscape

Postby brynn » Tue Oct 20, 2015 2:06 pm

Hi amit,
(from viewtopic.php?f=32&t=18449#p74925)

I never answered in this topic because Moini gave a better answer than I could give. I don't even know what a "macro" is :oops:

To write an extension, you would have to know the Python code (as far as I understand). Or be willing to learn. Writing an extension will allow other people to use it as well. But if you just need this for a one time job, it doesn't make sense to write the extension (like others in the Extensions menu).

As far as I know, to do what you want will take a custom script. I'm guessing you have a large number of files that need to be converted to both SVG and EMF, and you want to do it quickly? Or do you want to draw new images with Inkscape, that are saved automatically both ways?

Do you have any coding skills yourself?

If not, maybe someone here has the skills to write a script for you. They would probably need some more info, although I'm not sure what. Could you give us any further details about this project?

amit
Posts: 4
Joined: Thu Oct 15, 2015 7:03 pm

Re: Macros in Inkscape

Postby amit » Wed Oct 28, 2015 4:55 am

Thanks Brynn

I have large no. Of images which I need for designing manuals. These images are in bulk that's why I need ur help. I have no idea about coding as I am a VLSI design engineer.
Please help me Brynn

Regards
Amit

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Macros in Inkscape

Postby brynn » Wed Oct 28, 2015 9:07 am

VLSI.... [looks it up....] You design/build computer chips/boards? Don't you have resources within your business, to write a script for you? Can't call tech support?

I'm afraid there's not much I can do myself. I don't know how to write any kind of script. (Well that's not true. I can write simple HTML, but that won't do what you need.)

What format are the images that need to be converted? Since you mentioned MS programs in your first message, I guess you're on Windows (which someone would need to know, to write you a script, I guess)?

Hhmmm....I've heard about a graphics program called IrfanView. It's basically a raster editor, as far as I understand. But it's been said to have the ability to work with a wide variety of graphic formats, and as far as I can recall, can do batch conversions (even vector, I think). I heard this at least 5 to maybe 7 or 8 years ago though, so it may not still be true. But I think definitely worth looking into. I think there's a good chance it might work for you.

I also seem to recall that you might need to install various extensions with IrfanView, depending on which formats you're working with. I have a vague recollection of using it for a batch conversion, around 5 to 8 years ago, so that's how I've heard about this. There must have been some good documention, because I wouldn't be remembering this otherwise (haha).

Also, there are online file format converters all over the internet. Many may distribute malware, or otherwise have nefarious intentions, so be sure to do some good research, if you look for an online converter. Yes, there are some good and reputable ones. Unfortunately, I don't happen to know any names or addresses for them.

Anyone know any good online converters? (Or have time to write a script for Amit?)

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Macros in Inkscape

Postby Moini » Wed Oct 28, 2015 12:11 pm

Hi amit,

so now I know that someone actually wrote a page about writing extensions for our website:
https://inkscape.org/en/develop/extensions/

If you want to go that way, you should take a look there. The extensions you can consult for how to save the Inkscape file are, for example, the one called scour.py and there must be something in the gcodetools files, too.

If you only want to use wmf, that will be simple enough, because uniconvertor is used in other extensions, and you can just copy-paste.
Else (for emf) you might need to find a command line tool that can convert svg to emf, and make use of it in your extension.

This is probably what I would do:
You could also just write a script that watches over your image directories for changes, and if a file is changed, converts it to emf.
This would not require any extra extensions, or anything more than pressing Ctrl+S to save a file and update your wmfs at the same time.
There must be several examples in python and ruby available on the web, as django, pelican, jekyll and other web frameworks provide this kind of thing.
Only thing you need to find is something that converts svg to emf.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Macros in Inkscape

Postby ~suv » Wed Oct 28, 2015 3:22 pm

Moini wrote:Else (for emf) you might need to find a command line tool that can convert svg to emf, and make use of it in your extension.

Inkscape >= 0.91 does have cross-platform internal support for WMF/EMF input and output, this also works via command line:

Code: Select all

  -M, --export-emf=FILENAME    Export document to an Enhanced Metafile (EMF) File
  -m, --export-wmf=FILENAME    Export document to a Windows Metafile (WMF) File

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Macros in Inkscape

Postby Moini » Thu Oct 29, 2015 3:41 am

Ah - thanks, suv! - found it in 0.91 release notes now :)
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

Refaeliadria
Posts: 2
Joined: Fri Apr 22, 2016 7:21 pm

Re: Macros in Inkscape

Postby Refaeliadria » Wed May 11, 2016 7:30 pm

Array
Convert
Loop
Replace
Select
Verbs


Return to “Personal discussions”