For anyone who’s working through this technique - it’s actually better to attach the Constant MAT directly to the Geo COMP’s Material Parameter instead of using a Material SOP. SOPs are CPU-based and COMPs work with the GPU - you’ll have better performance when doing calculations on the GPU. It’s considered a best practice to apply materials via the Geo COMP. In the case of this network it might not make that much of a difference in terms of performance, but for those just building the network for the first time, I’d recommend making this small change. Let me know if you have any questions!
Thank you! Definitely, as long as you are able to solve for y and x, you’ll be able to assign the output of the equations to a constant CHOP as we’ve done here.
Thanks for this! for some reason I get a script error in onValuechange..but I've double checked and it's the same as your script..I get: TypeError: unsupported operands type(s) for *: 'NoneType' and 'float'
Hi Nicholas, Thanks for reaching out, glad you liked the video! I think this might be an issue with variable assignment or syntax issue. If you get a chance, post the code from your CHOP Exec DAT as a reply and I'll take a look. It'll be easier to troubleshoot that way.
@@NicholasCarn Hi Nicholas, Your code actually looks perfect! I tested it on both Mac and Windows versions of TouchDesigner and had no issues. I was able to recreate this error in one particular situation, though, which I’ll explain briefly. The TypeError: unsupported operands type(s) for *: 'NoneType' and 'float’ error occurs when one of the variables used in the equations within the onValueChange() function wasn’t correctly assigned a value. The code is saying that it can’t multiply the float values (decimal numbers) in the rest of the equation by a variable that has nothing assigned to it (NoneType). From the “*” we know that the error is occurring at a point of multiplication. We also know that the ‘NoneType’ variable is before the * sign, because it comes first in the error. If we look at our equation again, this means that it is likely your ‘p’ variable that is giving you trouble. If one of the radius values were incorrectly assigned, we would get the error TypeError: unsupported operands type(s) for +: 'NoneType' and 'float’ if it was R (radius1) and TypeError: unsupported operands type(s) for +: 'float’ and 'NoneType' if it was r (radius2). This is because these values are added together first in the equation, so if one of them was incorrectly assigned, we wouldn’t make it to the * part of the equation before receiving an error. Since everything looks good with your Python code, I’m thinking the title of the “position” CHOP channel within the constant_null might be misspelled or have an extra character added to it. Check within your Rename CHOP to see if this is the case. When I misspell the name to “position1” or “positio” in my version of the network, I get the same error that you do. If the Rename CHOP had the position channel name entered incorrectly, make sure it’s changed to read “position” (no quotes) and then right click on the CHOP Exec DAT and hit “Run Script”. This will cause the script to reload and will usually clear the error flag. Note that the error flag will not clear if you just change the CHOP channel name, the script needs to be run again. If the Rename CHOP had the position channel name entered correctly, then there is a chance that it was entered incorrectly at some point and the CHOP Exec DAT is still showing an old error. Try right clicking on it and hitting “Run Script” to see if this clears the error. I hope this helps! Let me know how you fare.
@@jackdilaura wow, thanks so much for spending the time sleuthing that one, but you got it :) It was the "position" name in the rename CHOP, I missed an 'i' and spelt "postion" by mistake. I thought I checked everything. This is why I often struggle with coding, one misspelt letter and it's hard to track down where it's gone wrong. Thanks again :)
@@NicholasCarn Amazing!! Glad to hear that fixed it. I know that struggle well, those errors can be really hard to track down, especially across different operators/pieces of code within TouchDesigner. Hope you have fun experimenting with the technique now that it’s running!
For anyone who’s working through this technique - it’s actually better to attach the Constant MAT directly to the Geo COMP’s Material Parameter instead of using a Material SOP. SOPs are CPU-based and COMPs work with the GPU - you’ll have better performance when doing calculations on the GPU. It’s considered a best practice to apply materials via the Geo COMP.
In the case of this network it might not make that much of a difference in terms of performance, but for those just building the network for the first time, I’d recommend making this small change. Let me know if you have any questions!
Great tutorial Jack! Thank you very much, it is quite funny to see how much work 2 simple lines of codes saves us from
Very clearly explained and quite educational Jack - thanks very much!
very cool video and technique! Thank you for making this video!
Thank you, glad to hear you like it! More to come!
amazing technique! would this work with other geometrical equations as well?
Thank you! Definitely, as long as you are able to solve for y and x, you’ll be able to assign the output of the equations to a constant CHOP as we’ve done here.
Thanks for this! for some reason I get a script error in onValuechange..but I've double checked and it's the same as your script..I get: TypeError: unsupported operands type(s) for *: 'NoneType' and 'float'
Hi Nicholas,
Thanks for reaching out, glad you liked the video! I think this might be an issue with variable assignment or syntax issue. If you get a chance, post the code from your CHOP Exec DAT as a reply and I'll take a look. It'll be easier to troubleshoot that way.
@@jackdilaura Hi Jack, thanks for checking it out:
R = op('constant_null')['radius1']
r = op('constant_null')['radius2']
p = op('constant_null')['position']
def onOffToOn(channel, sampleIndex, val, prev):
return
def whileOn(channel, sampleIndex, val, prev):
return
def onOnToOff(channel, sampleIndex, val, prev):
return
def whileOff(channel, sampleIndex, val, prev):
return
def onValueChange(channel, sampleIndex, val, prev):
op('pos_constant').par.value0 = (R + r) * math.cos(val) + p * math.cos((R + r) * val / r)
op('pos_constant').par.value1 = (R + r) * math.sin(val) + p * math.sin((R + r) * val / r)
return
@@NicholasCarn Hi Nicholas,
Your code actually looks perfect! I tested it on both Mac and Windows versions of TouchDesigner and had no issues.
I was able to recreate this error in one particular situation, though, which I’ll explain briefly.
The TypeError: unsupported operands type(s) for *: 'NoneType' and 'float’ error occurs when one of the variables used in the equations within the onValueChange() function wasn’t correctly assigned a value. The code is saying that it can’t multiply the float values (decimal numbers) in the rest of the equation by a variable that has nothing assigned to it (NoneType).
From the “*” we know that the error is occurring at a point of multiplication. We also know that the ‘NoneType’ variable is before the * sign, because it comes first in the error. If we look at our equation again, this means that it is likely your ‘p’ variable that is giving you trouble. If one of the radius values were incorrectly assigned, we would get the error TypeError: unsupported operands type(s) for +: 'NoneType' and 'float’ if it was R (radius1) and TypeError: unsupported operands type(s) for +: 'float’ and 'NoneType' if it was r (radius2). This is because these values are added together first in the equation, so if one of them was incorrectly assigned, we wouldn’t make it to the * part of the equation before receiving an error.
Since everything looks good with your Python code, I’m thinking the title of the “position” CHOP channel within the constant_null might be misspelled or have an extra character added to it. Check within your Rename CHOP to see if this is the case. When I misspell the name to “position1” or “positio” in my version of the network, I get the same error that you do.
If the Rename CHOP had the position channel name entered incorrectly, make sure it’s changed to read “position” (no quotes) and then right click on the CHOP Exec DAT and hit “Run Script”. This will cause the script to reload and will usually clear the error flag. Note that the error flag will not clear if you just change the CHOP channel name, the script needs to be run again.
If the Rename CHOP had the position channel name entered correctly, then there is a chance that it was entered incorrectly at some point and the CHOP Exec DAT is still showing an old error. Try right clicking on it and hitting “Run Script” to see if this clears the error.
I hope this helps! Let me know how you fare.
@@jackdilaura wow, thanks so much for spending the time sleuthing that one, but you got it :) It was the "position" name in the rename CHOP, I missed an 'i' and spelt "postion" by mistake. I thought I checked everything. This is why I often struggle with coding, one misspelt letter and it's hard to track down where it's gone wrong. Thanks again :)
@@NicholasCarn Amazing!! Glad to hear that fixed it. I know that struggle well, those errors can be really hard to track down, especially across different operators/pieces of code within TouchDesigner. Hope you have fun experimenting with the technique now that it’s running!