Hi Juan,
I have put the call to setPropertyValue outside the begin/end block and the undo still doesn't work. This is the relevant part of the code:
this.SaveKeywords = function(imageWindow)
{
console.writeln("Save keywords");
imageWindow.mainView.beginProcess(UndoFlag_Keywords);
var keywords = imageWindow.keywords;
this.UpdateBasicKeywords(keywords);
this.UpdateWCSKeywords(keywords);
this.UpdateReferKeywords(keywords);
imageWindow.keywords = keywords;
imageWindow.mainView.endProcess();
};
this.SaveProperties = function(imageWindow)
{
console.writeln("Save properties");
if(this.controlPoints && (this.ref_I_G instanceof ReferSpline))
this.SaveControlPoints(imageWindow);
else
imageWindow.mainView.deleteProperty("Transformation_ImageToProjection");
};
this.SaveControlPoints = function(imageWindow){
console.writeln("Save controlpoints");
var lines=["VERSION:1","TYPE:SurfaceSpline"];
lines.push(format("ORDER:%d", this.ref_I_G.order));
lines.push(format("SMOOTHING:%f", this.ref_I_G.smoothing));
lines.push("CONTROLPOINTS:[");
for(var i=0; i<this.controlPoints.pI.length; i++)
if(this.controlPoints.pI[i] && this.controlPoints.pG[i]){
if(this.controlPoints.weights)
lines.push(format("%.16f;%.16f;%.16f;%.16f;%.16f",
this.controlPoints.pI[i].x,this.controlPoints.pI[i].y,
this.controlPoints.pG[i].x,this.controlPoints.pG[i].y,
this.controlPoints.weights[i]));
else
lines.push(format("%.16f;%.16f;%.16f;%.16f",
this.controlPoints.pI[i].x,this.controlPoints.pI[i].y,
this.controlPoints.pG[i].x,this.controlPoints.pG[i].y));
}
lines.push("]");
var byteArray = new ByteArray(lines.join('\n'));
imageWindow.mainView.setPropertyValue("Transformation_ImageToProjection", byteArray, PropertyType_ByteArray, PropertyAttribute_Storable);
};
I call first the method SaveKeywords and then SaveProperties.
If I run this script on an image which doesn't have any properties a new property "Transformation_ImageToProjection" is created. If I execute an undo, I expect that the image doesn't have any properties again. However, after the undo the property "Transformation_ImageToProjection" is still defined in the image. This behaviour breaks the synchronization between the data stored in the keywords and properties.