I'm writting a small script for the script Node of animation nodes, which I suppose uses python 3.7 like my version of Blender 2.82 does, but I'm hitting a NotImplementedError when I try to slice a list.
Here's an example code that shows this
import math
#recieve v1 from Blender
for i in range(len(v1) - 1):
p1 = v1[i]
p2 = v1[i + 1]
if (p1 - p2).length > maxDist:
middleNode = ((p1.x+p2.x)/2,(p1.y+p2.y)/2,(p1.z+p2.z)/2)
# v1[:i] = v1[0..i] and v1[i:] = v1[i..]
v1 = v1[:i] + middleNode + v1[i:]
#v1.insert(i+1,middleNode)
i = i + 1
v2 = v1
# send back v2 to Blender
I'm currently finding a workaround around this, but I didnt know where to ask about this. I've only just started using python inside Blender and would be really disapointed if I couldnt use any kind of slicing.
type
ofv1
? Inv1 = v1[:i] + middleNode + v1[i:]
. You are asking python to concatlist
tuple
list
in that line $\endgroup$ – HikariTW May 5 '20 at 1:25to_tuple()
method docs.blender.org/api/current/… $\endgroup$ – Gorgious May 5 '20 at 6:43