Rewrote the script using GCoder. Now non-closed paths are supported