Inkscapeパスの取得

inkscape-get-path.png
#!/usr/bin/env python
#coding: UTF-8
import sys,os
sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions")
import cubicsuperpath
...中略
#パスの頂点座標を取得
points = cubicsuperpath.parsePath(path.get('d'))

パスの座標の配列化 simplepathを使うか、cubicsuperpathを使うか?

simplemath cubicsuperpath
[['M', [40.406101999999997, 151.30610999999999]], ['L', [96.974644999999995, 243.22998999999999]], ['L', [177.78684999999999, 147.2655]], ['L', [117.1777, 105.84923999999999]]]
[[[[40.406101999999997, 151.30610999999999], [40.406101999999997, 151.30610999999999], [40.406101999999997, 151.30610999999999]], [[96.974644999999995, 243.22998999999999], [96.974644999999995, 243.22998999999999], [96.974644999999995, 243.22998999999999]], [[177.78684999999999, 147.2655], [177.78684999999999, 147.2655], [177.78684999999999, 147.2655]], [[117.1777, 105.84923999999999], [117.1777, 105.84923999999999], [117.1777, 105.84923999999999]]]]
[[0, 0], [0, 1052.3622046999999], [744.09448818999999, 1052.3622046999999], [744.09448818999999, 1052.3622046999999]]

座標だけ取るには?

#パスの頂点座標を取得
vals=simplepath.parsePath(path.get('d'))
for cmd,params in vals:
        #MとかLとか
    inkex.errormsg("cmd:"+str(cmd))
    #こちらが座標です
    inkex.errormsg("params:"+str(params))

なぜd?

Elementの持っているkeyは以下になります

['style', 'd', 'id', '{http://www.inkscape.org/namespaces/inkscape}connector-curvature']

サポートサイト Wikidot.com