Getting output from a Python script text DAT?

So, I have a text DAT with a Python script inside. This script, when run, prints the URL of a JPG image. Now, I want to load this image URL inside the ‘File’ field of a MovieFileIn TOP. I tried using op(“text1”).text, but this isn’t working. What’s the proper way to do this? Thanks!

two options here:

  1. take out your command to print the url, and only put the web address in the text dat. Using this method, your current means of referencing the text dat should work.

  2. rather than printing the url, target your moviefilein top and set the file parameter to be equal to the url:

[code]url = “https://i1.wp.com/media.boingboing.net/wp-content/uploads/2017/01/fleming2.jpg?w=680

op( ‘moviefilein1’ ).par.file = url[/code]

Now when you run your script rather than printing out the url, you’ll target your moviefilein TOP, and set the file parameter to be the web link.

The second method works great! I didn’t know about the “par” property.

I can’t really use the first method because the text DAT script is parsing a JSON string from a web DAT.

Just out of curiosity, how would I reference the output of the text DAT if I needed to? Is this possible?

Well, it depends.

Assuming that you’re using a variable name for your path, then you can access the contents of your text dat with a mod call.

for example:

mod( 'text1' ).url

This should also work if you’re dealing with a json object:

[code]paths = {
“url1” : “https://i1.wp.com/media.boingboing.net/wp-content/uploads/2017/01/fleming2.jpg?w=680
}

[attachment=0]base_settings_paths.tox[/attachment]
mod( ‘text3’ ).paths[ ‘url1’ ][/code]
base_settings_paths.tox (630 Bytes)

Awesome, thanks!

Hey philjms,
Just to help get your oriented with python in TouchDesigner, when you click the “Python Help” button in the parameter dialog for any OP you will go to its python class help. This button is the “?” with python blue/yellow on it.

Python classes are hierarchical in TouchDesigner. So the textDAT Class is also inherits the DAT Class which then inherits the OP Class and so on. If you scroll down in the textDAT Class help you will come across the OP Class help as well. Since all OPs have parameters, the par member is found in the OP Class.

There are all sorts of useful tools in there, it’s worth a once over.

In addition, if you would like to see the entire python class hierarchy tree in TouchDesigner, it is on this page:
derivative.ca/wiki099/index. … ory:Python