John Svensson Posted July 24, 2015 Share Posted July 24, 2015 Hi there! I wrote a couple lines of python code that lets you export Houdini point attributes to an xml file. And then another couple of lines that reads the xml file in Maya. Useful for getting Houdini point colors to vertex colors in Maya, and possible other things to. I thought I would create a simple UI for the Houdini part of the script that has a couple of user defined parameters. But after searching for a while I still don't have a clear idea what's the simplest way to do this. I've attached a image of what the UI could look like. If this was a scripted python Digital Asset then I would get the UI for free, it feel like this shouldn't be that hard either. To do this in Maya, with Python or Mel isn't that tricky either. If it's possible I would like to avoid using PySide & PyQt. I've been looking the the hou.ui module but I don't really understand, I read somewhere that one approach is to load a UI description from a external file. What is common practice here (for simple UI's & dialogs)? Thanks / John Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted July 24, 2015 Share Posted July 24, 2015 (edited) What's the reason to avoid PySide if it's bundle with Houdini 14? Anyway, take a look at my huilib library. It's pure python and easy to use, although very limited in features. Edited July 24, 2015 by Stalkerx777 1 Quote Link to comment Share on other sites More sharing options...
edward Posted July 25, 2015 Share Posted July 25, 2015 I think this type of tool makes the most sense as a SOP digital asset. So you specify the attributes you want to export from its input and then you have a button that does the export. This is similar to the ROP Output Driver SOP except that it outputs some .xml file format instead. Quote Link to comment Share on other sites More sharing options...
John Svensson Posted July 25, 2015 Author Share Posted July 25, 2015 What's the reason to avoid PySide if it's bundle with Houdini 14? Anyway, take a look at my huilib library. It's pure python and easy to use, although very limited in features. I guess I thought because of the simplicity of what I want it was a simpler way than PySide (or maybe I should just try to learn it instead), I can only compare to maya with Mel & Python where you have PySide as an option but for simple UI stuff its quit easy to accomplish with a couple of lines of Mel or Python. I came across your library when I was searching this topic, I haven't tried it but it seems to do what I needed. I guess I just wanted to know what was common practice, this Houdini .ui language, is it just for HDK stuff (don't know what i mean) or could it work for this kind of thing? I will check out your library anyway though, thanks for your answer I think this type of tool makes the most sense as a SOP digital asset. So you specify the attributes you want to export from its input and then you have a button that does the export. This is similar to the ROP Output Driver SOP except that it outputs some .xml file format instead. I did look at it that way, I only saw that if I did it like a SOP DA all my UI problems would disappear. For some reason I saw it as a quick fix that didn't made sense, but when you say it like that, I guess you're right! Thanks Quote Link to comment Share on other sites More sharing options...
John Svensson Posted July 30, 2015 Author Share Posted July 30, 2015 (edited) Hi again! So I started to write my tool as a DA node instead of shelf script, and I have a few questions about the "anatomy" of a python node. I started to write my code as I've done before in the Code section of the Edit Operator Type Properties window. The first bump I hit was that I have a "Write" button in my UI that allows the user to run the tool, the node doesn't do anything without it. I found that to be able to call a function from the button I had to create a python module event handler in the script part of the window. Now I can call my "start" function with this callback script on the button kwargs['node'].hdaModule().cook() The script checks a few user parameters and have 2 outcomes (for now), "Invalid parameter settings" or call the "write" function. What I got stuck on was, that I want to raise a error if the parameters aren't valid. What I understand is that there are a few different way to do this in the UI. What I'm after is the regular black & yellow stroke, node error where you can middle mouse button click on the node and there are some description there. This is the code I believe. raise hou.NodeError("Invalid parameter settings") But when I run it from my python module, what I get is a pop up window displaying the error, if I instead run it from the code section, it works fine. Can python functions from the code & the script section talk to each other? I think it's something about the whole module thing I don't quite grasp. (I found this thread with the exact same question, unanswered) https://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&p=182284&sid=40be76ecbcde29c17d0f2eb50434536f Thanks / John Edited July 30, 2015 by John Svensson Quote Link to comment Share on other sites More sharing options...
edward Posted July 31, 2015 Share Posted July 31, 2015 You can try setting some "user data" on the node that your cook looks for to trigger the error. Quote Link to comment Share on other sites More sharing options...
John Svensson Posted August 1, 2015 Author Share Posted August 1, 2015 Thanks for your answer edward. I did a fast google on your suggestion but it seemed a bit more complicated than I thought it would be. I attached a screen grab over how my node looks in it current state. I may be off track here but, what I think would solve everything is if I could get a function (cook) from img (3) to call a function in img (2). I get this error message when I try. Traceback (most recent call last): File "<stdin>", line 1, in <module> File "opdef:/Sop/AttribIO_HToM_Writer?PythonModule", line 24, in cook NameError: global name 'error_test' is not defined It really feels like it's some detail I'm missing because there something about these modules I don't understand to how they relate to each other. Is there something like global functions or can I call the function some other way? Thanks again! / John Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted August 1, 2015 Share Posted August 1, 2015 Wouldn't it easier to do basically the opposite? Use the callback to do nothing more then set a variable that allows the SOP to actually write the file, and then cook the SOP. So all the actual code sits in the SOP, and the callback can simply turn a parm that allows the data to be written, cook, turn parm back. Quote Link to comment Share on other sites More sharing options...
edward Posted August 1, 2015 Share Posted August 1, 2015 I like captain's idea. For the communication, I was suggesting this: http://www.sidefx.com/docs/houdini14.0/hom/nodeuserdata... just make sure to name your data uniquely. 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.