Skip to content

Commit fb8070b

Browse files
committed
initial inkscape integration
1 parent 4cfbd75 commit fb8070b

6 files changed

Lines changed: 87 additions & 0 deletions

File tree

example/basic/manifest.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ departments:
4949
blender:
5050
exports:
5151
- .mesh.blend
52+
design:
53+
programs:
54+
inkscape: {}
5255

5356
assets:
5457
3d:
@@ -68,6 +71,12 @@ assets:
6871
departments:
6972
layout:
7073
- !depends(defaultCubeA;defaultCubeB) cubeInstancer
74+
2d:
75+
icons:
76+
- iconA:
77+
departments:
78+
design:
79+
- vector
7180

7281
shots:
7382
'103':
Lines changed: 5 additions & 0 deletions
Loading

integration/inkscape/conduct

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../common/
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
3+
<name>Create Setup</name>
4+
<id>com.lagmachine.conduct.create_setup</id>
5+
<param type="path" name="manifest" gui-text="Manifest File" mode="file" filetypes="yaml,yml" />
6+
<effect needs-live-preview="false" show-stderr="true">
7+
<object-type>all</object-type>
8+
<effects-menu>
9+
<submenu name="Conduct" />
10+
</effects-menu>
11+
</effect>
12+
<script>
13+
<command location="inx" interpreter="python">conduct_create_setup.py</command>
14+
</script>
15+
</inkscape-extension>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import inkex
2+
from inkex import command
3+
import os
4+
from conduct import conduct
5+
import subprocess
6+
7+
class ConductCreateSetup(inkex.EffectExtension):
8+
9+
def add_arguments(self, pars):
10+
pars.add_argument("-m", "--manifest", default="", help="Manifest File Path")
11+
12+
def effect(self):
13+
path = self.options.manifest
14+
c = conduct.get_from_manifest_path(path, "inkscape")
15+
result = c.setup()
16+
17+
if result['result'] != 'ok':
18+
return
19+
20+
dialog_data = result['data']
21+
path = os.path.join(dialog_data['path'], dialog_data['file_name'] + ".svg")
22+
23+
self.svg.set("com.lagmachine.conduct.asset", dialog_data['asset'])
24+
self.svg.set("com.lagmachine.conduct.department", dialog_data['department'])
25+
if dialog_data['shot'] is not None:
26+
self.svg.set("com.lagmachine.conduct.shot", dialog_data['shot'])
27+
28+
# write to new file, and open it in a new instance of inkscape
29+
# this is the best i can do, there is no function for changing the current file to a different location
30+
data = self.svg.tostring().decode('utf-8')
31+
32+
with open(path, mode='w') as f:
33+
f.write(data)
34+
35+
exe = inkex.command.which('inkscape')
36+
37+
#if we could find a good way to kill the original inkscape instance after starting the new one, that would be ideal
38+
if os.name == 'nt':
39+
creation_flags = subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.DETACHED_PROCESS
40+
proc = subprocess.Popen([exe, path], creationflags=creation_flags, start_new_session=True)
41+
else:
42+
proc = subprocess.Popen([exe, path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL)
43+
44+
if __name__ == '__main__':
45+
ConductCreateSetup().run()

integration/inkscape/shell.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
let pkgs = import <nixpkgs>{};
3+
4+
shell = pkgs.mkShell {
5+
buildInputs = with pkgs; [
6+
inkscape
7+
];
8+
9+
WEBKIT_DISABLE_COMPOSITING_MODE=1;
10+
};
11+
12+
in shell

0 commit comments

Comments
 (0)