AntoineSfx Posted February 13, 2017 Share Posted February 13, 2017 I have created a curve, but I didn't realize some points were created outside of the XZ plane. How can I fix the curve so that I don't have for example, a transform node with scaleY=0 after the curve. I just want to non procedurally alter the points. Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted February 13, 2017 Share Posted February 13, 2017 Set all Y values to 0 by hand in the coordinates field of the curve node. Quote Link to comment Share on other sites More sharing options...
galagast Posted February 14, 2017 Share Posted February 14, 2017 Hi, try out this code if it works for you. # flattens a curve without using a transform SOP sel = hou.selectedNodes() for s in sel: if s.type().name() == 'curve': p = s.parm('coords') old = p.eval().split() new = '' for i in old: vec = i.split(',') new += vec[0] + ',0,' + vec[2] + ' ' p.set(new) Just select the your Curve SOPs and run the script on a Shelf Tool. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 14, 2017 Share Posted February 14, 2017 (edited) As @konstantin magnus said, you need to manually process coordinate string, where points delimited by spaces and coordinates delimited by commas. It's usually easy to do by hand, but for the big curves, as one-time solution, open "Python Source Editor" from "Windows" menu on menu-bar and paste: import re coords = '-0.74726,0.925304,-0.00824785 -0.673029,0.290926,0.435489 0.377754,0.610135,-0.875927 0.689525,-0.412144,-0.35301 ' print(re.sub(r'(.*?),(.*?),(.*?)', r'\1,0.0,\3', coords)) Press Apply. Resulting string should be printed into console. Modify this for your case. 1. If Curve node outputs error, make sure you didn't copy empty newline from the end of console. 2. Clear and apply editor's contents before closing, otherwise it will print every time you open hip. 3. re.sub's second argument for zeroing x, y and z axes: r'0.0,\2,\3' r'\1,0.0,\3' r'\1,\2,0.0' Edited February 14, 2017 by f1480187 1 Quote Link to comment Share on other sites More sharing options...
galagast Posted February 14, 2017 Share Posted February 14, 2017 (edited) That is cool f1! I hope you don't mind me creating a variant of the script with your method # flatten variant using regular expressions import re sel = hou.selectedNodes() for s in sel: if s.type().name() == 'curve': p = s.parm('coords') coords = p.eval() p.set(re.sub(r'(.*?),(.*?),(.*?)', r'\1,0.0,\3', coords)) Edited February 14, 2017 by galagast 2 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.