RickWork Posted January 28, 2005 Share Posted January 28, 2005 Hello CHOPS Masters, Is there an if statement in CHOPs? I have 2 export CHOPs and I want to only export if the user picks a file for the FileCHOP otherwise do nothing. Currently, if a file is not specified the exportCHOP still overrides my object parameters that I'm exporting to with 0 values. Thanks, Rick Quote Link to comment Share on other sites More sharing options...
old school Posted January 28, 2005 Share Posted January 28, 2005 First off, you should be using the export CHOP and NOT the export flag to do this. The Export CHOP is exactly what you want. The left input takes your channel, the right input takes a binary channel to enable-disable the export mechanism. Simple. Now to create the binary condition for the export chop, you simply need to put down a constant CHOP and for the first channel, use the following expression: clamp(argc(chs("/obj/model/file1/file")),0,1) argc() simply counts the number of arguements supplied. If the string is empty it returns zero and if there is something in there, return a one guaranteed with the clamp max of 1. You don't need the clamp in this case but you never know when an unsuspecting windows user will supply a name with a space or some other foul character. I am sure there are other ways to test to see if the file has actual data or not but the expression above is one that doesn't care if the SOP has an error or not. You are just parsing a string in a parm field, that's all. Quote Link to comment Share on other sites More sharing options...
old school Posted January 28, 2005 Share Posted January 28, 2005 Oh, I didn't answer your first question: Is there an if statement in CHOPs? Yes there is but in an entirely different way than what you are looking for. In CHOPs you build up your logic using channels as conditions. Many of the CHOPs that perform logic operations will have a separate input for the condition channel as the export CHOP example above or the very handy Logic CHOP which will take in any motion channel and convert it to a binary channel based on certain conditions and then you use the output channels in other chops like count CHOP, fan CHOP, etc. Other chops will take the first channel as the logic input like the blend CHOP. The blend CHOP will blend between any number of inputs but it is the first channel incremented by ones that determines which subsequent inputs to switch to. I find that programming experience is actually a hinderance to building these visual nodes with logic. Same for VOPs. Great news for artists as they will have a much easier time of it learning to programme visually with these nodes. I really have to switch to a different part of my brain when I programme visually with nodes as opposed to writing code. 1 Quote Link to comment Share on other sites More sharing options...
RickWork Posted January 28, 2005 Author Share Posted January 28, 2005 Hi Jeff, Thanks for your reply. I tried your suggestion but am still not having luck with this. Here's my CHOP Setup. FileCHOP is wired into the left input of a ExportCHOP The ExportCHOP Node param is "/obj/model", the path parm is "tx" I now have a ConstantCHOP wired into the right input of the ExportCHOP. The Channel is the default 0? The Expression is: clamp(argc(chs("../file1/file")),0,1) Don't I still need to click on the export flag on the exportCHOP? I tried it both ways with no luck so I'm guessing my problems are upstream. P.S. I do agree that I need to start thinking differently when working with CHOPs/VOPs. My first thought was if(file) export! Thanks, Rick Quote Link to comment Share on other sites More sharing options...
RickWork Posted January 28, 2005 Author Share Posted January 28, 2005 Alright, after some tinkering around I got the your tip working but the end result is not behaving The expression works as you said it would. If there's a file specified in the FileCHOP, the constantCHOP expression returns 1 otherwise it returns 0. Perhaps i'm having a refresh problem because the ExportCHOP does not update. If I save the scene with nothing in the Path of the FileCHOP, nothing gets exported as it should. Now if I reopen the scene and provide a .chan file for the FileCHOP still, nothing is exported unless I starting tinkering with the CHOPS nodes (click on display, export, etc), then it will finally do what I want. Is there no way to force it to eval on change? In the long run, I will be wrapping all this up into an otl. Thanks, Rick Quote Link to comment Share on other sites More sharing options...
old school Posted January 28, 2005 Share Posted January 28, 2005 What version of Houdini? There is a bug where CHOPs won't update on channel dependencies like this. This should be fixed now. -jeff Quote Link to comment Share on other sites More sharing options...
RickWork Posted January 28, 2005 Author Share Posted January 28, 2005 What version of Houdini? There is a bug where CHOPs won't update on channel dependencies like this. This should be fixed now.-jeff 16010[/snapback] I'm using Houdini 7.0.195 on linux. Do you if there's a suggested workaround? Thanks, Rick Quote Link to comment Share on other sites More sharing options...
Lukich Posted January 29, 2005 Share Posted January 29, 2005 I stumbled at the problem of chops not updating. Was able to overcome that by using chopcf function, which, used on the sop level, grabs info from chops. Quote Link to comment Share on other sites More sharing options...
edward Posted January 29, 2005 Share Posted January 29, 2005 Try using a Switch CHOP in between your File CHOP and Export CHOP. Put Jeff's expression into the Index parameter of the Switch CHOP instead. The problem is that you don't want the File CHOP to cook if there's no filename in it as that will cause errors (the red triangle stuff) to propagate down stream. To fix the update problems, I suggest just putting the appropriate opcook -F command in the callback script of your otl file parameter. Quote Link to comment Share on other sites More sharing options...
RickWork Posted January 31, 2005 Author Share Posted January 31, 2005 Thanks Edward. It's working good now. Cheers fellas! Rick 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.