I am struggling with shifting a list inside a class.
I made a random walker path with a list a lines. Now I would like to connect each of these lines, two by two, by dividing them by a number of points and linking them with these same points (pt1 to pt1, pt2 to pt2, etc.)
You can see what I am trying to achieve with the picture below (I made it with grasshopper)
Basically, I wanted to create two lists of lines, one of them shifted by one.
Then it is easy to connect the first point to the first point, the second to the second one, etc.
I tried to shift the list with the function .pop(0) but it doesn’t work.
Here is the code :
import rhinoscriptsyntax as rs import random as r r.seed(5) time = 50 class Walker: def __init__(self): self.x = 50 self.y = 50 self.z = 0 rs.AddPoint(self.x,self.y,self.z) sph1 = rs.AddSphere((self.x, self.y, self.z),0.1) def point(self): self.shape1 = (self.x, self.y, self.z) def step(self): stepX = r.uniform(-1,1) stepY = r.uniform(-1,1) stepZ = r.uniform(-1,1) self.x += stepX self.y += stepY self.z += stepZ self.shape2 = rs.AddPoint(self.x, self.y, self.z) sph2 = rs.AddSphere(self.shape2,0.1) def lines(self): self.line1 = rs.AddLine(self.shape1, self.shape2) self.line2 = rs.AddLine(self.shape1, self.shape2) def divLines(self): self.divPts1 = rs.DivideCurve(self.line1,5,True,True) self.divPts2 = rs.DivideCurve(self.line2,5,True,True) self.divPts2.pop(0) def linkPts(self): self.lineBetPts = rs.AddLine(self.divPts1, self.divPts2) w = Walker() pList =  for t in range(time): pList.append(w.point()) w.step() pList.append(w.lines()) pList.append(w.divLines()) pList.append(w.linkPts())
As you can see, it the def linkPts(self) definition, I wrote “rs.AddLine(self.divPts1, self.divPts2)”.
Normally I would like to connect all of the points from each list, so “rs.AddLine(self.divPts1, self.divPts2)”
But I didn’t wrote it yet because it doesn’t work for the moment (the points are overlapping).