I would like to create some procedural curves in Touch much like I’ve done with Maya in the past using scripting. I’m not exactly sure where to start. I think I’ll need to use a text Dat to write the script but not sure how to execute it. Here is an example of a Maya mel script I wrote a while ago I would like to recreate in Touch.
curve -p 0 0 0 -n $crv; //create curve at position 0 0 0 and with name crv5
while( $i < 81 )
{
$rad = 2* $theta;
//$rad = 10 * sin ($theta * 1.25);
$theta = $theta + $pi * .1;
$x = $rad * cos ($theta);
$y = 0;
$z = $rad * sin ($theta);
curve -a -p $x $y $z ($crv); //add point to curve at $x $y $z
print " x ";
print $x;
print " y ";
print $y;
print " z ";
print $z;
print " \n ";
$i = $i + 1;
}[/b]
I can’t remember exactly what shape this creates but it basically takes the iteration and creates an angle value then takes that value and converts the polar coordinates to Cartesian.If anyone point me in the right direction to get started I would totally appreciate it.
Any script you write in a Text DAT can be executed by right-clicking on the DAT and selecting “Run Script” from the pop-up menu.
You can also have scripts executed by an event by placing them in CHOP Execute, DAT Execute, Panel Execute, or Parm Execute DATs. Using the parameters of these DATs, you can trigger scripts a multitude of ways.
You’ll have to convert this script to tscript, and for some functions like curve there will be no equivalent.
One way of doing this would be to write all the point positions into a Table DAT that theDat to SOP can read. Change the DAT to SOP Build parameter to Connect All Points to create a connected line of points. Then you can use a Convert SOP to convert this to a Bezier or Nurbs Curve. DATtoSOPcurve.tox (790 Bytes)
thanks Ben, I’ve attempted to recreate the script with Tscript . I’m not sure of a couple things but I think I’ve got a good start.
here is my code so far
tabdelete table1 a
set x=0.0
set y=0.0
set z=0.0
set theta=0.0
set rad=10.0
set i = 0
for i = 0 to 81
set rad = `2*$theta`
set theta = `$theta+$PI*5.0`
set x = `$rad*cos($theta)`
set y = `$rad*sin($theta)`
set z = `($i+1)*20`
tabinsert table1 r $i $x $y $z
set i = `$i+1`
end
I tried to connect the convert Sop in your example to a wireframe Sop but the curve did not get any thicker like it would when I’ve used a channel Sop connected to a wireframe. Is there another way I should do this get a thicker line?
Also is there a way to get a value from a chop as a variable?