SciMunk Posted September 30, 2019 Share Posted September 30, 2019 Hello, I'm trying to extract the content of a group into a strings to manually set a 'basegroup' parameter geo = hou.node("/obj/geo/geowithgroup").geometry() edges = geo.findEdgeGroup("mygroup").edges() sel = hou.Selection(edges) mystring = sel.selectionString(geo) the line "hou.Selection(edges)" don't work however, I get this issues : The attempted operation failed. Traceback (most recent call last): File "hou.session", line 10, in <module> File "C:/PROGRA~1/SideFX/HOUDIN~1.360/houdini/python2.7libs\hou.py", line 52675, in __init__ this = _hou.new_Selection(*args) TypeError: in method 'new_Selection', argument 1 of type 'std::vector<HOM_Prim *,std::allocator<HOM_Prim * > > const &' I've been looking at the doc for hours now and to me, it seam like it the only way to do that, but I just don't understand why it don't work since I provide to the function what it should expect from the doc : https://www.sidefx.com/docs/houdini/hom/hou/Selection.html I couldn't find any other way to do that. any help please ? Quote Link to comment Share on other sites More sharing options...
fsimerey Posted September 30, 2019 Share Posted September 30, 2019 43 minutes ago, SciMunk said: the line "hou.Selection(edges)" don't work however I'm not a python specialist, but if your goal is to get a basegroup string, I would do this: geo = hou.node("/obj/geo/geowithgroup").geometry() edges = geo.findEdgeGroup("mygroup").edges() for i in range(len(edges)) : mystring += (edges[i].edgeId()) + " " Quote Link to comment Share on other sites More sharing options...
SciMunk Posted September 30, 2019 Author Share Posted September 30, 2019 (edited) this solution don't really give me a smart string for exemple with "p10-p50 100-512" etc Edited September 30, 2019 by SciMunk Quote Link to comment Share on other sites More sharing options...
fsimerey Posted September 30, 2019 Share Posted September 30, 2019 (edited) 33 minutes ago, SciMunk said: this solution don't really give me a smart string for exemple with "p10-p50 100-512" etc In 17.5.360 this kind of string doesn't work in an edge group node in 'Base Group' parameter. The best smart is "p-10-11-12-13 p100-101-102-103" and you can check with a variable if the last computed point was the actual minus 1 to replace the result EdgeId() Edited September 30, 2019 by fsimerey Quote Link to comment Share on other sites More sharing options...
SciMunk Posted September 30, 2019 Author Share Posted September 30, 2019 (edited) my exemple was just informative, I'm looking at the function that convert a list of point/prim/vertex/edge using python into a string the same way the select on viewport work when setting group, there has to be a function for something like that. I just wanna avoid do my own. Edited September 30, 2019 by SciMunk Quote Link to comment Share on other sites More sharing options...
fsimerey Posted September 30, 2019 Share Posted September 30, 2019 10 minutes ago, SciMunk said: my exemple was just informative, I'm looking at the function that convert a list of point/prim/vertex/edge using python into a string the same way the select on viewport work when setting group, there has to be a function for something like that. I just wanna avoid do my own. Ok, I understand but it's not that difficult, even I can do it: node = hou.pwd() geo = node.geometry() edges = geo.findEdgeGroup("group4").edges() mystring= "" last_pt = "" for i in range(len(edges)) : edgestr = edges[i].edgeId() s = edgestr[1:].split("-") start_pt = s[0] end_pt = s[1] if last_pt == start_pt : mystring += "-" + end_pt else: mystring += " p" + start_pt + "-" + end_pt last_pt = end_pt Quote Link to comment Share on other sites More sharing options...
SciMunk Posted September 30, 2019 Author Share Posted September 30, 2019 (edited) yes, I can do it too, but that really not the point of it, I want to know about an existing houdini function. a python version can be slow for million of point, houdini version would be c++ based, that why I'm asking . Edited September 30, 2019 by SciMunk Quote Link to comment Share on other sites More sharing options...
fsimerey Posted September 30, 2019 Share Posted September 30, 2019 Ok in that case ask for convert a group in string but not 'Convert a group into string using Python' Quote Link to comment Share on other sites More sharing options...
SciMunk Posted September 30, 2019 Author Share Posted September 30, 2019 well, technically speaking, it still using python, but using a houdini existing function ... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.