Hello guys, I would like to output two different colored meshes after creating the geometry of the first mesh.
can someone help me?
I recently started using python on grasshopper.
Thanks.
Domenico
This is my script in python with rhinocommon:
meshColours.py (658 Bytes)
import Rhino.Geometry as rg
from System.Drawing import Color
from scriptcontext import doc
mesh = rg.Mesh()
mesh.Vertices.Add(rg.Point3d(0, 0, 0))
mesh.Vertices.Add(rg.Point3d(10, 0, 0))
mesh.Vertices.Add(rg.Point3d(10, 10, 0))
mesh.Vertices.Add(rg.Point3d(0, 10, 0))
mesh.Faces.AddFace(0, 1, 2, 3)
mesh.VertexColors.CreateMonotoneMesh(Color.Blue)
doc.Objects.AddMesh(mesh)
dup = mesh.DuplicateMesh()
dup.VertexColors.CreateMonotoneMesh(Color.Red)
doc.Objects.AddMesh(dup)
meshColours.py (487 Bytes)
1 Like
Thank you very much.
Last question:
I would like to color the vertices with different colors and not use ‘CreateMonotoneMesh (Color.Red)’
import Rhino.Geometry as rg
from scriptcontext import doc
mesh = rg.Mesh()
mesh.Vertices.Add(rg.Point3d(0, 0, 0))
mesh.Vertices.Add(rg.Point3d(10, 0, 0))
mesh.Vertices.Add(rg.Point3d(10, 10, 0))
mesh.Vertices.Add(rg.Point3d(0, 10, 0))
mesh.Faces.AddFace(0, 1, 2, 3)
mesh.VertexColors.Add(255,255,0)
mesh.VertexColors.Add(255,50,255)
mesh.VertexColors.Add(100,255,255)
mesh.VertexColors.Add(255,255,150)
doc.Objects.AddMesh(mesh)
dup = mesh.DuplicateMesh()
dup.VertexColors.Clear()
dup.VertexColors.Add(0,255,255)
dup.VertexColors.Add(255,50,255)
dup.VertexColors.Add(255,255,100)
dup.VertexColors.Add(150,255,255)
doc.Objects.AddMesh(dup)
meshColours.py (659 Bytes)
1 Like