Analysis
As usual, let’s start with a quick review of the assignment.
This week’s task is fairly straightforward with no major logical hurdles. The main thing to watch out for is the class hierarchy. I sketched the minimal layout as follows: the CSG class goes in CSGModule.py, while the Box and Tube classes go in ShapeModule.py.
One important detail: we use variables t, r, s, and c to store Position, Rotation, Scale, and Color respectively. When you actually modify them, make sure you are updating the node’s internal parameters. This is where __setattr__ helps a lot and greatly simplifies the code. Since __setattr__ is invoked whenever an attribute is set, we just detect changes to t, r, s, and c and then forward those changes to the node’s parameters.
Because this week’s assignment asks you to split classes across different files and call them from a main file, you can simply place those modules into Houdini’s Python library so they can be imported directly.
Example (Houdini 20.5.613)
-
Find Houdini’s Start Menu folder:
-
Go to the Python libs directory:
-
Put the files there:
-
In your Houdini Python script, import the classes:
Note: I didn’t import
CSGModule.pyexplicitly here because it is already imported insideShapeModule.py, so there’s no need to import it again.
没有评论:
发表评论