ben Posted March 3, 2011 Share Posted March 3, 2011 Hi, I'm working on an OTL and I need the user to be able to choose sets of objects from directories. So I've tried to do a custom python operator and I'm very close to what I need. - specify a directory - check obj and or fbx - a list is populated - object is loaded according to the user choice. ( SOP : TabMenu/Import -> ListFiles ) thx ben ListFiles.otl Quote Link to comment Share on other sites More sharing options...
kubabuk Posted March 3, 2011 Share Posted March 3, 2011 Hi Ben and thanks for the asset. Unfortunately I don't have the answer for you at the moment. Everything works for me just fine. Perhaps the problem occurs only when loading heavy geometry, no? kuba Quote Link to comment Share on other sites More sharing options...
ben Posted March 3, 2011 Author Share Posted March 3, 2011 No it happens even with very low geometry. Usually first time you pick something in the list it's ok but then if you change your choice it's kind of random. Thanks for trying it. Quote Link to comment Share on other sites More sharing options...
graham Posted March 3, 2011 Share Posted March 3, 2011 (edited) Sometimes you can have issues with script driven menus not always refreshing when you'd like and whatnot, but there are a couple things you can do. If you call hou.Parm.menuItems() on a menu parameter it will cause the script to reevaluate and be up to date. If you do this in the cook code it should ensure that if a valid file is available it is loaded. Also you can force it to update properly, at least visually when you change your directory or toggle the file types. One thing I noticed that might also be causing problems is that you build the list of files in the menu parameter, but then build it again in the cook code. If you build it just once in the parameter then get the file from there after ensuring it's update you might get less problems as well. Attached is a quickly modified version where I've done some of the things I mentioned above. Also, to add a little more flexibility and such I've modified it a little so that it builds the list of file extensions to check from the parameter interface itself. If you want to add any other available extensions all you need to do is add a parameter "ext_whatever" where whatever is the name i.e "ext_obj" and it will automatically add any .obj files to the list if they are toggled on. Be sure to copy the callback script which just ensures the menu is properly rebuilt when a toggle is toggled. I also threw in some error checking to be safe. No guarantee it will solve the problem but it's worth a shot. ListFiles.otl Edited March 3, 2011 by graham Quote Link to comment Share on other sites More sharing options...
ben Posted March 3, 2011 Author Share Posted March 3, 2011 Thanks a lot Graham ! Your script is really clean and nicely commented, I'm learning a lot from it. Unfortunatly it doesn't solve the main problem but I don't give up. Quote Link to comment Share on other sites More sharing options...
lukeiamyourfather Posted March 3, 2011 Share Posted March 3, 2011 Thanks a lot Graham ! Your script is really clean and nicely commented, I'm learning a lot from it. Unfortunatly it doesn't solve the main problem but I don't give up. I haven't downloaded the tool to check it out, but it sounds like your issues might be system I/O related rather than a Python issue. For example if the files being loaded are on a network drive then network connectivity might be intermittent (conflicting DNS, bad switch, bad NIC, etc.). Try from a local drive if you haven't already. Quote Link to comment Share on other sites More sharing options...
graham Posted March 3, 2011 Share Posted March 3, 2011 Can you post a hip file with specific instructions? Might help track the problem down. Quote Link to comment Share on other sites More sharing options...
Fabiano Berlim Posted March 3, 2011 Share Posted March 3, 2011 It's working just fine for me. Even after deleting and adding files, it could update without a single problem. There's inside hou.Node the cook() function. Maybe it helps. Quote Link to comment Share on other sites More sharing options...
ben Posted March 3, 2011 Author Share Posted March 3, 2011 Luke : I'm loading from local drive. I've just tried from another faster (10000rpm) drive and it's just the same. Graham : There's no specific hip file right now. I just need to make this simple one to work before embeding it in bigger OTLs . --- strange ... I've just realise that exactly the same is happening using a fileNode (randomly need to hit Reload Geometry few times). It's weird, and it's new, everything was fine before... Right now I'm on 10.0.581 (win64), I'm going to try all of this on an other PC. Thanks everyone for having a look at it. Quote Link to comment Share on other sites More sharing options...
ben Posted March 3, 2011 Author Share Posted March 3, 2011 To conclude : I've just tried it at home on my mac (same H release .581) and it works fine (with both my otl and graham one) ... Still strange because the node takes about 550ms to cook on my PC at work and "only" 150ms less on mac at home. I dont't know but I guess my problem was more a hardware issue (slow or fragmented hard drive maybe ?) Anyway this was my first try with HOM and i've learn new stuff today. Special thx to graham. ben Quote Link to comment Share on other sites More sharing options...
lukeiamyourfather Posted March 3, 2011 Share Posted March 3, 2011 I dont't know but I guess my problem was more a hardware issue (slow or fragmented hard drive maybe ?) Or a software bug. Try the latest Houdini and/or check the journal. Quote Link to comment Share on other sites More sharing options...
Macha Posted March 4, 2011 Share Posted March 4, 2011 I have no probs with it. Tested local and on network. 10.0.658 Quote Link to comment Share on other sites More sharing options...
LaidlawFX Posted March 4, 2011 Share Posted March 4, 2011 Wicked cool. Thanks Ben and Graham. Quote Link to comment Share on other sites More sharing options...
ben Posted March 4, 2011 Author Share Posted March 4, 2011 Apparently my problem was a software bug 11.0.463 : OK 11.0.504 : OK 11.0.581 : Refresh problems 11.0.658 ! OK Quote Link to comment Share on other sites More sharing options...
ben Posted March 4, 2011 Author Share Posted March 4, 2011 Nearly the same, just added Prefix and Suffix filter. ListFiles.otl Quote Link to comment Share on other sites More sharing options...
graham Posted March 4, 2011 Share Posted March 4, 2011 Glad it's working out now. One thing I noticed after testing my version a little bit is my callback scripts on my node that were meant to refresh the menu on toggle changing weren't working out as well as I'd hoped. A better solution is to change the callbacks for the toggle and directory to be 'hou.pwd().cook(True)'. This works a bit better because it causes the entire node to recook and thus causes the menu to properly refresh before hand and makes it so no matter how often the toggles change or whatever the menu is always accurate. Quote Link to comment Share on other sites More sharing options...
ben Posted March 4, 2011 Author Share Posted March 4, 2011 Nice tip, works well. Thx Graham 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.