Rhino3dmIO create mesh from scratch


I use Rhino3dmIO to support 3dm file format as an export option for my app.
So I create new 3dm files from scratch, based on mesh data created by my app.

Currently I do:

 var m = new Rhino.Geometry.Mesh();
 var verts = mesh.Vertices.Select(x => new Rhino.Geometry.Point3d(x.X, x.Y, x.Z));
 var faces = mesh.Triangles.Select(x => new Rhino.Geometry.MeshFace(x.P0, x.P1,x.P2));

Which works well.
There are a couple of things that I have not been able to figure out, which would really improve the quality of the 3dm file export.

  1. How to add a texture/material to a mesh? I have an image, and some parameters, how do I create a material from those, and how do I apply that to the mesh?
  2. How to create blocks/instances? I have lots of duplicate geometry, which I would prefer would stay grouped, like “blocks” in dxf for example, so that editing one edits all.

Thank you for your time!