Monday 27 January 2020

Week 3 - Json Files Part 1

As per Mike Pickton's suggestion I had a look into using .json files for creating a variety of modular piece sets to use for the building generator. That inevitably meant digging out my very limited and dusty Python knowledge from 4 years ago, plus learning a bunch of new stuff.

I started by testing how to read from and write to .json files in Houdini, but ultimately decided, that we needed an external tool for creating those files, which also adds the advantage of making it reusable in the future ( with some changes ).

The idea is, that in this tool you can create either a list of the entire modular kit, you want to import to Houdini or files for specific sets, e.g. ground floor, roof, etc. and also stores certain attributes of each piece, based on a list of keywords, so that in Houdini I can filter out corner, window, etc. pieces, instead of having to create separate files for all of those.

I plan to add an Editor option to the tool, so you can easily edit those .json files, for example appending or replacing pieces, maybe also based on piece type. Furthermore I need to make an executable file out of it.





Here is how it works in its current state:

Current User Interface



As for future plans I will now move on to properly implementing the use of those files in Houdini and also do some testing with how it translates to UE4. Whilst doing that I am sure I will have to adapt how exactly the tool works, improve and expand it.

1 comment:

  1. Nice!

    Couple of tips:

    - You can write your json with whitespace, which makes it more readable. It adds a small amount of cost to the json files, but that really isnt a concern here. From memory, I think you just specify the indentation... check it out:
    https://codeblogmoney.com/json-pretty-print-using-python/

    "bare" exceptions are a recipe for hiding bugs you want to raise as exceptions. Bit of reading on that here:
    https://python101.pythonlibrary.org/chapter7_exception_handling.html

    Finally, although I haven't don much UI in python, my limited experience has been finding tkinter rather painful, and switching up to pyside. It has a WYSIWYG editor called QtDesigner. Perhaps if you do another UI it could be worth trying out? Also, if you want to do any tools in max or maya, they use pyQt, which is the same... ish? I think? In the case of max, at least, you don't need to use PyQt, but you can, and it offers more powerful controls than maxscript's basic ones. So it's a bit more widely used than tkinter.

    ReplyDelete