Jump to content

JXS

Members
  • Content count

    7
  • Donations

    0.00 CAD 
  • Joined

  • Last visited

  • Days Won

    1

JXS last won the day on February 20 2020

JXS had the most liked content!

Community Reputation

4 Neutral

About JXS

  • Rank
    Peon

Personal Information

  • Name
    Jael Lopez
  • Location
    United States

Recent Profile Visitors

362 profile views
  1. JSON, PYTHON and Detail Attribs

    Not sure if this is what you're looking for but here goes. Upon importing your JSON file, I "cleaned it up" a bit and created a new dictionary called "process" using DOM_ID/PATTERN as key/value pairs. I retained the original dict for clarity's sake. Then in an attribute wrangle running in Detail(any mode will do, but I have no geometry here in this scene so detail is the appropriate mode), just import your dictionary using the detail() function, then access the values using whatever DOM_ID you wish. I cleaned it up because basically, in VEX terms, you have a single key pointing to an array of dictionaries and each dictionary's DOM_ID is separate from its pattern. If anything you wouldn't even need the DOM_ID to access the PATTERN. Something like the following in the attribute wrangle would get you your PATTERN: dict list_of_dicts[] = detail(0, "dom_dict")["DOM_IDS"]; foreach(dict dct; list_of_dicts){ string pat = dct["PATTERN"]; printf("%s\n", pat); }
  2. Multiparm callbacks

    I tried to wrap my head around this one but from my understanding, and if anyone with more exp on this could chime in, those buttons are tied to one parameter, namely, whatever your folder's name is. They themselves are not parameters (unless if you make two individual buttons but that's another thing entirely). As expected, when you increment, the script value (kwargs["script_value"]) goes up and vice versa with the - button, but all in all they are altering the same parameter, which means only one callback script...I think. I contemplated the idea of perhaps using a callback script as an entry function and passing in the parameter values. The X/Clear button sets it to 0 by default and the +/- buttons move that value up/down respectively, so maybe you could attempt to feed that value as a key to a dictionary of functions or perhaps more simply, a simple if/else statement where if the value passed is 0, the function will call some nested function A(), and if the value passed is greater than 0, the function will call some nested function B(). Something like the following: def entry_point(kw): def hi(): print("Hi") def bye(): print("Bye") hi() if int(kw) > 0 else bye() Very simple example yes, but it works. Then in the callback script just type in something like the following: __import__(module_name_here).function_name(kwargs["script_value"]. Of course, now you have the issue that your first function will run regardless of whether you press the + or - button and if it's non-zero. The only way the second function will run is if the parameter value is 0. So, like @acey195 said, unless if there's a way to store the previous parameter value, like a global variable, and compare it to the new value, then no, there is no way to differentiate between the +/- buttons and attach different callback scripts to them. With the script above, maybe you could differentiate between the +/- and the X/Clear but at this point, you're probably better off achieving your original goal by simply dropping down two button parameters and attaching your callback scripts to them. I'm certain that what you're asking for is doable, but probably not through a callback script, I think. Hopefully someone with more exp could chime in on this.
  3. New materials based on s@name attribute

    Hi. Not sure if this is what you're looking for. Without a HIP file, I don't have much to work with but given what it is you're looking for, this is how I would go about it. Hope it helps! I’m sure what your attempting to do is doable using the iterPrims() method, but in my case I simply tackled them all at once using the prims() method, extracted the “state” attribute on each loop and created a principled shader using the value of the attribute. I set up an additional file_path_dir string attribute which I also use to set the texture path parameter in the shader. material_name_attrib.hip
  4. Houdini Python hou.setPreferance

    Hi! Yes. I recall helping out sometime last year on a similar topic. To get the list of names and values, you can run the following quick snippet on a Python shell: list_of_prefs = sorted(hou.getPreferenceNames()) for pref in list_of_prefs: print(pref + ": " + hou.getPreference(pref)) Basically, hou.getPreferenceNames() will return a tuple of all the preference names (the names you would use in setPreference). the sorted function is optional. In a loop, you can process each name to get its current value using hou.getPreference().
  5. As a follow up, I created a simple shelf tool which implements the method I mentioned above. Here's a proof-of-concept:
  6. I was curious about this so I remote sessioned into Houdini...cause I’m at work at the moment. I used the Python Shell so I haven’t had a chance to test out a shelf tool or startup script version but it should work nonetheless. In the shell, running hou.getPreferenceNames() returns, among all the prefs, 2 autosave related preferences. There is a third one but it’s not immediately related to the problem at hand. 1: “general.autosaveinterval.val” This corresponds to the Auto Save Every X Minutes where X is the current value. 2: “general.autosaveinc.val” This corresponds to the Auto Save Method This is the one you’re looking for. To change preferences use hou.setPreferences(name, value) where name corresponds to the preference name and value to the value you desire. The values for Auto Save Method are as follows: ’0’ : Overwrite File ’1’ : Increment Filename ’2’ : Make Numbered Backup Let’s say that by default, my unsaved scene starts with the setting at Overwrite File and I want to change it to Make Numbered Backup. In the shell or shelf tool or wherever, I would just run the following: hou.setPreference(“general.autosaveinc.val”, “2”) If successful, the method will return True. Otherwise it will return False. Make sure that both the name and the value arguments you pass to it are strings, as in, in quotations or you may error out.
  7. Get time and date as a global variable

    I second the use of the datetime module as well. Here’s the documentation for that specific module. I found myself in a similar spot when I changed naming conventions for saving project files. I was always doing the whole 01_, 02_ thing, until I realized it wasn’t very intuitive for me. So I created a custom Python shelf tool that saves my hip files to a specific location using a date based naming convention. Here’s a snippet of the code containing the date/time section: def filePrep(self): timeStamp = datetime.datetime.now().strftime("%m-%d-%y_%I_%M_%p_") if self.ui.sys_time.isChecked() else None The sys_time portion is Qt-centric code since I’m wrapping it all in a QWidget using PySide2, but after all is said and done, the script outputs a directory which is then fed to the hou.hipFile.save() method and saves it. As an example, the code would spit out something like: $HOME/Projects/(Project Name Here)/hipfiles/02-18-20_10_49_AM_filename.hip Those % characters are format codes you can feed to the strftime method to return a string according to what you need. Check out the linked documentation.
×