Page 1 of 1
Rotate to minimum rectangle
Posted: 08 Jul 2022, 07:13
by shantisoftware
Has anyone got an algorithm to rotate a CadImage to minimum rectangle.
I have a simple one that is working for most drawings, where I just use CadImage.Rotate about z axis, and iterate through 360 degrees to find the angle with the smallest rectangle via PureExtents.
I came across some examples where the results of cadImage.PureExtents give weird results as I rotate. I can't see why.
Re: Rotate to minimum rectangle
Posted: 08 Jul 2022, 10:34
by support
shantisoftware wrote: ↑08 Jul 2022, 07:13
Has anyone got an algorithm to rotate a CadImage to minimum rectangle.
I have a simple one that is working for most drawings, where I just use CadImage.Rotate about z axis, and iterate through 360 degrees to find the angle with the smallest rectangle via PureExtents.
I came across some examples where the results of cadImage.PureExtents give weird results as I rotate. I can't see why.
Hi,
We have a
Viewer demo, that illustrates how the
Rotate function works. Most likely, you should recalculate the extents after you rotate the CADImage:
Code: Select all
this.cadImage.Rotate(Axes.Z, angle);
this.cadImage.GetExtents();
Also, if you want to get pure extents without margins, you should check the
IsWithoutMargins property of CADImage.
Catherine.
Re: Rotate to minimum rectangle
Posted: 01 Feb 2023, 10:45
by shantisoftware
Hi Catherine
From what I can see that method doesn't actually rotate the co-ordinates of the points, as when I load the saved file into another CAD program nothing has changed.
I've used the other sample with RotatePolyLine, RotateText, etc, to work through each entity and rotate it about a common centre point.
Am I missing something?
Re: Rotate to minimum rectangle
Posted: 03 Feb 2023, 12:05
by support
shantisoftware wrote: ↑01 Feb 2023, 10:45
Hi Catherine
From what I can see that method doesn't actually rotate the co-ordinates of the points, as when I load the saved file into another CAD program nothing has changed.
I've used the other sample with RotatePolyLine, RotateText, etc, to work through each entity and rotate it about a common centre point.
Am I missing something?
Hi,
well, the
cadImage.Rotate function should be working correctly.
Here is a code example of the Rotate function usage:
Code: Select all
string pathdxffile = @"d://Test.dxf";
string pathoutdxffile = @"d://Test30.dxf";
this.cadImage = CADImage.CreateImageByExtension(pathdxffile);
cadImage.LoadFromFile(pathdxffile);
cadImage.Rotate(Axes.Z, 30);
var vExp = new CADImport.Export.DirectCADtoDXF.CADtoDXF(cadImage);
vExp.Version = DWGVersion.ACR2004;//or choose ACR2000
vExp.SaveToFile(pathoutdxffile);
If something goes wrong, please, send us your code snippet and file example.
Catherine.