But this code example is legacy (property OffsetX or OffsetY don’t exist).
// Get pinx and piny
double pinx = m.OffsetX;
double piny = m.OffsetY;
For example we have two files. Different between them is that in second file shapes are grouped, so, has another coordinates.
First file, first shape has (non grouped):
PinX: 4.1732283464566926
PinY: 8.1692913385826742
Second file, first shape (grouped):
PinX: 1.1811023622047243
PinY: 2.8543307086614149
I need that PinX of grouped shape would be 4.1732283464566926 instead of 1.1811023622047243 and 8.1692913385826742 instead of 2.8543307086614149. Can you share working sample code how I can do this? Test1.zip (39.6 KB)
Would you please make sure to try using Aspose.Diagram for .NET 19.2 as the code is working with it. Furthermore, we have tested the scenario in our environment using latest version and were unable to retrieve desired PinX and PinY values. We used following code snippet for both Parent and Sub-Shapes:
// Load Visio diagram
Aspose.Diagram.Diagram diagram = new Aspose.Diagram.Diagram(dataDir + "second.vsd");
// Get a group shape by ID and page index is 0
Aspose.Diagram.Shape shape = diagram.Pages[0].Shapes.GetShape(6);
Aspose.Diagram.Shape subShape1 = shape.Shapes.GetShape(4);
Aspose.Diagram.Shape subShape2 = shape.Shapes.GetShape(5);
///
// Tried below code snippet with both subShape1 and subShape2
///
System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix();
// Apply the translation vector
m.Translate(-(float)shape.XForm.LocPinX.Value, -(float)shape.XForm.LocPinY.Value);
// Set the elements of that matrix to a rotation
m.Rotate((float)shape.XForm.Angle.Value);
// Apply the translation vector
m.Translate((float)shape.XForm.PinX.Value, (float)shape.XForm.PinY.Value);
// Get pinx and piny
double pinx = m.OffsetX;
double piny = m.OffsetY;
// Calculate the sub-shape pinx and piny
double resultx = shape.XForm.PinX.Value - shape.XForm.LocPinX.Value - pinx;
double resulty = shape.XForm.PinY.Value - shape.XForm.LocPinY.Value - piny;
//Console.WriteLine(string.Format("pinx={0}, piny={0}", pinx.ToString(), piny.ToString()));
Nevertheless, we have logged an investigation ticket as DIAGRAMNET-51622 in our issue tracking system for further investigation of the scenario. We will surely let you know as soon as some definite updates are available regarding ticket resolution. Please spare us little time.
First problem was that in code example you are not type full namespace of Matrix object (System.Drawing.Drawing2D.Matrix), so i thought that is Aspose.CAD.Matrix.
Second, this code gets wrong coordinates (at least, in my case it’s wrong). My task - draw rectange with coordinates of shape. Rectangle coordinates I get by next code:
So, by this code I can calculate right shape coordinates, and draw rectangle on page image representation. But this code working only for ungrouped shapes. If using coordinates of shape inside grouped shape, then results wrong.
Suggest I have 2 documents, and want compare them, and if they some different, draw rectangle in that changed area. Test1.zip (42.2 KB)
Of course, I’m multiplicate Width and Height on 0.95F, so, blue rectangle some smaller, otherwise rectangle would be precisely drawing over shape black rectangle lines.
You can test this on your side. Just convert vsd page to image, and then draw rectangle with coordinates using code above.
Yes, your understanding are correct. The coordinates would be according to parent shape and you need to use them in order to determine sub shape coordinates. In case you face any issue, please share your sample Diagram file with us. We will test the scenario in our environment and address it accordingly.