RhinoObject.CreateMeshes does not include texture coordinates on ExtrusionObject or SubDObject

Not sure if this is intended or a (minor) bug - but currently (tested in R6 and R7) calling RhinoObject.CreateMeshes(MeshType.Preview, params, false) includes texture coordinates when called on SurfaceObject and BrepObject, but texture coordinates are lost on SubDObject or ExtrusionObject. Non-urgent as the following workaround exists, mentioning here to avoid someones’ headaches in the future:

#if RHINO_7_OR_NEWER
            if (!(material.GetTexture(TextureType.Bitmap) is Texture tx) || !tx.Enabled)
#else
            if (!(material.GetBitmapTexture() is Texture tx) || !tx.Enabled)
#endif
{
     // Extrusion and SubD mapping doesn't copy by default, Rhino bug?
    EnsureTextureMapping(obj, mesh);
}
        private void EnsureTextureMapping(RhinoObject source, Mesh target)
        {
#if RHINO_7_OR_NEWER
            if (source.GetMaterial(true)?.GetTexture(TextureType.Bitmap) is Texture tx && tx.Enabled)
#else
            if (source.GetMaterial(true)?.GetBitmapTexture() is Texture tx && tx.Enabled)
#endif
            {
                if (source.GetTextureChannels() is int[] chans && chans.Length > 0)
                {
                    if (chans.Contains(tx.MappingChannelId))
                    {
                        Rhino.Render.TextureMapping mapping = source.GetTextureMapping(tx.MappingChannelId, out Transform xfm);
                        if (mapping != null)
                        {
#if RHINO_6_OR_NEWER
                            target.SetTextureCoordinates(mapping, xfm, false);
#else
                            target.TextureCoordinates.SetTextureCoordinates(mapping);
#endif
                        }
                    }
                }
            }
        }

Hi @camnewnham,

Try using one of the RhinoObject.MeshObjects overrides.

– Dale