Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdbbs/0c0eb498b050b1db3cbf30f76b8bb49a to your computer and use it in GitHub Desktop.
Save sdbbs/0c0eb498b050b1db3cbf30f76b8bb49a to your computer and use it in GitHub Desktop.
install fsmMLK/inkscapeDimensions Ubuntu 18.04

Using Ubuntu 18.04, Inkscape 0.92

The user extension directory is ~/.config/inkscape/extensions

We can just directly clone the repositories in the user extension directory (I have had no extensions previously in this directory, so it is empty at start):

$ cd ~/.config/inkscape/extensions/

$ git clone https://github.com/fsmMLK/inkscapeMadeEasy.git
Cloning into 'inkscapeMadeEasy'...
...
Resolving deltas: 100% (371/371), done.

$ git clone https://github.com/fsmMLK/inkscapeDimensions.git
Cloning into 'inkscapeDimensions'...
...
Resolving deltas: 100% (56/56), done.

$ ls
inkscapeDimensions  inkscapeMadeEasy

I'm not going to use Latex here, so I'm not going to download the extension textext from Pauli Virtanen.

Note that, for Inkscape to load an extension - it:

  • either needs an .inx file directly present in the the user extension directory
  • or needs an .inx file in a subfolder, which also has an __init__.py file

That is not the case for either of the above folders - however, we can get around that by symlinking:

$ ln -s inkscapeMadeEasy/*.py .

$ ls -la
total 16
drwxr-x--x 4 user user 4096 Apr 12 09:00 .
drwxr-x--x 7 user user 4096 Oct  4  2018 ..
drwxr-xr-x 4 user user 4096 Apr 12 08:56 inkscapeDimensions
drwxr-xr-x 6 user user 4096 Apr 12 08:56 inkscapeMadeEasy
lrwxrwxrwx 1 user user   41 Apr 12 09:00 inkscapeMadeEasy_Base.py -> inkscapeMadeEasy/inkscapeMadeEasy_Base.py
lrwxrwxrwx 1 user user   41 Apr 12 09:00 inkscapeMadeEasy_Draw.py -> inkscapeMadeEasy/inkscapeMadeEasy_Draw.py
lrwxrwxrwx 1 user user   41 Apr 12 09:00 inkscapeMadeEasy_Plot.py -> inkscapeMadeEasy/inkscapeMadeEasy_Plot.py

$ ln -s inkscapeDimensions/dimensions.* .

$ ls -la
total 16
drwxr-x--x 4 user user 4096 Apr 12 09:02 .
drwxr-x--x 7 user user 4096 Oct  4  2018 ..
lrwxrwxrwx 1 user user   33 Apr 12 09:02 dimensions.inx -> inkscapeDimensions/dimensions.inx
lrwxrwxrwx 1 user user   32 Apr 12 09:02 dimensions.py -> inkscapeDimensions/dimensions.py
drwxr-xr-x 4 user user 4096 Apr 12 08:56 inkscapeDimensions
drwxr-xr-x 6 user user 4096 Apr 12 08:56 inkscapeMadeEasy
lrwxrwxrwx 1 user user   41 Apr 12 09:00 inkscapeMadeEasy_Base.py -> inkscapeMadeEasy/inkscapeMadeEasy_Base.py
lrwxrwxrwx 1 user user   41 Apr 12 09:00 inkscapeMadeEasy_Draw.py -> inkscapeMadeEasy/inkscapeMadeEasy_Draw.py
lrwxrwxrwx 1 user user   41 Apr 12 09:00 inkscapeMadeEasy_Plot.py -> inkscapeMadeEasy/inkscapeMadeEasy_Plot.py

$ tree .
.
├── dimensions.inx -> inkscapeDimensions/dimensions.inx
├── dimensions.py -> inkscapeDimensions/dimensions.py
├── inkscapeDimensions
│   ├── dimensions.inx
│   ├── dimensions.py
│   ├── docs
│   │   └── images
│   │       ├── ANG_explementary.png
│   │       ├     ...
│   │       └── Tab_linear.png
│   ├── LICENSE
│   └── README.md
├── inkscapeMadeEasy
│   ├── CHANGELOG.txt
│   ├── docs
│   │   ├── imagesDocs
│   │   │   ├── arc_centerAngStartAngEnd_flags.png
│   │   │   ├    ...
│   │   │   └── samples_01.svg
│   │   ├── Makefile
│   │   └── source
│   │       ├── conf.py
│   │       └── index.rst
│   ├── examples
│   │   ├── iME_Draw_colorPicker.inx
│   │   ├── iME_Draw_colorPicker.py
│   │   ├── iME_Draw_lineStyle_and_markers.inx
│   │   └── iME_Draw_lineStyle_and_markers.py
│   ├── inkscapeMadeEasy_Base.py
│   ├── inkscapeMadeEasy_Draw.py
│   ├── inkscapeMadeEasy_Plot.py
│   ├── LICENSE
│   ├── README.md
│   └── textextLib
│       ├── basicLatexPackages.tex
│       ├── __init__.py
│       ├── textext.inx
│       └── textext.py
├── inkscapeMadeEasy_Base.py -> inkscapeMadeEasy/inkscapeMadeEasy_Base.py
├── inkscapeMadeEasy_Draw.py -> inkscapeMadeEasy/inkscapeMadeEasy_Draw.py
└── inkscapeMadeEasy_Plot.py -> inkscapeMadeEasy/inkscapeMadeEasy_Plot.py

Since we don't use Latex here, first we need to disable the use of Latex, by opening inkscapeMadeEasy_Draw.py in a text editor (here nano):

$ nano inkscapeMadeEasy_Draw.py

... and uncommenting the line with useLatex=False, and saving the file.

At this point, the extension should be recognized by Inkscape, however, loading it will fail with:

Traceback (most recent call last):
  File "dimensions.py", line 6, in <module>
    import inkscapeMadeEasy_Base as inkBase
ImportError: No module named inkscapeMadeEasy_Base

The reason for this is: due to symlinking, Inkscape's extension Python does not pick up the user extension directory ~/.config/inkscape/extensions in sys.path, but instead it picks up ~/.config/inkscape/extensions/inkscapeDimensions - and then it cannot find any other extension.

That can be fixed with the following patch in ~/.config/inkscape/extensions/inkscapeDimensions/dimensions.py:

diff --git a/dimensions.py b/dimensions.py
index 288a311..f6efdfc 100644
--- a/dimensions.py
+++ b/dimensions.py
@@ -1,6 +1,15 @@
 # -*- coding: utf-8 -*-
 # !/usr/bin/python
 
+import sys
+import os
+# possibly because of symlink, ~/.config/inkscape/extensions is not in module path - add it
+userextdir = os.path.expanduser('~/.config/inkscape/extensions')
+sys.path.append(userextdir)
+# hide/comment the debug print if not needed; otherwise inkscape GUI will report:
+# "Inkscape has received additional data from the script executed.  The script did not return an error, but this may indicate the results will not be as expected."
+#sys.stderr.write(str(sys.path)+"\n") # debug print
+
 import math
 
 import inkscapeMadeEasy_Base as inkBase

After this patch has been implemented in the file dimensions.py, and the file saved - upon startup, Inkscape should be able to find the extension, and create the menu entry Extensions/fsmMLK/Dimensions... (and, the extension should run - at least with the basic functions - without crashing; although some functions do crash)

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