Python access to invalid OP references in parameters

If you have a COMP and type in foo in the “Clone Master” parameter, but there is no foo operator, is it possible to detect in Python that the text “foo” was typed into it?

I’m trying to create something that fixes clone master paths that may be broken. But as far as I can tell, if the text in that parameter refers to an OP that does not exist even though the UI shows text in the parameter, p.val evaluates to "", and p.expr is also "".

Hi @tekt ,

if you do an .eval() you will either get an op returned or None.
For parameters that accept multiple operators like the camera parameter of the render TOP, you can use evalOPs and it will return a list of operators. (Par Class - Derivative)

Hope this helps
Markus

So in the case that .eval() returns None, there is no way to get the text (the path to the OP that does not exist)?
This is specifically for the clone parameter, so I can’t use an Str parameter with evalOPs().

Hey @tekt ,

I missed the issue: You are using an expression similar to this:

op('bla{0}'.format(me.digits))

and you need to evaluate the operator name?
Cheers
Markus

For the RayTK toolkit, the palette creates operators which have a cloning path that’s fixed like /raytk/operators/sdf/boxSdf, but with cloning switched off. It always uses that sort of absolute path, even if the toolkit comp is somewhere else. It doesn’t cause issues since it isn’t actually using the cloning by default.
This allows me to have some control over the update process, similar to what’s done for Basic Widgets. Each operator has an “Update OP” parameter that triggers an update script. As part of that I’d like to reclone (and then disable cloning again), and have it work even if the user placed the toolkit somewhere else. There’s a global OP shortcut that I use on the toolkit itself, so it’s easy to locate.
So the update process ideally would go something like this:

  1. Check the contents of the clone parameter.
  2. If it’s a valid reference, pulse enablecloningpulse and we’re done.
  3. If the toolkit comp was placed somewhere else:
  • Temporarily swap in an expression like op.raytk.op('operators/sdf/boxSdf').
  • Pulse enablecloningpulse
  • Change the clone parameter back to the “normalized” absolute path /raytk/operators/sdf/boxSdf.
  1. After the recloning there are a few other changes that it makes to migrate things to the new version.

The goal was to:

  1. Have a standardized clone path, with automatic cloning disabled.
  2. Be able to “fix” that path for purposes of re-cloning, without totally replacing that standardized path.
  3. Be able to move or rename operators within the toolkit for a new release, and have it able to remap references to the old ones.

I had considered doing something like having the standardized path be an expression that uses the OP shortcut. But the components need to work properly even if the toolkit itself is missing, and that would mean having a more complex expression like op.raytk.op('.....') if hasattr(op, 'raytk') else ''.

There’s an alternative option that I can use with a metadata type name stored inside the comps, which can be used to look up the real path. But I figured that being able to access that part of the Par object might be useful for other people too.

Hey @tekt ,

ah ok - yeah - I’m surprised you are not able to get the .val back from the parameter:

cheers
Markus

Huh. I’m seeing that now. I’m not sure what was different about what I was trying initially.
:man_facepalming:

thanks for looking into it