How to select just the x-coordinate in a given list using python script?

In this weird format, how can I select a given x-coordinate at a certain indices (let’s say list 3) in python script?

image

Hi @WARTELLAD

One possibility :

It is easier to get points from the vertex first using nodes such as Deconstruct.Vertex and the OTTB node Vertex.PointGeometry and then filtering point values as @Alban_de_Chasteigner has demonstrated.

A bit of a hack way (just DSCore functions) in Python is to convert it to a string, process the characters, then float it back to a number for further use… though you could do the same thing with OOTB nodes, outside the python environment. :neutral_face:

image

import clr
clr.AddReference('DSCoreNodes') 
import DSCore
from DSCore import *

vtex = DSCore.List.Flatten(IN[0],1)
ind=IN[1]
strlist = []
dataX=[]
dataY=[]
dataZ=[]

for v in vtex:
	strlist.append(v.ToString())

for s in strlist:
	data=String.Split(s,"X = ","Y = ","Z = ",",","))")
	dataX.append(DSCore.List.GetItemAtIndex(data,1))
	dataY.append(DSCore.List.GetItemAtIndex(data,3))
	dataZ.append(DSCore.List.GetItemAtIndex(data,5))
	
for x,y,z in zip(dataX,dataY,dataZ):
	indx=DSCore.List.GetItemAtIndex(dataX,ind)
	indy=DSCore.List.GetItemAtIndex(dataY,ind)
	indz=DSCore.List.GetItemAtIndex(dataZ,ind)

OUT = float(indx),float(indy),float(indz)
3 Likes

Thanks so much! One thing I do have left is to list all X-values in a given list. How do I do this without selecting at a single indices in python script? Would I have do a while loop while using a counter?

Nvm I got it.