kuaile_yzh Posted May 19, 2009 Share Posted May 19, 2009 (edited) guys,i meet a afflicting puzzle,anybody can do me a favor? I just have a more stupid way:exchange all positions of all points,then exchange their attributes. this method is troublesome and low-cost,i wonder if anyone can have a more convenient way. thx. # This code is called when instances of this SOP cook. geo = hou.pwd().geometry() # Add code to modify the contents of geo. tempos=[] temattrib=[] for point in geo.points(): tempos.append(point.position()) temattrib.append(point.attribValue("Cd")) pnum=len(tempos) a=0 for i in range(pnum): geo.points()[a].setPosition(tempos[pnum-1]) geo.points()[a].setAttribValue("Cd",temattrib[pnum-1]) pnum-=1 a+=1 sort02.hipnc Edited May 20, 2009 by kuaile_yzh Quote Link to comment Share on other sites More sharing options...
kuaile_yzh Posted May 19, 2009 Author Share Posted May 19, 2009 just change the index of the point but keep its attribute.thx. Quote Link to comment Share on other sites More sharing options...
ranxerox Posted May 19, 2009 Share Posted May 19, 2009 hello. I am new to houdini and am a little confused. Is this a script sop ? In the docs it says that the script sop does not modify the geometry. I was looking through the docs and the only type of sop I could find to edit the geometry in a similar manner would be a vop sop or a vex sop. Please enlighten me, thanks -ranxx just change the index of the point but keep its attribute.thx. Quote Link to comment Share on other sites More sharing options...
edward Posted May 20, 2009 Share Posted May 20, 2009 I just have a more stupid way:exchange all positions of all points,then exchange their attributes.this method is troublesome and low-cost,i wonder if anyone can have a more convenient way. I was going to say, just use the Sort SOP but you already have that in your .hip file so I am not sure what your question is? By the way, your .hip file wasn't saved with Embedded definitions so your Python SOP code was not included. Quote Link to comment Share on other sites More sharing options...
edward Posted May 20, 2009 Share Posted May 20, 2009 hello. I am new to houdini and am a little confused. Is this a script sop? No, kuaile_yzh has created a new SOP HDA that is defined by Python. There are some examples in the docs: http://www.sidefx.com/docs/houdini10.0/hom.../color_falloff/ http://www.sidefx.com/docs/houdini10.0/hom.../surface_wires/ Quote Link to comment Share on other sites More sharing options...
kuaile_yzh Posted May 20, 2009 Author Share Posted May 20, 2009 thx,The file is updated. Quote Link to comment Share on other sites More sharing options...
edward Posted May 20, 2009 Share Posted May 20, 2009 What is your question again? Quote Link to comment Share on other sites More sharing options...
kuaile_yzh Posted May 20, 2009 Author Share Posted May 20, 2009 can we change $PT of these point in python? Quote Link to comment Share on other sites More sharing options...
edward Posted May 21, 2009 Share Posted May 21, 2009 You just effectively did that in python. Points (and attributes) are stored as arrays in Houdini. $PT, or point number is just the index into these arrays. If you want to make your python code more "efficient", then instead of doing two loops, just do one loop and swap half of the elements. 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.