Setting An Op Parm To A Variable

   5189   7   3
User Avatar
Member
543 posts
Joined: July 2005
Offline
Hi,

I have dozens of noise nodes that I need to change the values of the noise for but want to use a variable instead of hard coding the values and also use hscript to set them (instead of doing it manually).

Essentially I want to do something like this:
opparm subnet1/noise4d1 amp ($noise_x $noise_y $noise_z)

But of course the variable value gets evaluated in this form but I want to insert the string (i.e. “$noise_x”) into the fields but can't figure out the correct syntax. I've tried various forms using single and double qoutes, no luck.

Any suggestions?

Thanks!


–Mark
========================================================
You are no age between space
User Avatar
Member
176 posts
Joined: July 2005
Offline
You can use
“\” to comment out the $
opparm subnet1/noise4d1 amp (\$noise_x \$noise_y \$noise_z)

if you want an expression into a field…in this case you may want to use chadd and chkey…
set cosvar=cos\(\$F*ch\(\“../blender/freq\”))*ch\(\“../blender/amp\”)+ch\(\“../blender/offset\”)

set sinvar=sin\(\$F*ch\(\“../blender/freq\”))*ch\(\“../blender/amp\”)+ch\(\“../blender/offset\”)

chadd -t 0 0 0 $SOP tx
chadd -t 0 0 0 $SOP tz
chkey -t 0 -v 0 -m 0 -A 0 -F “$cosvar” text1/tx
chkey -t 0 -v 0 -m 0 -A 0 -F “$sinvar” text1/tz
User Avatar
Member
543 posts
Joined: July 2005
Offline
Hi,

OK. Thanks for the tips, will try them in a bit. I thought I had tried to escape the ‘$’ char with a ‘\’ but maybe I missed something.

Thanks!


–Mark
========================================================
You are no age between space
User Avatar
Member
4140 posts
Joined: July 2005
Offline
I'm pretty sure you want the chadd/chkey approach - by entering an expression into a field, that's actually what you're doing behind the scenes. I don't know the precise param names, but something like:

chadd -t 0 0 0 subnet/noise4d*/ampx

chkey -t 0 -v 0 -m 0 -A 0 -F subnet/noise4d*/ampx $noise_x

Something like that, anyway. Do an opscript on the op to double check.

Cheers,

J.C.
John Coldrick
User Avatar
Member
321 posts
Joined: July 2005
Offline
Personally, I'd skip the variables and just add spare channels to the operator where the noise is being applied (point SOP?) That way, you have a basic UI right there, you get some sliders, labeled parameters, etc. And if you have the same settings in multiple places, you can always create the parameters as spare channels up one level, or just have a null SOP that provides the channels to which all the other SOPs point.

– Antoine
Antoine Durr
Floq FX
antoine@floqfx.com
_________________
User Avatar
Member
543 posts
Joined: July 2005
Offline
JColdrick
chadd -t 0 0 0 subnet/noise4d*/ampx

chkey -t 0 -v 0 -m 0 -A 0 -F subnet/noise4d*/ampx $noise_x
Hi there JC,

Thanks for the tip, turns out that Houdini wouldn't create any channels at all, I restarted H and then it was working fine. Weird. More than likely operator error. :-)


–Mark
========================================================
You are no age between space
User Avatar
Member
543 posts
Joined: July 2005
Offline
Antoine Durr
Personally, I'd skip the variables and just add spare channels to the operator where the noise is being applied (point SOP?) That way, you have a basic UI right there, you get some sliders, labeled parameters, etc. And if you have the same settings in multiple places, you can always create the parameters as spare channels up one level, or just have a null SOP that provides the channels to which all the other SOPs point.

– Antoine
Hi Antoine,

You know, I started by using spare channels then realized I needed to do this at a “global” level, thus the variable usage. But now that you mention it, it would a lot easier to put the spare channel and controls at a higher level in the network. Much better.

Thanks for jogging my synaptic net mess!


–Mark
========================================================
You are no age between space
User Avatar
Member
380 posts
Joined: July 2005
Offline
I know this post is way old, but just ran into this on H8 myself,
when in H9+ you can opparm the variable as a literal string w/
single quotes.

# H9> opparm /obj/model tx ( ‘$VER’ )
# H8> chadd /obj/model rx ry rz
# > chkey -t 0 -F ‘$VER’ /obj/model/rx /obj/model/ry
  • Quick Links