Partical.grt
Published in

Partical.grt

Call Functions from Another Operator in TouchDesigner — Tip in TouchDesigner#8

In TouchDesigner, we always use op() to get a single operator to read its value or change it.

What if I wrote a function in a Text (DAT) and want to call it from other operators, could I use op() to get the target function?

-

-

No

You cannot use op() to get the function inside.

-

The solution is → mod()

mod() will use the target operator like a module.

According the official document:

The MOD class provides access to Module On Demand object, which allows DATs to be dynamically imported as modules. It can be accessed with the mod object, found in the automatically imported td module. Alternatively, one can use the regular python statement: import. Use of the import statement is limited to modules in the search path, where as the mod format allows complete statements in one line, which is more useful for entering expressions. Also note that DAT modules cannot be organized into packages as regular file system based python modules can be.

Okay, that’s so much.

Let’s just explain it with a example will be really easy to understand

mod(DAT Name).FUNCTION NAME()

Create a Text (DAT) “text1” and write a function to print “Happy Programing” inside.

And create another Text (DAT) to just write down a script using mod().

When I Run Script “text2”, you can see it printed out in the Textport dialog.

That’s it. You just use script in “text2” to call a function inside “text1”.

I really think this is a useful knowledge I hope I knew it when I first to learn.

Refer:

--

--

--

Just some the tips and tutorials on my creating journey. I think you will find something useful. 😉 Instagram: https://www.instagram.com/partical.grt/. TouchDesigner Snippet & Works: https://partical.notion.site

Recommended from Medium

Daily progress — Enemy shared behavior

Second PXP burn complete

Top 3 Programming Languages For Implementing a Computer Vision System

Completion: NFT Blast Development for Governance

Part 9: Buy Crypto with Fiat

Writing a Code Editor with Layers (Part 3)

Is “Angela Yu: Web Development Bootcamp 2022” worth for beginners ?

Kanban Boards, To-Do Lists and More: Which Style is Best for Your Small Business Project Management

Best project management software

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Partical Weng

Partical Weng

A person love new things and extremely futurism.

More from Medium

Three underused Developer Tools to understand your code

Journey of DLithe Bootcamp .NET Full Stack Developer | Week 4 (Feb14-Feb19)

Writing Clean, Scalable, DRY Code

How to Season Your Database, With Some Bits of Salt and Pepper