using Python to get the Geometry subData

   5405   7   0
User Avatar
Member
27 posts
Joined: Nov. 2009
Offline
as follow shown:

Attachments:
geometry.jpg (36.2 KB)

Houdini is a big thing!
User Avatar
Member
1908 posts
Joined: Nov. 2006
Offline
Unfortunately you can't really access the actual geometry data from a DOP object right now. There's an existing RFE to be able to get a hou.Geometry object out but there's not much you can do currently.

The only thing you could kind of do is to work your way back to the SOP that fed the object when it was created and try and get it from there. Of course if your geometry is modified in DOPs or the has moved that's useless.

geo_data = mydopobject.findSubData(“Geometry”)
basic_record = geo_data.record(“Basic”)
sopgeo_path = basic_record.field(“creator”)
sopgeo = hou.node(sopgeo_path)
geo_source_path = sopgeo.evalParm(“soppath”)
source_geo = hou.node(geo_source_path).geometry()


Not really sure what you have in mind but I'm pretty sure that's about the only way you can get anything geometry related out of a hou.DopObject right now.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
27 posts
Joined: Nov. 2009
Offline
thanks graham
Houdini is a big thing!
User Avatar
Member
160 posts
Joined:
Offline
#This code is called when this DOP solver runs.
if not hou.dop.isScriptSolverRunning():
# Evaluate parameters and store them in DOP data here:
for object in hou.pwd().processedObjects():
solver_data = object.findSubData(“Solver”)
#solver.options().setField(foo, hou.ch(“foo”))
else:
# We cannot access the DOP node or any of its parameters. Use the
# DOP data to solve for the objects.

if hou.dop.isScriptSolverInitializing():
# Set the initial state of objects being solved.
for object in hou.dop.scriptSolverObjects():
pass
else:
# Update the current simulation state for the objects.
timestep = hou.dop.scriptSolverTimestepSize()
for object in hou.dop.scriptSolverObjects():
geo_data = object.findSubData(“Geometry”)
basic_record = geo_data.record(“Basic”)
sopgeo_path = basic_record.field(“creator”)
sopgeo = hou.node(sopgeo_path)
geo_source_path = sopgeo.evalParm(“soppath”)
source_geo = hou.node(geo_source_path).geometry()
for pt in source_geo.points():
pos = pt.attribValue(“P”)
pos = (pos+0.1,pos,pos)
pt.setPosition(pos)
# print pos

pass


but DOP return this error message:GeometryPermissionError:Geometry is read-only.
how to fix this problem?
User Avatar
Member
1908 posts
Joined: Nov. 2006
Offline
Sorry I should have been more clear. That method is a hack for at least getting something resembling the geometry of your object. All you can do is query it for information. Since the geometry belongs to a SOP you won't be able to modify it in any way.

Ideally in the future you will be able to get a hou.Geometry object, as well as a hou.Volume object from a hou.DopObject and be able to modify them within Python DOP Objects/Solvers.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
30 posts
Joined: May 2012
Offline
Hi, there! Is it still impossible to get hou.Geometry from dops? I`m trying group all dynamic rbd objects which are part of glue constrain network. So my approach is to get Geometry dop data from gluenetwork, then check dopoject ids for each point and then group corresponding pieces. Unfotunately gluenet geometry is different each frame so getting sop geo is not an option.

I`m also open to any other ideas of groupig pieces which has active gluenetworks attached to them. SopSolver maybe?

Thank you
User Avatar
Member
1908 posts
Joined: Nov. 2006
Offline
It's now possible to get hou.Geometry objects directly from a hou.DopObject using the geometry() function. However, this only works to get the main Geometry subdata off an object. It's not possible to access other types of SIM_Geometry data, like say the geometry that is a part of a SIM_GlueNetworkRelationship.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
30 posts
Joined: May 2012
Offline
thanks, graham!
so no way to know which object is constrained to gluenet for each frame?
I tried sop solver approach, but it doesent work properly and there are some update issues.
I can post scene file if someone wants to help.
  • Quick Links