I am working to create a network of a lot of spheres in paraview. I have coordinates and their respective names in a spreadsheet that I imported to paraview as a CSV. I am creating everything through the python shell using loops because there are over 900 different spheres I need to visualize.
I have successfully created the network of spheres, but the next step is to create tubes that connect all these spheres (the tube data is in the format of startnode: node4 endnode: node5 which is meant to connect node 4 and 5) The problem I am having is I cannot rename the spheres I have created using their names that are in the spreadsheet with their coordinates. The names are in the format of integers. I am attaching my algorithm I have now that works and renames the spheres as “node1, node2, node3, etc” but I need to call a specific cell from my spreadsheet to be the name of the spheres.
from paraview.simple import *
table = FindSource(‘nodes test - Sheet1.csv’)
#Create a TableToPoints filter to convert table data into points
tableToPoints = TableToPoints(Input=table)
tableToPoints.XColumn = ‘x’ # Set the X column
tableToPoints.YColumn = ‘y’ # Set the Y column
tableToPoints.ZColumn = ‘z’ # Set the Z column
#Update to ensure the filter is applied
tableToPoints.UpdatePipeline()
#Get the output data
outputData = servermanager.Fetch(tableToPoints)
#Set radius of nodes
radius = 25 # Diameter of 50
#Loop over each point in the output data and create spheres
for i in range(outputData.GetNumberOfPoints()):
x, y, z = outputData.GetPoint(i)
sphere = Sphere()
sphere.Center = [x, y, z]
sphere.Radius = radius
sphere_name = f"node{i+1}"
RenameSource(sphere_name, sphere)
Show(sphere)
SetActiveSource(sphere)
Render()