BoundingBox
Moderators: SDS, support, admin
BoundingBox
Hi,
i've the following Problem: I need the bounding-box (TFRect) from a dxf-image.
I designed an Interface, which provide me i way to access several dxf-images implemetations. In your documentation there are 4 different properties and methods to get such a boubding-box.
For Example:
* TsgDXFImage.CurrentLayout.Box
* TsgDXFImage.Extents
* TsgDXFImage.DrawingBox
* TsgDXFImage.PureExtents
I've testet all these ways to get these box, but often the results are all 0. What must be done to get the exact bouzunding-box?
~ Joe
i've the following Problem: I need the bounding-box (TFRect) from a dxf-image.
I designed an Interface, which provide me i way to access several dxf-images implemetations. In your documentation there are 4 different properties and methods to get such a boubding-box.
For Example:
* TsgDXFImage.CurrentLayout.Box
* TsgDXFImage.Extents
* TsgDXFImage.DrawingBox
* TsgDXFImage.PureExtents
I've testet all these ways to get these box, but often the results are all 0. What must be done to get the exact bouzunding-box?
~ Joe
Hello Joe,
<ol type="1"> <li> The following calls return the same results:
We recommend to use <b>TsgDXFImage.CurrentLayout.Box;</b></li>
<li><blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">I've testet all these ways to get these box, but often the results are all 0. What must be done to get the exact bouzunding-box?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Please, give us example of your code.
</li> </ol id="1">
Sergey.
please post questions to the forum or write to support@cadsofttools.com
<ol type="1"> <li> The following calls return the same results:
Code: Select all
<ol type="a"> <li>TsgDXFImage.CurrentLayout.Box;</li>
<li>TsgDXFImage.IsWithoutBorder := true;
TsgDXFImage.CurrentLayout.Box;</li>
<li>TsgDXFImage.PureExtents;</li> </ol id="a">
<li><blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">I've testet all these ways to get these box, but often the results are all 0. What must be done to get the exact bouzunding-box?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Please, give us example of your code.
</li> </ol id="1">
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Hi Sergey, thanks for your quick reply.
Here an example:
Sometimes <b>cad.CurrentLayout.Box</b> provide a box with (L: 1e+20, T: -1e+20, R: -1e+20, B: 1e+20) or <b>cad.Extents</b> a box with (L: 0, T: 0, R: 0, B: 0);
What is GetExtents and TsgDXFImage.Extents for?
~Joe
Here an example:
Code: Select all
procedure dosomething;
var
cad: TsgDXFImage;
src: TFRect;
begin
//Interface to provide dwg, dxf, ... -images
cad := TsgDXFImage(Loader.GetImage);
while (cad.IsLoading and (not Assigned(cad)))do
sleep(10);
{BoundingBox}
if (Assigned(cad)) then
begin
cad.GetExtents;
if (Assigned(cad.CurrentLayout)) then
src := cad.CurrentLayout.Box
else
src := cad.Extents;
end;
//do something with bounding box
end;
What is GetExtents and TsgDXFImage.Extents for?
~Joe
Hello Joe,
The following code works:
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">What is GetExtents and TsgDXFImage.Extents for?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
<h4>TsgDXFImage.GetExtents</h4>
<b>procedure</b> GetExtents;
<b>Description</b>
Calculates extents for all LAYOUTs and sets the model as current LAYOUT.
<h4>TsgDXFImage.Extents</h4>
<b>property</b> Extents: TFRect
<b>Description</b>
Defines drawing's extents. Returned TFRect is calculated through all entities' coordinates.
Sergey.
please post questions to the forum or write to support@cadsofttools.com
The following code works:
Code: Select all
<b>procedure</b> TForm1.Button2Click(Sender: TObject);
<b>var</b>
cad: TsgDXFImage;
src: TFRect;
<b>begin</b>
//Interface to provide dwg, dxf, ... -images
cad := TsgDXFImage.Create;
cad.LoadFromFile(<font color="blue">'c:\Test.dxf'</font id="blue">);
<b>while</b> (cad.IsLoading <b>and</b> (<b>not</b> Assigned(cad)))<b>do</b>
sleep(10);
{BoundingBox}
<b>if</b> (Assigned(cad.CurrentLayout)) <b>then</b>
src := cad.CurrentLayout.Box
<b>else</b>
src := cad.Extents;
cad.Free;
<b>end</b>;
<h4>TsgDXFImage.GetExtents</h4>
<b>procedure</b> GetExtents;
<b>Description</b>
Calculates extents for all LAYOUTs and sets the model as current LAYOUT.
<h4>TsgDXFImage.Extents</h4>
<b>property</b> Extents: TFRect
<b>Description</b>
Defines drawing's extents. Returned TFRect is calculated through all entities' coordinates.
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Hello Joe,
Here goes full text of the project that we have sent you. Project contains the only button and it does work:
This line returns rectangle with the size 100x100:
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Here goes full text of the project that we have sent you. Project contains the only button and it does work:
Code: Select all
<b>unit</b> Unit1;
<b>interface</b>
<b>uses</b>
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DXFImage, sgConsts, ExtCtrls, SGImage, StdCtrls;
<b>type</b>
TForm1 = <b>class</b>(TForm)
Button1: TButton;
<b>procedure</b> Button1Click(Sender: TObject);
<b>private</b>
{ Private declarations }
<b>public</b>
{ Public declarations }
<b>end</b>;
<b>var</b>
Form1: TForm1;
<b>implementation</b>
{$R *.dfm}
<b>procedure</b> TForm1.Button1Click(Sender: TObject);
<b>var</b>
cad: TsgDXFImage;
src: TFRect;
<b>begin</b>
cad := TsgDXFImage.Create;
cad.LoadFromFile('Rect.dxf');
<b>while</b> (cad.IsLoading <b>and</b> (<b>not</b> Assigned(cad)))<b>do</b>
sleep(10);
<b>if</b> (Assigned(cad.CurrentLayout)) <b>then</b>
src := cad.CurrentLayout.Box
<b>else</b>
src := cad.Extents;
cad.Free;
<b>end</b>;
<b>end</b>.
Code: Select all
src := cad.CurrentLayout.Box
please post questions to the forum or write to support@cadsofttools.com