hi, everyone.
I want to use python to get the value of creationtime which is the subData of Impacts.
I don't how to list the subDatas “Basic” and “Impacts”.
Thanks
using Python to get subDatas
3065 4 0- sparkChan
- Member
- 27 posts
- Joined: Nov. 2009
- Offline
- graham
- Member
- 1921 posts
- Joined: Nov. 2006
- Online
It's something like this:
records = hou.DopObject.findSubData(“Impacts”).records(“Impacts”)
for record in records:
time = record.field(“time”)
You can also check out my attached otl file here for an example.
http://forums.odforce.net/index.php?/topic/9794-particles-created-on-collision/page__view__findpost__p__64423 [forums.odforce.net]
records = hou.DopObject.findSubData(“Impacts”).records(“Impacts”)
for record in records:
time = record.field(“time”)
You can also check out my attached otl file here for an example.
http://forums.odforce.net/index.php?/topic/9794-particles-created-on-collision/page__view__findpost__p__64423 [forums.odforce.net]
Graham Thompson, Technical Artist @ Rockstar Games
- sparkChan
- Member
- 27 posts
- Joined: Nov. 2009
- Offline
graham
It's something like this:
records = hou.DopObject.findSubData(“Impacts”).records(“Impacts”)
for record in records:
time = record.field(“time”)
You can also check out my attached otl file here for an example.
http://forums.odforce.net/index.php?/topic/9794-particles-created-on-collision/page__view__findpost__p__64423 [forums.odforce.net]
thanks graham,
I have wrotten the code, but I want to keep the value of ‘creationtime’ when the sphere doesn't collided with the ground .
I just use the method creating a file to store the value, and then read the value from the file.
the codes:
obj = pwd().simulation().findObject('active')
check = obj.findAllSubData('I*').keys()
impacts = ‘Impacts’
if impacts in check:
files = open(“chenxiang.txt”,'w')
records = obj.findSubData('Impacts').records('Basic')
for record in records:
time = record.field('creationtime')
files.write(str(time))
files.close()
filename = open('C:\Users\IBM\chenxiang.txt','r')
valueS = filename.readline()
value = float(valueS)
return value
Houdini is a big thing!
- graham
- Member
- 1921 posts
- Joined: Nov. 2006
- Online
Sorry about that. I was thinking you wanted something different.
If you want to store data you might also consider using the hou.session module as opposed to the file. You can actually store proper data python data structures there and not have to worry about file i/o. You can also store a list to handle multiple times you get impacts.
# Create a list if we don't have one already.
if not hasattr(hou.session, “impact_times”):
hou.session.impact_times =
…
for record in records:
hou.session.impact_times.append(record.field(“creationtime”))
If you want to store data you might also consider using the hou.session module as opposed to the file. You can actually store proper data python data structures there and not have to worry about file i/o. You can also store a list to handle multiple times you get impacts.
# Create a list if we don't have one already.
if not hasattr(hou.session, “impact_times”):
hou.session.impact_times =
…
for record in records:
hou.session.impact_times.append(record.field(“creationtime”))
Graham Thompson, Technical Artist @ Rockstar Games
- sparkChan
- Member
- 27 posts
- Joined: Nov. 2009
- Offline
grahamI have used hou.session module to keep the value successfully, but if I change the simulation state, the value doesn't change correctly. Is there any way to judge the simulation state. if the simulaton is changed, I will delete the list.
Sorry about that. I was thinking you wanted something different.
If you want to store data you might also consider using the hou.session module as opposed to the file. You can actually store proper data python data structures there and not have to worry about file i/o. You can also store a list to handle multiple times you get impacts.
# Create a list if we don't have one already.
if not hasattr(hou.session, “impact_times”):
hou.session.impact_times =
…
for record in records:
hou.session.impact_times.append(record.field(“creationtime”))
Houdini is a big thing!
-
- Quick Links