Jump to content

[TOP/PDG] A Python script to get workitem attributes causes an error on ROPGeometry TOP


willlinks

Recommended Posts

Hi There,

I'm trying to grab all attributes on the current work item in TOP and assign them to points in SOP.

I wrote a python script and it works fine in SOP lively but I'm getting an error or crush when I kick off ROP Geometry Output TOP.

I used python approach because I have several attributes to transfer and the attributes can be changed in the future so I'd like to avoid using @xxxx with hardcoded attribute names in SOP.   

It would be great to have some suggestions. Thanks you ~

Edited by willlinks
Link to comment
Share on other sites

Here are my updated simplified hip and script.

import pdg

node = hou.pwd()
geo = node.geometry()

# Setting target attributes
top_node = hou.node("/obj/topnet1/partition_items")
top_node.cookWorkItems()
target_work_items = top_node.getPDGNode().workItems
target_attrib_names = target_work_items[0].attribNames()

# Current work item
work_item = pdg.workItem()
attrib_names = work_item.attribNames()

# Make point attributes
for attr in attrib_names:
    if attr in target_attrib_names:
        val = work_item.attribArray(attr)[0]
        geo.addAttrib(hou.attribType.Point, attr, val)

# Set point attribute values    
i = 0
for point in geo.points():
    for attr in attrib_names:
        if attr in target_attrib_names:
            vals = work_item.attribArray(attr)
            if len(vals)>1:
                val = vals[i]
                point.setAttribValue(attr, val)
    i += 1

 

Hip File : pdg_attributes.zip

I see the error below but I don't see the python node erroring out...
image.png.2d8fcae9aa83bfbc2829dc23d65bc91f.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...