import rhinoscriptsyntax as rs #from System.Drawing import Color class AlgoNode(): def __init__ (self, LINE): #print "made an AlgoNode" self.line = LINE lineTokens = self.line.split(",") self.part = int( lineTokens[0].split(" ")[1] )#propably object count self.element = int( lineTokens[1].split(" ")[2] )#face count self.elementNode = int( lineTokens[2].split(" ")[3] )#count of vertex in face self.node = int( lineTokens[3].split(" ")[2] )#vertex index self.x = float( lineTokens[4].split(" ")[3] ) self.y = float( lineTokens[5].split(" ")[3] ) self.z = float( lineTokens[6].split(" ")[3] ) self.val = float( lineTokens[7].split(" ")[2] ) class AlgoMesh(): def __init__(self,path): data = open(path,'r') self.algoNodeList = [] for line in data: self.algoNodeList.append(AlgoNode(line)) def vertices(self): #here return the vertices result = [] #for myAlgoNode in self.algoNodeList: # result.append([myAlgoNode.x, myAlgoNode.y, myAlgoNode.z]) temp4count = self.nodes() temp4count.sort() allNodes = self.nodes() for i in range(temp4count[-1]): index = allNodes.index(i+1) result.append([self.algoNodeList[index].x, self.algoNodeList[index].y, self.algoNodeList[index].z]) return result def faceVertices(self): #here return the face vartices result = [] oldElement = self.algoNodeList[0].element oneFace = [] for myAlgoNode in self.algoNodeList: if myAlgoNode.element == oldElement: oneFace.append(myAlgoNode.node-1) else: oldElement = myAlgoNode.element result.append(oneFace) oneFace = [] oneFace.append(myAlgoNode.node-1) return result def vertexColors(self): #here return the vertex colors result = [] temp4count = self.nodes() temp4count.sort() allNodes = self.nodes() for i in range(temp4count[-1]): index = allNodes.index(i+1) color = 255*50*self.algoNodeList[index].val / self.maxVal() if color>255 : color = 255 result.append((color,color,color)) return result def nodes(self): #here return the vertices result = [] for myAlgoNode in self.algoNodeList: result.append(myAlgoNode.node) return result def maxVal(self): listOfVals = [] for myAlgoNode in self.algoNodeList: listOfVals.append(myAlgoNode.val) listOfVals.sort() return listOfVals[-1] def Main(): #myAlgoNode = AlgoNode("Part# 1, Element# 1, Element Node# 1, Node# 368, X = 615.779, Y = -158.81, Z = -358.427, Val 0") #print myAlgoNode.val myAlgoMesh = AlgoMesh('C:zingbanger2.txt') myMesh = rs.AddMesh(myAlgoMesh.vertices(), myAlgoMesh.faceVertices()) rs.MeshVertexColors(myMesh, myAlgoMesh.vertexColors()) #rs.AddPointCloud(myAlgoMesh.vertices()) Main() Update