Hi all
My name is Cristian, English is not my original language so I will apologize in advance.
I would like to know how to hide a vertex of a mesh, I followed the indications of the RhinoCommon API (applied in Python) to create a base mesh successfully, but I have not been able to hide a vertex of it.
The following code allows you to create a mesh cube with colors in each vertex:
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
import System.Drawing.Color as color
plane = Rhino.Geometry.Plane.WorldXY
angle = 45
vector = Rhino.Geometry.Vector3d(0,0,1)
plane.Rotate(angle,vector)
width = 20
lenght = 20
height = 15
rectangle3D = Rhino.Geometry.Rectangle3d(plane, width, lenght)
rectangle = rectangle3D.ToPolyline()
pointsRectangle = rectangle.ToArray()
point1=Rhino.Geometry.Point3d(pointsRectangle[0][0],pointsRectangle[0][1],pointsRectangle[0][2]-height/2)
point2=Rhino.Geometry.Point3d(pointsRectangle[1][0],pointsRectangle[1][1],pointsRectangle[1][2]-height/2)
point3=Rhino.Geometry.Point3d(pointsRectangle[2][0],pointsRectangle[2][1],pointsRectangle[2][2]-height/2)
point4=Rhino.Geometry.Point3d(pointsRectangle[3][0],pointsRectangle[3][1],pointsRectangle[3][2]-height/2)
point5=Rhino.Geometry.Point3d(pointsRectangle[0][0],pointsRectangle[0][1],pointsRectangle[0][2]+height/2)
point6=Rhino.Geometry.Point3d(pointsRectangle[1][0],pointsRectangle[1][1],pointsRectangle[1][2]+height/2)
point7=Rhino.Geometry.Point3d(pointsRectangle[2][0],pointsRectangle[2][1],pointsRectangle[2][2]+height/2)
point8=Rhino.Geometry.Point3d(pointsRectangle[3][0],pointsRectangle[3][1],pointsRectangle[3][2]+height/2)
meshVertexs = []
meshVertexs.append(point1)
meshVertexs.append(point2)
meshVertexs.append(point3)
meshVertexs.append(point4)
meshVertexs.append(point5)
meshVertexs.append(point6)
meshVertexs.append(point7)
meshVertexs.append(point8)
meshVertexsColors = []
meshVertexsColors.append(color.FromArgb(255,255,0,0))
meshVertexsColors.append(color.FromArgb(255,0,0,255))
meshVertexsColors.append(color.FromArgb(255,0,255,0))
meshVertexsColors.append(color.FromArgb(255,255,255,0))
meshVertexsColors.append(color.FromArgb(255,255,0,255))
meshVertexsColors.append(color.FromArgb(255,0,0,0))
meshVertexsColors.append(color.FromArgb(255,255,255,255))
meshVertexsColors.append(color.FromArgb(255,255,0,0))
meshFaces = []
meshFaces.append(Rhino.Geometry.MeshFace(0,1,2,3))
meshFaces.append(Rhino.Geometry.MeshFace(0,1,5,4))
meshFaces.append(Rhino.Geometry.MeshFace(1,2,6,5))
meshFaces.append(Rhino.Geometry.MeshFace(2,3,7,6))
meshFaces.append(Rhino.Geometry.MeshFace(3,0,4,7))
meshFaces.append(Rhino.Geometry.MeshFace(4,5,6,7))
meshBase = Rhino.Geometry.Mesh()
for vertice in meshVertexs:
meshBase.Vertices.Add(vertice)
for face in meshFaces:
meshBase.Faces.AddFace(face)
for color in meshVertexsColors:
meshBase.VertexColors.Add(color)
meshBase.UnifyNormals()
sc.doc.Objects.AddMesh(meshBase)
sc.doc.Views.Redraw()
if you activate the option of transparency or shading you can see the colored grid.
The following code tried to hide the vertice 3 of the cube without success (select the cube generated with the other code)
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
go = Rhino.Input.Custom.GetObject()
go.SetCommandPrompt("Select Mesh")
go.GeometryFilter = Rhino.DocObjects.ObjectType.Mesh
go.Get()
objRefs = go.Objects()
for objRef in objRefs:
mesh = objRef.Mesh()
vertices = mesh.Vertices
for vertice in vertices:
index = vertices.IndexOf(vertice)
if index == 3:
vertices.Hide(index)
sc.doc.Objects.Replace(objRef,mesh)
sc.doc.Views.Redraw()
Any suggestions to be able to hide the vertex number 3?
Thank you