Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,61 @@
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/BrendanParmer/NodeToPython)](https://github.com/BrendanParmer/NodeToPython/releases) [![GitHub](https://img.shields.io/github/license/BrendanParmer/NodeToPython)](https://github.com/BrendanParmer/NodeToPython/blob/main/LICENSE) ![](https://visitor-badge.laobi.icu/badge?page_id=BrendanParmer.NodeToPython)

## About
A Blender add-on to create add-ons! This script will take your Geometry Node group and convert it into a legible Python script.
A Blender add-on to create add-ons! This script will take your Geometry Nodes or Materials and convert them into legible Python add-ons!

It automatically handles node layout, default values, sub-node groups, naming, and more!

I think Geometry Nodes is a powerful tool that's fairly accessible to people. I wanted to make scripting node groups easier for add-on creators in cases when Python is needed, as you don't need to recreate the whole node tree from scratch to do things like
I think Blender's node-based editors are powerful, yet accessible tools, and I wanted to make scripting them for add-on creators. Combining Python with node based setups allows you to do things that would otherwise be tedious or impossible, such as
* `for` loops
* different node trees for different versions or settings
* interfacing with other parts of the software.

NodeToPython is compatible with Blender 3.0-3.4
NodeToPython recreates the node networks for you, so you can focus on the good stuff.

## Supported Versions
Blender 3.0 - 3.4
NodeToPython v2.0 is compatible with Blender 3.0 - 3.4 on Windows, macOS, and Linux. I generally try to update the addon to handle new nodes around the beta release of each update.

* Once the 3.5 beta drops, I'll start adding nodes from that release
## Installation
1. Download the .zip file from the [latest release](https://github.com/BrendanParmer/NodeToPython/releases)
2. In Blender, navigate to `Edit > Preferences > Add-ons`
3. Click Install, and find where you downloaded the zip file. Then hit the `Install Add-on` button, and you're done!

## Installation and Usage
Download `node_to_python.py`, and install it to Blender like other add-ons. Then, go to `Object > Node to Python`, and type in the name of your node group. It will then save an add-on to where your blend file is stored.
## Usage
Once you've installed the add-on, you'll see a new tab to the side of a Node Editor.

In the tab, there's panels to create add-ons for Geometry Nodes and Materials, each with a drop-down menu.

Just select the one you want, and soon a python file will be created in an `addons` folder located in the folder where your blend file is.

From here, you can install it like a regular add-on.

## Future
* Expansion to Shader and Compositing nodes
* Expansion to Compositing nodes
* Copy over referenced assets in the scene (Collections, Objects, Materials, Textures, etc.)
* Automatically format code to be PEP8 compliant

## Potential Issues
* As of version 1.2.1, the add-on will not set default values for
* As of version 2.0.0, the add-on will not set default values for
* Collections
* Images
* Materials
* Objects
* Textures
* Scripts
* IES files
* Filepaths

as they won't exist in every blend file. I plan on implementing these soon.
as they won't exist in every blend file. I'm expecting to support some of these in the future.

There are a few nodes that don't set their default values like other ones, though these should also soon be supported.

## Bug Reports and Suggestions

When submitting an issue, please include

* Your version of Blender
* Your operating system
* A short description of what you were trying to accomplish, or steps to reproduce the issue

If you don't mind sharing a blend file, that helps a lot!

Suggestions for how to improve the add-on are more than welcome!
* A short description of what you were trying to accomplish, or steps to reproduce the issue.
* Sample blend files are more than welcome!

Suggestions for how to improve the add-on are more than welcome!
49 changes: 49 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
bl_info = {
"name": "Node to Python",
"description": "Convert Blender node groups to a Python add-on!",
"author": "Brendan Parmer",
"version": (2, 0, 0),
"blender": (3, 0, 0),
"location": "Node",
"category": "Node",
}

if "bpy" in locals():
import importlib
importlib.reload(materials)
importlib.reload(geo_nodes)
else:
from . import materials
from . import geo_nodes

import bpy

class NodeToPythonMenu(bpy.types.Menu):
bl_idname = "NODE_MT_node_to_python"
bl_label = "Node To Python"

@classmethod
def poll(cls, context):
return True

def draw(self, context):
layout = self.layout.column_flow(columns=1)
layout.operator_context = 'INVOKE_DEFAULT'

classes = [NodeToPythonMenu,
geo_nodes.GeoNodesToPython,
geo_nodes.SelectGeoNodesMenu,
geo_nodes.GeoNodesToPythonPanel,
materials.MaterialToPython,
materials.SelectMaterialMenu,
materials.MaterialToPythonPanel]

def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)

if __name__ == "__main__":
register()
Binary file added __pycache__/geo_nodes.cpython-310.pyc
Binary file not shown.
Loading