Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Using AutoCAD files with RB

edited July 2005 in General
Having spend a longish amount of time on this, I thought I'd document
this for the group...

I'm using a library called CADImportVCL from www.cadsofttools.com to
process DWG, DXF, and even HPGL, EMF etc files.

To print drawings with RB - say as a full page drawing in a header, do
the following:

1) create a new registration unit

unit ppCustomDXF;
interface
{$I ppIfDef.pas}
uses ppCtrls,
DXFImage; // from CADImportVCL
implementation
initialization
ppRegisterGraphicClass('DXF', TsgDXFImage);
ppRegisterGraphicClass('DWG', TsgDXFImage);
finalization
ppUnRegisterGraphicClass(TsgDXFImage);
end.

2) include new registration unit and Cad soft units in report form
uses
...
DWG, DXFImage, ppCustomDXF,
...;

3) set your header band to the printable size of page (eg if landscape
for 8.5x11 sheet then set for 10.5 wide x 8.0 high)

4) drop a ppImage on the header band, set position to top=0, left=0,
width=10.5, height=8.0

Set ppImage properties as:
Autosize=false
DirectDraw=TRUE
MaintainAspectRatio=true
Stretch=true

5) in the header band onBeforePrint event set:
procedure TForm1.ppHeaderBand1BeforePrint( Sender: TObject);
var
fName: string;
begin
fName:= GetDrawingFileNameSomehowOrOtherThatsYourProblem; //
ppImage1.Picture.LoadFromFile(fName);
TsgDXFImage(ppImage1.Picture.Graphic).BackgroundColor:=clWhite;
TsgDXFImage(ppImage1.Picture.Graphic).IsWithoutBorder:=true;
// UseWinEllipse sometimes gives smoother arcs
TsgDXFImage(ppImage1.Picture.Graphic).UseWinEllipse:=true;
// set minium line width for "null width lines"
TsgDXFImage(ppImage1.Picture.Graphic).NullWidth:=1;
// set drawing mode - dmNormal=colour, dmGray=GrayScale, dmBlack= B/W
TsgDXFImage(ppImage1.Picture.Graphic).DrawMode:=dmGray;
TsgDXFImage(ppImage1.Picture.Graphic).GetExtents;
end;

Note that if you use Waler TExtraDevices, you'll have to set the PDF
PixelsPerInch around 150 to get nice clean printing PDF, and make sure
PDF ScaleImages = true.


Cheers,
EdB

Comments

This discussion has been closed.