Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Help utilizing the JavaScript tool in Alteryx to translate SVG files to XY

jusdespommes
8 - Asteroid

I am trying to take SVG floorplans of buildings and export their XY coords - tldr, essentially achieving something similar to Coordinator - but using Alteryx.

 

I want to use Alteryx to run over these SVG files as they are regularly updated. The initial read of the SVG files is done and working fine reading the files as XML - but I'm stuck when it comes to translating curves, arcs, and effectively anything more than straight lines.

 

To get around this, I have a JS script that runs perfectly locally using Node that reads all SVG shapes and returns coordinates by layer; however, I'm a bit confused as to how to implement it via the JS tool in Alteryx.

 

This is where I'm at so far:

 

jusdespommes_0-1650373158810.png

 

Getting fed in as svgString - is this brief example:

 

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
width="792px" height="612px" viewBox="0 0 792 612" enable-background="new 0 0 792 612" xml:space="preserve">
<g>
<path id="path3789" d="M287.168,442.411
c-8.65,0-15.652,7.003-15.652,15.653
c0,8.65,7.003,15.69,15.652,15.69
s15.653-7.04,15.653-15.69
"/>
</g>
</svg>

 

Expected output should look something like, depending on parameters:

 

jusdespommes_1-1650373946015.png

 

Any help getting the code firing via Alteryx would be massively appreciated. Would be happy to macro and release to the wider community, as I'm sure this would be useful to other people.

1 REPLY 1
jdunkerley79
ACE Emeritus
ACE Emeritus

I don't believe you can use 'import' within this JS tool as I don't believe it runs within Node. Depending on how complicated the library is you might be able to just embed it in the script.

 

You also need to call:

writeAlteryxMetadata(...)
writeAlteryxData(...)

to output data from this tool. 

 

Labels