I have an issue with a drawing that I am working on. I start with a Visio drawing and use Diagram.NET to modify it. One of the modifications that I am doing is to change a Shapesheet 1-D Endpoints using the following code:
case "Y1":
// If this is a shape with 1-D Endpoints (a line)
if (shape.OneD)
{
// If this is a change relative to the current BeginY,
// add the evaluated value to the BeginY.
if (kvp.Value.ChangeType == ShapeChange.ChangeTypes.Relative)
shape.XForm1D.BeginY.Value += value.AsNumber();
// If this is a change absolute set the BeginY to the evaluated value.
else if (kvp.Value.ChangeType == ShapeChange.ChangeTypes.Absolute)
shape.XForm1D.BeginY.Value = value.AsNumber();
// If the change type is none, display a Warning
else
DisplayLogMessage($" WARNING: {shape.Name} handle={shape.ID} Y1 does not support a type of none.");
}
else
// If the shape does not have 1-D Endpoints, display an error.
DisplayLogMessage($" ERROR: {shape.Name} handle={shape.ID} does not support Y1.");
continue;
As an example, using the drawing in Image1-Diagram A as my source, I change the BeginY value of the top line.
When I open the resulting drawing in Visio, Image1-Diagram B, the shape does not appear to have changed, although the Begin point handle has moved.
When I nudge the End point, the shape is refreshed, and the Begin point moves to the position I had set it to in my code, Image1-Diagram C.
What do I have to do to get the drawing to refresh the end point?
I suspect that it has something to do with how OPC recalculates the file when it opens as per https://docs.microsoft.com/en-us/office/client-developer/visio/how-to-manipulate-the-visio-file-format-programmatically#recalculate-data-in-the-file
Is there a flag I have to set or procedure I have to call to get the drawing to refresh?
Image1.png (257.4 KB)
Edit: I also tried adding a shape.RefreshShape() as per Refresh shapes data|Documentation and this move the center point of the line but did not update the geometry. See Image 2.
Image 2.png (17.9 KB)