Overlay current wedge attributes

   6648   6   1
User Avatar
Member
55 posts
Joined: Jan. 2006
Offline
The ROP Composite Output TOP has by default the text “Overlay $F”, but what I want to put in there is the currently evaluated Wedge Attribute name, parameter, and value. I don't seem to find that anywhere. Checking “Export to Environment” doesn't seem to help.

Is that possible? It should be possible. That information is in there somewhere, right? Is it a $ or a `@attribute` style expression? Is it some python code?

My final goal is to put these up on the left had side of the frame to demonstrate the use of variables in sims when teaching and when prototyping and experimenting.
“If you can eat it raw you can't under cook it”
User Avatar
Staff
600 posts
Joined: May 2014
Offline
Work item attributes are always accessed with @attribute.index or pdgattribute(“attribute”, index) when using HScript. For each work item, the wedge node will create:

  • The wedgeattribs attribute, which is a list of the attributes created by the wedge
  • For each wedged attribute, an attribute with the name specified on the wedge node and the value of the variation for that work item
  • If a target parameter was specified, an attribute named <attrib>channel which contains the the target parameter.

Those are accessible on the job side as well, e.g. a ROP Geometry can cook a SOP net that contained expressions with PDG attributes in them. If you have a wedge attribute called “scale”, you could put the following in the overlay text for example:

scale = `@scale`, parameter = `@scalechannel`

Note that backticks are needed becasue the text field is a string parameter.

If you want a more automated solution that dumps out all wedge attributes, the easiest way is probably to set a Python expression on the overlay text field:

import pdg
active_item = pdg.EvaluationContext.workItemDep()

data = active_item.data
attribs = ""
for wedge_attrib in data.stringDataArray("wedgeattribs"):   
    val = data.stringDataArray(wedge_attrib)
    if not val:
        val = data.intDataArray(wedge_attrib)
    if not val:
        val = data.floatDataArray(wedge_attrib)
    if not val:
        continue
    attribs += "{} = {}\n".format(wedge_attrib, str(val))
return attribs

This will query the active work item and then create a multi-line string from the wedge attribute/value pairs.
Edited by tpetrick - Aug. 2, 2019 11:17:12
User Avatar
Member
55 posts
Joined: Jan. 2006
Offline
AWESOME! That's exactly what I was looking for.

Weird though, last night I swear I was trying ‘@attrib’ ,but it wasn't working (see my original question). Oh well.

I'll also add that if you want to control the floating point representation printed on the overlay you can use:

    val = round(float(str(val)[1:-1]),3)
    attribs += "{} = {}\n".format(wedge_attrib, str(val))
Edited by kleer001 - Aug. 2, 2019 13:30:11
“If you can eat it raw you can't under cook it”
User Avatar
Member
12 posts
Joined: Feb. 2018
Offline
Hey guy's I really want to do this as well but cant seem to get it to work my side, do you guy's maybe have an example scene? Thanks in advance.

Image Not Found
Edited by SuekieZA - Aug. 21, 2019 08:32:08

Attachments:
Capture.JPG (216.9 KB)

User Avatar
Staff
600 posts
Joined: May 2014
Offline
The code I posted should be set as a Python Expression on an Overlay Text node's text field. The Overlay Text node is a specialized ROP Composite that takes input image(s) and writes customizable text onto them - the Python code snippet just returns a list of attributes.
User Avatar
Member
12 posts
Joined: Feb. 2018
Offline
Hi there,

So I still cant seem to get this to work :C

I have tried a ton of things now. I'm attaching a scene for you to look at. I would like the overlay to display the attributes and their values on the renders.

Attachments:
overlayissue.hip (543.6 KB)

User Avatar
Staff
600 posts
Joined: May 2014
Offline
The script on the overlay text is being set a string value, not as an expression. You need to right click on the parm and go to “Edit Expression” and set the expression contents. Then, set the expression language to Python instead of HScript.

I've attached an updated version of the .hip file. I also fixed the output path on the overlay text so that it doesn't use the same file name for different wedges.

Attachments:
overlayissue.hip (554.7 KB)

  • Quick Links