Forgot password?

Create an account!

Forum

« back

Python – can't color my tetrahedron

Messages

Please log in to write a message.

  • 1. new haven (Feb 12, 2018 05.50):

    Hi all,

    I am working on this piece of code:

    import rhinoscriptsyntax as rs

    class Tetra():

    def __init__(self, PTS, TYPE):
    self.vtxs = PTS
    self.type = TYPE
    self.fvtxs = []
    self.fvtxs.append([0,2,1])
    self.fvtxs.append([0,1,3])
    self.fvtxs.append([1,2,3])
    self.fvtxs.append([2,0,3])
    self.id = rs.AddMesh(self.vtxs,self.fvtxs)

    def paintme(self):
    if self.type == "A":
    colors = [ [255,0,0], [255,0,0], [255,0,0], [255,0,0] ]
    elif self.type == "B":
    colors = [ [0,255,0], [0,255,0], [0,255,0], [0,255,0] ]
    elif self.type == "C":
    colors = [ [0,0,255], [0,0,255], [0,0,255], [0,0,255] ]
    else:
    colors = [ [0,0,0], [0,0,0], [0,0,0], [0,0,0] ]
    rs.MeshVertexColors(self.id,colors)

    def Main():
    #ask the user for 4 points-coordinates
    pts = rs.GetPoints(True)
    #create a new instance of the class Tetra
    myTetra = Tetra(pts, "A")
    #paint the tetrahedron based on its type
    myTetra.paintme()
    Main()



    I can't make it work. The message that I get back is:
    ''Message: length of colors must match vertex count''

    Besides I get messages that something is happening in lines that don't even exist. Any thoughts?

    Thanks

Recommend

Why are these buttons gray?