Determining Viewport of imported DXF

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
dwilbourn
Posts: 6
Joined: 04 Sep 2006, 21:00
Location: Netherlands

Determining Viewport of imported DXF

Post by dwilbourn » 04 Sep 2006, 21:06

I am evaluating the CADImport functions prior to purchase and wanted to modify the SimpleImport demo to return the ViewPort size and position. I tried adding a simple procedure based on the other ImportXXX procedures but it seems that the TsgDXFViewport is not covered by the Iterate function.

Can someone tell me what I need to do?

Thanks,
David.

dwilbourn
Posts: 6
Joined: 04 Sep 2006, 21:00
Location: Netherlands

Post by dwilbourn » 05 Sep 2006, 00:55

Figured it out! TsgDXFImage.extents :-)

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 05 Sep 2006, 16:12

Hello,

Entity <b>VIEWPORT</b> (<b>TsgDXFViewport</b> in <b>CADImportVCL</b> terms) is located in the <b>PaperSpace</b> in every correct <b>AutoCAD</b> drawing.
<br /><b>SimpleImport</b> iterates through entities in the <b>ModelSpace</b>. The following code allows to get <b>VIEWPORT</b> if current layout is not <b>Model</b> (TsgDXFImage.CurrentLayout<>TsgDXFImage.Layouts[0]).

Code: Select all

<b>procedure</b> TForm1.ReadCADEntities(Entity: TsgDXFEntity);
...
  <b>if</b> Entity <b>is</b> TsgDXFViewPort <b>then
  begin</b>
    ImportViewPort(Entity);
    Exit;
  <b>end</b>;
...

<b>procedure</b> TForm1.Button1Click(Sender: TObject);
...
        //TsgDXFImage(Image1.Picture.Graphic).Converter.Iterate(ReadCADEntities, FCADParams);
        TsgDXFImage(Image1.Picture.Graphic).Converter.Params := @FCADParams;
        TsgDXFImage(Image1.Picture.Graphic).CurrentLayout.Iterate(TsgDXFImage(Image1.Picture.Graphic).Converter, ReadCADEntities);
...

<b>procedure</b> TForm1.ImportViewPort(Sender: TObject);
<b>var</b>
  V: TsgDXFViewPort absolute Sender;
<b>begin</b>
  MessageBox(Application.Handle, PChar('Box'
    + #13#10'   Left= ' + FloatToStr(V.Rect.Left)
    + #13#10'   Top= ' + FloatToStr(V.Rect.Top)
    + #13#10'   Z1= ' + FloatToStr(V.Rect.Z1)
    + #13#10'   Right= ' + FloatToStr(V.Rect.Right)
    + #13#10'   Bottom= ' + FloatToStr(V.Rect.Bottom)
    + #13#10'   Z2= ' + FloatToStr(V.Rect.Z2)), 'VIEWPORT', MB_OK);
<b>end</b>;
Sergey.

please post questions to the forum or write to support@cadsofttools.com

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 06 Sep 2006, 16:44

Hello!

Updated version of SimpleImport is available in the ..\CADImportVCL_site_beta_010906\Delphi\Demos\SimpleImport\.. folder of the CADImportVCL beta package (avalable on: http://www.cadsofttools.com/download/CA ... 010906.zip)

Sergey.

please post questions to the forum or write to support@cadsofttools.com

Post Reply