# Creating a New Geometry / Function Node ###### tags: `Blender` In addition to a file that defines the function of a node, there are several files that need to be updated to reference that new code as well. This document will create a new geometry node called Stub. The instructions will also reference changes to the stub code for creating a function node. **source/blender/blenkernel/BKE_node.h** BKE_node contains a mapping of a static number to a human readable name that will refernce the node. A search of GEO_NODE_ or FN_NODE_ (depending on the type of node) in this file will reveal a list of #define statements. At the bottom of this list choose an unused incremented number and assign it a name. ``` #define GEO_NODE_STUB 1111 ``` **Your Node Source Code File** This file will contain the logic and layout information for your node. This file will live in the folder appropriate to its type: * source/blender/nodes/geometry/nodes * source/blender/nodes/function/nodes For the purposes of this documentation, we will create a geometry node stub called *source/blender/nodes/geometry/nodes/node_geo_stub.cc* The contents of this file will vary based on whether we are coding a geometry node or a function node. The main similarity will be a node registration function that the other files will reference. The layout of the main node file will be covered in another document. ``` void register_node_type_geo_stub() { static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_STUB, "Geometry Stub Example", NODE_CLASS_GEOMETRY, 0); // OTHER Node definitions and function references here nodeRegisterType(&ntype); } ``` There are a few items to note in this code. 1. The name of the registration function is laid out as follows: * register_ * node_type_geo_ // or node_type_fn_ * stub // name of node * 2. Declare a bNodeType variable. 3. The geo_node_type_base() function takes the following parameters: * The bNodeType variable that was just declared * The define name from BKE_node.h is used as the 2nd parameter of the function. * A display name for the node * A node class (this determines what color the node header is among other things) * 0. //TODO - leave 0 4. Register the bNodeType variable **source/blender/blenkernel/intern/node.cc** There is a function called registerGeometryNodes() in which to call the registration function defined in the node source file. ```register_node_type_geo_stub()``` **source/blender/nodes/CMakeLists.txt** In the CMakeLists file go to the secion of files in the geometry/nodes/ folder and add the node source file in alphabetical order: ``` geometry/nodes/node_geo_stub.cc``` **source/blender/nodes/NOD_geometry.h or source/blender/nodes/NOD_funcation.h** In the file corresponding to the type of node being created, add the function prototype of the node registration function in aplhabetical order: ```void register_node_type_geo_stub(void);``` **source/blender/nodes/NOD_static_types.h** This file contains the node definitions. In alphabetical order add the DefNode line for the new node ``` DefNode(GeometryNode, GEO_NODE_STUB, 0, "STUB", Stub, "Stub Node", "") ``` The parameters are as follows: 1. Node Type: GeometryNode or FunctionNode 2. Define Name for the Node 3. An RNA function if the node requires it, set to 0 if this node does not have custom storage 4. Used for Python. Follow the define name minus GEO_NODE 5. Pascal case version of node name used for Python API 6. The menu entry name 7. // TODO (leave blank) **release/scripts/startup/nodeitems_builtins.py** This file contains the definition for the Add Nodes Menu. Search for the appropriate GeometryNodeCategory to add an entry. The NodeItem name is a combination of the NodeType from the DefNode entry and the Pascal case version of the name. ``` NodeItem("GeometryNodeStub"), ```