custom_node_shape_creator.py¶
Custom node shape creator for Houdini.
This module provides functionality for creating and managing custom node shapes, including example network generation and shape data export. It handles:
- Creation of example node shape networks
- Export of shape data to JSON format
- Size and path management
- Group assignments and organization
The module uses a class-based approach to maintain state and manage the creation process, with separate methods for different aspects of shape creation.
Classes:
Name | Description |
---|---|
CustomNodeShapeCreator |
Main shape creation functionality |
CustomNodeShapeCreator
¶
Manages creation and export of custom node shapes.
This class handles the creation of example networks and export of node shape data to JSON format.
Attributes:
Name | Type | Description |
---|---|---|
node |
The HDA node being managed |
|
builder |
NetworkBuilder instance for creating examples |
Example
creator = CustomNodeShapeCreator(node) creator.create_example() creator.export_shape_data()
Source code in nodes/custom_node_shape_creator.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
__init__(node)
¶
Initialize with the HDA node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Node
|
The HDA node containing custom shape parameters. Must be a valid Digital Asset node. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If node is None or invalid |
TypeError
|
If node is not of type hou.Node |
Source code in nodes/custom_node_shape_creator.py
create_example()
¶
Create an example node shape network.
Creates a complete network demonstrating shape creation techniques based on the selected example type.
Notes
- Resets node parameters before creation
- Handles different example types
- Creates appropriate network structure
- Sets up proper connections
Example
creator.create_example() # Creates based on node's example parameter
Raises:
Type | Description |
---|---|
ValueError
|
If example index is invalid |
Source code in nodes/custom_node_shape_creator.py
export_shape_data()
¶
Export node shape data to JSON file.
Extracts shape data from the current node setup and exports it in a format suitable for node shape definition.
Notes
- Validates shape name and path
- Generates shape data structure
- Handles outline, flags, inputs/outputs
- Creates proper JSON formatting
Example
creator.export_shape_data()
Raises:
Type | Description |
---|---|
ValidationError
|
If shape name not specified |
Source code in nodes/custom_node_shape_creator.py
update_path()
¶
Update the export path parameter and label.
Updates the path parameter with the full normalized path and creates a truncated version for the display label if path is too long.
Raises:
Type | Description |
---|---|
RuntimeError
|
If path parameters cannot be updated |
ValueError
|
If directory or shape name is invalid |
Source code in nodes/custom_node_shape_creator.py
update_size()
¶
Update the node shape size parameter and label.
Updates the size parameter based on current width/height settings and refreshes the size display label.
Raises:
Type | Description |
---|---|
RuntimeError
|
If size parameters cannot be updated |
ValueError
|
If width or height values are invalid |
Source code in nodes/custom_node_shape_creator.py
avg_node_shape_info()
¶
Displays a message about the average node shape size.
Source code in nodes/custom_node_shape_creator.py
match_start(kwargs)
¶
Match the curve end parameter to the start parameter.
Synchronizes the end parameter value based on the start parameter when matching is enabled.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs
|
Dict[str, Any]
|
Callback keyword arguments containing: - node: The HDA node instance - parm: The parameter being modified - parm_name: Name of the parameter |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
KeyError
|
If required kwargs are missing |
Source code in nodes/custom_node_shape_creator.py
on_example_create(kwargs)
¶
Create an example node shape network.
Creates a demonstration network showing custom node shape usage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs
|
Dict[str, Any]
|
Callback keyword arguments containing: - node: The HDA node instance |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
RuntimeError
|
If example creation fails |
Source code in nodes/custom_node_shape_creator.py
on_export_shape(kwargs)
¶
Export node shape data to JSON.
Saves the current node shape configuration to a JSON file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs
|
Dict[str, Any]
|
Callback keyword arguments containing: - node: The HDA node instance |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
IOError
|
If export fails |
Source code in nodes/custom_node_shape_creator.py
on_update_path(kwargs)
¶
Update the export path parameter.
Updates the path parameter and display label based on current settings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs
|
Dict[str, Any]
|
Callback keyword arguments containing: - node: The HDA node instance |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
RuntimeError
|
If path update fails |
Source code in nodes/custom_node_shape_creator.py
on_update_size(kwargs)
¶
Update the node shape size parameter.
Updates size parameter and display label based on current dimensions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs
|
Dict[str, Any]
|
Callback keyword arguments containing: - node: The HDA node instance |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
RuntimeError
|
If size update fails |