Extending the RBD objects using Python Expression

   2933   1   0
User Avatar
Member
27 posts
Joined: Nov. 2009
Offline
Asumming that I have 10 RBD Objects, and I want to extend a rbd to a list every frame, how to achieve that?

frame = hou.frame()
prefix = ‘sphere_’
if(not hasattr(hou.session, ‘objs’)):
hou.session.objs =
sources = hou.pwd().simulation().findAllObjects('sphere*')
for piece in sources:
aList = piece.name().split(prefix)
num = int(aList)
if num == frame:
hou.session.objs.append(piece)
return hou.session.objs


this is my code in the Group 0 Mask parameter of Group Dynamic Objects DOP
but I got a message like this ‘ObjectWasDeleted: Attempt to access an object that no longer exists in Houdini.’

thanks

Attachments:
shatter_at_tframe.hip (812.8 KB)

Houdini is a big thing!
User Avatar
Member
1921 posts
Joined: Nov. 2006
Online
Whenever you change a setting in a simulation it needs to recook itself. It does that by basically deleting all the cached data from previous frames and resimulating it. Since you are storing a list of hou.DopObject that reference the previous simulation they get destroyed as well, hence the ObjectWasDeleted exception.

There isn't really a good way store objects like this, as well as you will get lots of duplicates in your list since you aren't filtering for already existing items. My suggestion would be to not store a list in hou.session. You could create a simple list, find all the objects that have their number value <= to the current frame, and return that list. You should also convert your list to either names or objid numbers. I was surprised it even worked returning a list of objects. I guess the parser was able to find the info from the repr() of the list.

Something like this:

mask =
for piece in sources:
aList = piece.name().split(prefix)
num = int(aList)
if num <= frame:
mask.append(str(piece.objid()))

return “ ”.join(mask)
Graham Thompson, Technical Artist @ Rockstar Games
  • Quick Links