Monday 22 May 2023

Inkscape 1.2 Extension: Musescore Viewbox

This is an extension for Inkscape 1.2 for correcting SVG-files that were exported by Musescore 3 or 4.

These SVGs are always exported with a page size in pixels (at a strange scale factor) and if exporting a selection from Musescore 3 there is stuff that exceeds the Viewbox. (lines etc.) which is a problem when reimporting into Musescore or into Scribus

The extension has the options to

- change page size from pixels to mm
- remove all elements that are outside the page (most of it). 

When you want to use the SVGs in any other software like LibreOffice, Scribus then it is a good idea to change the page size to mm. Only for reimporting into Musescore it is better not to change the (strange) size.

Musescore 4 only can export whole pages but you can open such an SVG in Inkscape, resize the page sized white rectangle to your desired size, then press ctrl+shift+r to resize the actual page to your selection and then run the Extension. This can replace the missing graphic selection tool in Musescore 4.


 

 

Installation:

On Windows extract the zip file into something like this path:
C:\Users\yourname\AppData\Roaming\inkscape\extensions\ 

To find and open the correct folder you can also open Inkscape->Edit->Preferences->System->User Extensions->Open

After installation and restart Inkscape you can run the extension in "Extensions"->Document->Musescore Viewbox. 

 

Usage as .bat-file to process multiple SVGs:

As it is a python script it also can be used to batch process multiple files via command line. 

Put this line into a text-file, edit the paths (yourname) and save as MusescoreViewbox.bat:

for %%a in (%*) do python.exe "C:\Users\yourname\AppData\Roaming\inkscape\extensions\MusescoreViewbox\MusescoreViewboxExtension.py" --px2mm=True --remove_elements=True %%a > %%a_viewbox.svg 

 An example .bat-file is included.

Once created you can drag and drop multiple SVGs onto the MusescoreViewbox.bat-file and the script will generate the corrected SVGs.

Note: If Inkscape is not installed in "C:\Program Files\" you must edit the Python script.

 

Add .bat-file to Send-to-Menu:

You can add the .bat-file to the Windows Send-to-menu.

Open Windows-Explorer and insert this into the address-bar: shell:sendto

This opens the Send-to-folder. Copy the .bat-file into it.

Now you can select all your SVGs, right click -> Send-to -> MusescoreViewbox.bat

 

Download: MusescoreViewbox.zip

   





No comments:

Post a Comment