Skip to content

Conversation

Copy link

Copilot AI commented Sep 14, 2025

This PR implements a complete TouchDesigner .tox component solution for generating random numbers with configurable parameters. The implementation provides a DAT Script that generates random numbers within a specified range and outputs them to a DAT table with precise formatting.

Features Implemented

Core Functionality:

  • Configurable minimum and maximum range parameters
  • Configurable number of rows (output size)
  • Random number generation using Python's random.uniform()
  • All output values automatically rounded to exactly 2 decimal places
  • Output written to DAT table with one random number per row
  • Comprehensive error handling for invalid parameters

TouchDesigner Integration:

  • Ready-to-use DAT script (touchdesigner_dat_script.py) for direct copy-paste into TouchDesigner
  • Automatic parameter reading from parent component
  • Proper DAT table manipulation using TouchDesigner's API
  • Error messages displayed in the output table for invalid configurations

Files Added

  • touchdesigner_dat_script.py - Main script for TouchDesigner DAT operator
  • random_number_generator.py - Standalone Python version for development/testing
  • TOUCHDESIGNER_SETUP.md - Detailed setup instructions for TouchDesigner
  • demo.py - Interactive demonstration showing all functionality
  • test_random_generator.py - Comprehensive unit test suite (5 test cases)
  • EXAMPLES.md - Common parameter configurations and use cases

Usage Example

# Parameters configured in TouchDesigner component:
# Min Range: 10.0
# Max Range: 50.0  
# Number of Rows: 5

# Example output in DAT table:
Random Numbers
23.45
41.78
15.92
38.14
29.67

Validation

The implementation includes comprehensive testing:

  • Unit Tests: 5 test cases covering core functionality, parameter validation, and edge cases
  • Demonstration Script: Interactive demo showing various parameter configurations
  • Error Handling: Validates min < max range and positive row count

All tests pass and the demonstration confirms correct behavior across different parameter ranges including negative numbers, decimals, and large values.

Setup Instructions

Users can follow the detailed setup guide in TOUCHDESIGNER_SETUP.md to:

  1. Create a TouchDesigner component with custom parameters
  2. Copy the DAT script into a Text DAT operator
  3. Configure parameter bindings
  4. Execute the script to generate random numbers

This implementation fully satisfies the requirements for a TouchDesigner .tox that generates configurable random numbers with precise 2-decimal formatting in a DAT table structure.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ameters

Co-authored-by: Tombkn <178416194+Tombkn@users.noreply.github.com>
Copilot AI changed the title [WIP] This TouchDesigner .tox contains a DAT Script that allows you to configure a min and max range, as well as the number of rows. Each time it is executed, the script generates random numbers within the defined range. The output values are written into a ... Implement TouchDesigner Random Number Generator with Configurable Parameters Sep 14, 2025
Copilot AI requested a review from Tombkn September 14, 2025 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants