• Stars
    star
    154
  • Rank 242,095 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A pipeline for handling the SOP to SVG pipeline. This is especially handy for using procedurally generated geometry for paths to be cut or plotted.

touchdesigner-sop-to-svg

Matthew Ragan

matthewragan.com
A pipeline for handling the SOP to SVG pipeline. This is especially handy for using procedurally generated geometry for paths to be cut or plotted.

Dependencies

TouchDesigner 099 - https://www.derivative.ca/099/Downloads/ This tox is written and maintained in 099.

SVG Write - https://pypi.python.org/pypi/svgwrite/ This tox requires the Python library SVG Write to function correctly. If you're familiar with adding external Python libraries in Touch please carry on. If that's a new process to you, I'd recommend that you read through the python documentation on the derivative wiki:
https://www.derivative.ca/wiki099/index.php?title=Introduction_to_Python_Tutorial

Adding Dependencies to TouchDesigner

If you'd like to add the modules directly to your TouchDesigner folder you can do that with the following commands

Windows

First install Python 3.5.1
From the command line pip install --target=/path/to/your/packages/directory/for/TD package_to_install

There's a good chance that looks like:
From the command line pip install --target="C:\Program Files\Derivative\TouchDesigner099\bin\Lib\site-packages" svgwrite

MacOS

First install Python 3.5.1
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
python3 -m pip install --target=/Applications/TouchDesigner099.app/Contents/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages svgwrite

Overview

Scalable Vector Graphics (SVG) are a handy means of creating images that aren't bound by the rules of raster graphics. Illustrators and designers often use SVGs for a variety of purposes, but they're especially interesting when it comes to interacting with plotting and cutting machinery. Laser and vinyl cutters, plotters and all manner of other devices can use SVGs rather than raster based graphics.

Derivative's TouchDesigner is well known for working with raster based graphics, but there's little support for capturing and outputting SVGs as a built in approach. It does, however, support a robust python layer which is capable of handling this task. The primary design in this TouchDesigner module is to target the process of converting Surface Operators (SOPs) to SVGs so they can be plotted or laser cut.

plot1

To that end in this TOX you'll find several means of capturing and plotting your geometry.

Feature and Parameters

Not all geometry is created equal, and while it's lovely to imagine that there might be a single perfect way to handle drawing all shapes, but alas it's a little more dicey than that when plotting lines. A large concern here is the need to be able to draw closed shapes, open shapes, and images that have both closed and open shapes.

This is addressed through a set of custom parameters and a python extension. The python extension can be found inside of the base_sop_to_svg tox as svgEXT. If Python is in your wheelhouse, take a look inside the tox as the methods and members are documented inside of this extension.

Parameter Description and Function
Polyline SOP This parameter accepts a SOP and should be a group of any primitives you'd like to have drawn as open polylines. Important to note, the extension will draw each primitive in your SOP as its own open shaped polyline.
PolygonSOP This parameter accepts a SOP and should be a group of any primitives you'd like to have drawn as closed polygons. Important to note, the extension will draw each primitive in your SOP as its own closed shape polygon.
Canvas Size The axidraw (my primary plotting device) supports two different canvas sizes: Letter and A4. Using this parameter will help ensure that your svg is correctly set up to export at dimensions that are friendly to inkscape for plotting right away without needing additional document setup.
Destination Directory This should be a path to your desired directory location for your file. It's important to note that TouchDesigner has an undesirable legacy feature that uses a built in variable $TOUCH that represents the location of your project file. Using this variable will result in an error at save. To avoid this, make sure that your save destination is not the same as where your project is saved. If you're using an un-saved project, this typically defaults to the desktop - in this case, save to a destination other than your desktop.
File Name The string name for your file. The file extension .svg will be added to your saved file - you do not need to include this.
SVG Type Here you can choose to save an SVG that's comprised of polygons and polylines, only polylines, or only polygons. Use the appropriate menu selection to match your intended output.
Save SVG Click to save to file.
Use Camera Toggle on to use perspective camera, Toggle off for orthographic rendering.
Aspect The aspect ratio for the final output. Not really used.

Using the TOX

Let's look at a simple use case where we want to draw both closed and open shapes.

Drawing Closed Shapes

Let's use a circle SOP set to 3 divisions.

circle-div3

Next we'll use a copy SOP to make 7 copies. Let's set the rz parameter to 8, and the uniform scale parameter to 0.8.

copy circle

Let's connect this to a null SOP, and then drag and drop the null SOP onto the Polygon SOP parameter. Select a canvas size, destination directory, and name your file. Make sure to select the Polygon only SVG Type, and click save.

svg settings

Congratulations, you've made your first SVG out of SOPs.

Drawing Open Shapes

Let's start with a circle SOP with 40 divisions. Let's make sure our arc type is set to open, and our arc angles are set to 90.

ope arc

Next let's connect a copy SOP to make 7 copies. This time let's change our rz par to 45, and our uniform scale to 0.8.

copy sop

Connect your copy SOP to a null SOP, now drag and drop your null onto the Polyline SOP parameter. Select a canvas size, destination directory, and name your file. Make sure to select the Polygon only SVG Type, and click save.

poly line settings

Congratulations, you've made your second SVG out of SOPs.

More Repositories

1

TD-Examples

TouchDesigner Examples
Python
323
star
2

BOS-in-TouchDesigner

A port of the Book of Shaders to TouchDesigner
GLSL
152
star
3

learningGLSL

Python
141
star
4

td_fb_forum_examples

Batchfile
88
star
5

touchdesigner-save-external

a simple save external tox and text helper
Python
59
star
6

touchdesigner-hueControl

Components for controlling hue lights from TouchDesigner
Python
51
star
7

glsl2dTuts-in-TouchDesigner

GLSL
43
star
8

touchdesigner-dominant-color

An approach for finding dominant color in an image using KMeans clustering with scikit learn and openCV. The approach here is built for realtime applications using TouchDesigner and python multi-threading.
Python
40
star
9

touchdesigner_light_volume

36
star
10

make_some_noise_2017

Support materials for a TouchDesigner Workshop / Makeshop hosted by Obscura Digital in San Francisco CA.
30
star
11

touchdesigner_yale_workshop_2017

30
star
12

python_for_td

Python
28
star
13

touchdesigner-deferred-lighting

A look at how to accomplish deferred lighting in TouchDesigner 099
26
star
14

AME394

Sample files for AME 394
21
star
15

THP494-598

Files for THP 494 and 598
20
star
16

touchdesigner-template-tox-dev

a template for building a stand alone tox
Python
19
star
17

touchdesigner-multi-threading

A look at how to use multiple threads in python with TouchDesigner
Python
19
star
18

touchdesigner-config-with-env-vars

TouchDesigner Configuration with Environment Variables
Python
15
star
19

blog-td-subprocess

Working with Subprocess and TouchDesigner
Python
13
star
20

touchdesigner-style-ragan

A repo of TouchDesigner style gude elements
CSS
13
star
21

touchdesigner-reusable-frameworks

Python
10
star
22

touchdesigner_virtual_cameras

A closer look at virtual camera setups, and how to exploit them in TouchDesigner
10
star
23

touchdesigner-heartbeats

a simple process heartbeat tox
Python
9
star
24

blog-td-light-tracking-previs

9
star
25

touchdesigner-tdsw-obs-websockets

Python
9
star
26

touchdesigner-tox-prep-for-release

A general tool for packaging up a TOX into a release ready format
Python
8
star
27

td_tools_release-collection

Python
7
star
28

touchdesigner-process-managment

A look at how you can launch another process from TouchDesigner with Python, and how you can kill that process.
7
star
29

touchdesigner-learning-opencv

Python
6
star
30

touchdesigner-machine-grouping

A first look at possible mechanisms for handling mirrored networks
Python
6
star
31

touchdesigner-reusable-code-segmentation-python

Python
5
star
32

touchdesigner-python-version-installer

Python
4
star
33

touchdesigner_ldi_2017

Support materials for the 2017 LDI workshop
4
star
34

touchdesigner_config_and_startup

Python
4
star
35

touchdesigner-node-red-com-example

Example of sending data from TouchDesigner to Node Red
4
star
36

touchdesigner-community-examples-code

Python
3
star
37

touchdesigner-sop-points-to-csv

a simple tool for saving out a SOP point cloud as a CSV
3
star
38

HQ-advanced-advanced-rendering

3
star
39

touchdesigner-community-examples

SCSS
3
star
40

hq-coaching-crystal

Python
3
star
41

td-general-tools

A set of reusable and modular tools for use in TouchDesigner
3
star
42

touchdesigner-external-presets

Python
2
star
43

blog-td-stoner-project-par

2
star
44

OTGMixer

A live video mixing tool for Orange Theatre Group
2
star
45

touchdesigner-roboCopy

A helper for syncing media files between machines
2
star
46

touchdesigner-palette-pop-up

A look at creating a pop up op-create style dialogue for the touchdesigner palette
Python
2
star
47

touchdesigner-ui-2020

2
star
48

touchdesigner_curly_paths

A look at how you might think about moving objects along paths - from single objects to multiple instances.
1
star
49

touch_git_example

A simple example for how to use git with TouchDesigner
1
star
50

multi_stoner_example

Python
1
star
51

touchdesigner_ldi_advanced_2018

1
star
52

touchdesigner-python-externals

Python
1
star
53

experiments

a z|m m|z experiments and learning space
1
star
54

touchdesigner_ldi_python_2018

1
star
55

touchdesigner-com

1
star
56

touchdesigner-skl-project

A project skeleton
Python
1
star
57

hq-coaching-scott

GLSL
1
star
58

ModuleAndStorageExamples

1
star
59

touchdesigner_ldi_intro_2018

LDI 2018 TouchDesigner repo
1
star
60

touchdesigner-lister-blog

1
star
61

techniques-iris-variations

1
star