When I import a WRL file via script, the texture mapping with the corresponding jpg works fine. But if I extract the mesh geometry and then add that mesh back to the doc, only vertex colors remain, no mesh texture. Is there a way to include the texture mapping when I extract the mesh geometry?
Well, I don’t see any texture mapping. But I do see a material that uses a color texture.So perhaps all you need to do is assign the material from the source object, Rhino.DocObjects.ObjectAttributes.MaterialIndex, to the newly created target object.
Okay, make sense now. Though I’m having trouble setting MaterialIndex. It seems to get set in code, but then in the document the material is still being set by the layer. How might I change the following code to address this?
Dim MeshrhObject = Doc.Objects.Find(MeshID)
Dim MaterialIndexStored = MeshrhObject.Attributes.MaterialIndex
Dim NewMeshID = Doc.Objects.AddMesh(Mesh)
Dim NewMeshrhObject = Doc.Objects.Find(MeshID)
NewMeshrhObject.Attributes.MaterialIndex = MaterialIndexStored
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
var go = new GetObject();
go.SetCommandPrompt("Select object to copy");
if (go.CommandResult() == Result.Success)
var obj = go.Object(0).Object();
if (null != obj)
var geo = obj.Geometry;
if (null != geo)