I have an issue with adding/editing RenderTextures in the Rhino document.
The command I implemented creates a new RenderTexture or edits the rotation of an already existing one. I can see the changes in the RenderTextureTable at the end of the command. Although, when I undo the command, the RenderTexture does not undo its changes, like they were not registered inside the command. I tried to use BeginChange and EndChange on the texture table and on the single textures to notify the change, but it did not work.
Any suggestions?
Hello, of course! I attach here the piece of code where the texture is edited: it is part of a method called from a plug in command (so derived from a Rhino Command class). I also tried to add RhinoDoc.BeginUndoRecord and EndUndoRecord at the beginning and end of the command, but it made no difference.
var undoid=doc.BeginUndoRecord("edit texture");
(...)
doc.RenderTextures.BeginChange(RenderContent.ChangeContexts.Program);
for (int i = 0; i < doc.RenderTextures.Count; ++i) {
var tex = doc.RenderTextures[i];
if (tex.Id == textureId) {
tex.BeginChange(RenderContent.ChangeContexts.Program);
tex.SetRotation(new Vector3d(0, 0, rotation), RenderContent.ChangeContexts.Program);
tex.EndChange();
doc.RenderTextures.EndChange();
return;
}
}
(...)
doc.EndUndoRecord(undoid);