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.
Rotate to minimum rectangle
Moderators: SDS, support, admin
Re: Rotate to minimum rectangle
Hi,shantisoftware wrote: ↑08 Jul 2022, 07:13Has 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.
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();
Catherine.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 6
- Joined: 15 Jul 2015, 14:03
Re: Rotate to minimum rectangle
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?
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
Hi,shantisoftware wrote: ↑01 Feb 2023, 10:45Hi 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?
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);
Catherine.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support