magneto Posted October 23, 2012 Share Posted October 23, 2012 Hi, I looked at the help but couldn't find it. Is there a way to find a point based on attribute values? Either in VEX or just in expressions. Something like: findpoint("../grid1", "weight", 16, #FIRST) 16 is the value to look up #FIRST or 0, means first match I know I can use the Group SOP, but I need this in code and run it inside a loop, instead of multiple nodes inside a foreach. Can this be done? Thanks Quote Link to comment Share on other sites More sharing options...
DanBode Posted October 23, 2012 Share Posted October 23, 2012 If you make the attribute a vector you can do it with pointclouds in vops. Just change the "P" on pcopen to the name of the vector attribute you're looking up. 2 Quote Link to comment Share on other sites More sharing options...
magneto Posted October 23, 2012 Author Share Posted October 23, 2012 Thanks Dan, I didn't know of that trick. When I use the pcopen like you said, will be an exact match or closest match possible? Also I assume it will give me multiple points, right? Quote Link to comment Share on other sites More sharing options...
ranxerox Posted October 23, 2012 Share Posted October 23, 2012 Hi, I looked at the help but couldn't find it. Is there a way to find a point based on attribute values? Either in VEX or just in expressions. Something like: findpoint("../grid1", "weight", 16, #FIRST) 16 is the value to look up #FIRST or 0, means first match I know I can use the Group SOP, but I need this in code and run it inside a loop, instead of multiple nodes inside a foreach. Can this be done? Thanks # # getPtFromId # # returns pointnumber of point with given id value # def getPtFromId(node, id): nodeGeo = node.geometry() idList = nodeGeo.pointFloatAttribValues("id") idListAsInt = [int(i) for i in idList] return idListAsInt.index(id) this will work but it's slow.. it's looking specifically for the attribute "id", but you can change that or add it as a parameter. I'm not sure the point cloud answer will work exactly .. won't that return the closest result ? Maybe a combination of the 2 would be faster if you have a lot of points .. use the point cloud to return a list of possible close matches and the python to return the exact match or an error if there is no point with the given attribute. -G 1 Quote Link to comment Share on other sites More sharing options...
DanBode Posted October 23, 2012 Share Posted October 23, 2012 Thanks Dan, I didn't know of that trick. When I use the pcopen like you said, will be an exact match or closest match possible? Also I assume it will give me multiple points, right? The match will be as close as the size of your search radius. I do this for id look ups often and just leave the search radius at .1 for an exact match. If multiple points have the same id you can get all of them if you want. I usually Use Point Cloud Num Found to see if there was any match, then Point Cloud Import By Index with the index left at zero to grab the first one. 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted October 23, 2012 Author Share Posted October 23, 2012 Thanks guys. @ranxerox: I was hoping for a built-in function for this, because like you said python will be slow and if you need this for prims, etc then you can't use the pcopen in combination with your python function. @Dan: So if you are doing integer lookups, then having values like {0,0,0}, {1,0,0}, {2,0,0}, {3,0,0}, etc, you should keep the radius at 1? But for floats, you need the know the smallest difference between values that's greater than 0, right? Otherwise if you have 0.00001 and 0.000012, and you use 0.001, you will get both, but the first point won't necessarily be the one with the closest value? Quote Link to comment Share on other sites More sharing options...
ranxerox Posted October 23, 2012 Share Posted October 23, 2012 cool trick. It's too bad there isn't a 1d version of point cloud open etc to get around creating/deleting an extra vector attribute. -G The match will be as close as the size of your search radius. I do this for id look ups often and just leave the search radius at .1 for an exact match. If multiple points have the same id you can get all of them if you want. I usually Use Point Cloud Num Found to see if there was any match, then Point Cloud Import By Index with the index left at zero to grab the first one. Quote Link to comment Share on other sites More sharing options...
bloomendale Posted October 23, 2012 Share Posted October 23, 2012 cool trick. It's too bad there isn't a 1d version of point cloud open etc to get around creating/deleting an extra vector attribute. -G Store "P" in attribute, zero out it, replace for example X with float attrib. Do the PC search, get "P" back. 1 Quote Link to comment Share on other sites More sharing options...
eetu Posted October 23, 2012 Share Posted October 23, 2012 ... but the first point won't necessarily be the one with the closest value? Actually, I think the point cloud functions return the matches in order - e.g. the first one will be the closest. 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted October 23, 2012 Author Share Posted October 23, 2012 (edited) Thanks Eetu, that's great Also I found another thread about this: http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&p=113850 So people actually want this as an RFE Edited October 23, 2012 by magneto Quote Link to comment Share on other sites More sharing options...
ranxerox Posted October 23, 2012 Share Posted October 23, 2012 Store "P" in attribute, zero out it, replace for example X with float attrib. Do the PC search, get "P" back. this is equivalent to Dan's suggestion of putting the attribute as a parameter to the pcopen, except for the extra steps. another way to do this as a friend suggested is to store $PT in an attribute, delete non selected by expression $ID == x, then the remaining points have the pointnumbers of the points which have the attribute value you are looking for. That's gonna run an expression on every point so not as fast as the pcopen, but it's extremely simple. -G Quote Link to comment Share on other sites More sharing options...
carstenkolve Posted October 23, 2012 Share Posted October 23, 2012 the point sop has an option "match by attribute", which works fine - but you need to have the same attribute on both pointclouds, have only used it with id attributes so far, though (so I'm not sure how/if it deals with inprecisions ) "When there are two inputs the standard behaviour is to match according to point number. However, if the inputs are particle systems, this might not match properly as one wants to match the same particle even if particles are deleted or created. Match By Attribute will have $TX2 refer to the point on the second input whose attribute matches the attribute of the currently evaluated point. If more than one point on the second input matches, the point with the greatest point number will be used. " http://www.sidefx.com/docs/houdini12.1/nodes/sop/point Quote Link to comment Share on other sites More sharing options...
cgTux Posted March 5, 2014 Share Posted March 5, 2014 can some one provide an example file with the pcopen hack where you look by Id and then get the position back? I have not been able to get this to work Thanks! Quote Link to comment Share on other sites More sharing options...
anim Posted March 5, 2014 Share Posted March 5, 2014 you don't need pcopen hack nowadays there is Find Attribute Value VOP or findattribval() VEX function for that http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&p=133858#133858 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.