Re: [gaffer] Adding reference to a node via a plug

113 views
Skip to first unread message

Murray Stevenson

unread,
Sep 21, 2023, 6:51:37 PM9/21/23
to gaffe...@googlegroups.com
Hey,

> I am more than open to other solutions for finding internal nodes of a Box other than their names!

One way of tagging specific nodes to find them later is to register custom metadata on the node. You could try something along the lines of: 

Gaffer.Metadata.registerValue( root["Box"]["ArnoldOptions"], "myCustomMetadataName", True )

Then to find any nodes tagged with "myCustomMetadataName" metadata under root["Box"]

Gaffer.Metadata.nodesWithMetadata( root["Box"], "myCustomMetadataName" )

Otherwise, if you're after all ArnoldOptions nodes that are immediate children of root["Box"] you can use GafferArnold.ArnoldOptions.Range( root["Box"] ).

And for all ArnoldOptions nodes that are a descendant of root["Box"]: GafferArnold.ArnoldOptions.RecursiveRange( root["Box"] ).

There's also some useful stuff in Gaffer.NodeAlgo for finding upstream and downstream nodes by connection. You can see some examples of use in the test cases here: https://github.com/GafferHQ/gaffer/blob/main/python/GafferTest/NodeAlgoTest.py#L340-L457

> which unless referenced, can be changed by the artists and break the plugins.

"Read-onlyness" is also just metadata, so if you wanted to have a Box that is not meant to have user editable internals, you can use Gaffer.MetadataAlgo.setChildNodesAreReadOnly( root["Box"], True ). This allows any plugs on the box to still be edited, but makes its contents read only.

Hope this helps!

Murray

On Thu, 21 Sept 2023 at 12:10, Jeremy Books <jbo...@mainframe.ca> wrote:
Hey Guys,

I am wondering if its possible to use some expression syntax to add a reference to a node on another node. For example; If I have a box node with an ArnoldOptions node inside. I want to have a plug on the Box node who's value would resolve an instance of the ArnoldOptions node. This would allow me to have some python plugins that runs on this Box node finding internal nodes much easier than relying on naming, which unless referenced, can be changed by the artists and break the plugins.

I am more than open to other solutions for finding internal nodes of a Box other than their names!



This email and any attachments are intended only for use by the addressee(s) named herein and may contain confidential information. If you are not the intended recipient of this email, you are hereby notified any dissemination, distribution or copying of this email and any attachments is strictly prohibited. If you receive this email in error, please immediately notify the sender by return email and permanently delete the original, any copy and any printout thereof. The integrity and security of email cannot be guaranteed.

--
You received this message because you are subscribed to the Google Groups "gaffer-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gaffer-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gaffer-dev/7e45452b-696c-422d-9f71-66d3798f8428n%40googlegroups.com.

Jeremy Books

unread,
Sep 21, 2023, 7:38:11 PM9/21/23
to gaffer-dev
Hey Murray,

Gaffer.Metadata.nodesWithMetadata should actually work perfectly for this!
I use Gaffer.NodeAlgo quite a bit its definitely very useful, but I was unaware of the Range and RecursiveRange methods, those look like they would also come in handy.

Also, Gaffer.MetadataAlgo.setChildNodesAreReadOnly will be helpful!

wow, thank you this was all very helpful (:
Reply all
Reply to author
Forward
0 new messages