sgruth
July 15, 2025, 12:29pm
1
Hello,
i have the problem that the style properties of a shape are sometimes null.
You can reproduce it with the following code:
Diagram diagram = new Diagram();
var page = diagram.Pages[0];
long recShapeId = page.DrawRectangle(5, 5, 10, 10);
Aspose.Diagram.Shape drawedShape = page.Shapes.GetShape(recShapeId);
var lineStyleOfOwnShape = drawedShape.LineStyle; // not null
long recShapeId2 = page.DrawRectangle(37.5, 270, 47, 265.1);
Aspose.Diagram.Shape drawedShape2 = page.Shapes.GetShape(recShapeId2);
var lineStypeOfOwnShape2 = drawedShape2.LineStyle; // is null
As far as I have tested it, the following properties are null for the second shape:
FillStyle
LineStyle
TextStyle
Why are the style properites null at shape 2? And why does it work at shape 1?
Regards
Steve
@sgruth
Thanks for the sample code.
I have tested your scenario/case using our latest version : Aspose.Diagram for .net v25.7 . It works fine and as expected.
All stylesheet properties of shape 2 are set to default with Id “0”.
Please try our latest version Aspose.Diagram for .Net v25.7.
Thanks.
sgruth
July 16, 2025, 7:18am
3
Thanks for your reply.
I have updated to the current Aspose version 25.7. But the problem is the same.
However, I have noticed that I have forgotten a line in my example code.
Please try the following to reproduce the Problem.
long recShapeId = page.DrawRectangle(5, 5, 10, 10);
Aspose.Diagram.Shape drawedShape = page.Shapes.GetShape(recShapeId);
var lineStyleOfOwnShape = drawedShape.LineStyle; // not null
drawedShape.LineStyle.NameU = "Normal";
long recShapeId2 = page.DrawRectangle(37.5, 270, 47, 265.1);
Aspose.Diagram.Shape drawedShape2 = page.Shapes.GetShape(recShapeId2);
var lineStypeOfOwnShape2 = drawedShape2.LineStyle; // is null
The key line is:
drawedShape.LineStyle.NameU = "Normal";
If i set LineStyle.NameU at the first shape object then is the LineStyle property of the second shape object null.
How can this behaviour be explained?
@sgruth
We added this line of code, but the program still runs fine.
Please check the generated file—both shapes’ styles remain at their default values with Id “0”.
out.zip (6.2 KB)
Type='Shape' LineStyle='0' FillStyle='0' TextStyle='0'
Could you please share the output file ?We will check it soon.
diagram.Save("out.vsdx", SaveFileFormat.Vsdx);
Thanks.
sgruth
July 17, 2025, 7:21am
5
After Windows tried to install an update and I had to restart the computer, I can no longer reproduce the phenomenon.
it’s very strange.
Thanks for your help.
@sgruth
It’s good to know that your issue is sorted out now.
In case you have further inquiries or may need any help in future, please let us know by posting a new thread in Aspose.Diagram’ forum.