0
$\begingroup$

I would like to create a precise number of geometry nodes and then position each instance based on some code.

enter image description here

The only way I found to place these instances is the apply the modifier, separate by loose part and then change the coordinates of each created object. However is there a way I can do that directly within the node tree, by e.g. passing a vector list as input to the Points Positions node ?

$\endgroup$

1 Answer 1

1
$\begingroup$

One way to bring an arbitrary list of positions into geometry nodes is to encode the positions into a texture.

testList.txt:

0.5 0.5 0.5 0 0 0 1 1 1 1 0 0 0 1 0 0 0 1 -0.5 -0.5 -0.5 -0.8 -0.8 -0.8 

EncodeVectorList.py:

import bpy import csv filepath = bpy.path.abspath("//testList.txt") results = [] with open(filepath) as csvfile: reader = csv.reader(csvfile, delimiter=' ', quoting=csv.QUOTE_NONNUMERIC) # change contents to floats for row in reader: # each row is a list results.append(row) # The 8 here is the number of points img = bpy.data.images.new("testImg", 8, 1, alpha=False, float_buffer=True, is_data=True) # Adds an unused alpha channel for formatting reasons and flattens the list img.pixels = [item for sublist in [color + [1.0] for color in results] for item in sublist] 

For Blender at least, colors are stored as floats, so any position values should be valid.

Node setup and result:

VectorList geometry node setup and results

Make sure to set interpolation to closest on the Image Texture node.

$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.