blank dxf file
Posted: 27 Oct 2006, 17:18
Hi Sergey.
I've made some progress from my last problem. I found I had to export to a temporary dxf file, then import it back in. Is there a better way?
I have the following 2 issues now:
1. The blank dxf isn't actually blank, so I'd like to get rid of the rectangle without losing the aspect ratio (which matches the original bitmap selected by the user).
2. In order to export a dxf I needed to download
http://www.cadsofttools.com/download/dxfexportvcl.zip
which now has the demo messagebox when accessed. Does my purchase of cadimportvcl (with source) qualify for registration of this export component as well?
thanks,
Steve
current code snippet:
I've made some progress from my last problem. I found I had to export to a temporary dxf file, then import it back in. Is there a better way?
I have the following 2 issues now:
1. The blank dxf isn't actually blank, so I'd like to get rid of the rectangle without losing the aspect ratio (which matches the original bitmap selected by the user).
2. In order to export a dxf I needed to download
http://www.cadsofttools.com/download/dxfexportvcl.zip
which now has the demo messagebox when accessed. Does my purchase of cadimportvcl (with source) qualify for registration of this export component as well?
thanks,
Steve
current code snippet:
Code: Select all
...
if ext = '.bmp' then begin
BMOverlay.LoadFromFile(sFileName); // bitmap overlay
// create a dummy blank dxf image so we have something to draw on and create measurements
vImg := TsgDXFImage.Create;
try
vImg.IsWithoutBorder := True;
// draw a rectangle the same size as the bitmap overlay to get the aspect ration correct
vLine1 := TsgDXFLine.Create;
vLine1.Point := MakeFPoint(0,0,0);
vLine1.Point1 := MakeFPoint(0,BMOverlay.Height,0);
vImg.Converter.Sections[csEntities].AddEntity(vLine1);
vLine2 := TsgDXFLine.Create;
vLine2.Point := MakeFPoint(0,BMOverlay.Height,0);
vLine2.Point1 := MakeFPoint(BMOverlay.Width,BMOverlay.Height,0);
vImg.Converter.Sections[csEntities].AddEntity(vLine2);
vLine3 := TsgDXFLine.Create;
vLine3.Point := MakeFPoint(BMOverlay.Width,BMOverlay.Height,0);
vLine3.Point1 := MakeFPoint(BMOverlay.Width,0,0);
vImg.Converter.Sections[csEntities].AddEntity(vLine3);
vLine4 := TsgDXFLine.Create;
vLine4.Point := MakeFPoint(BMOverlay.Width,0,0);
vLine4.Point1 := MakeFPoint(0,0,0);
vImg.Converter.Sections[csEntities].AddEntity(vLine4);
if Assigned(vImg.Converter.OnCreate) then begin
vImg.Converter.OnCreate(vLine1);
vImg.Converter.OnCreate(vLine2);
vImg.Converter.OnCreate(vLine3);
vImg.Converter.OnCreate(vLine4);
end;
vImg.Converter.Loads(vLine1);
vImg.Converter.Loads(vLine2);
vImg.Converter.Loads(vLine3);
vImg.Converter.Loads(vLine4);
vImg.CurrentLayout := vImg.Layouts[0];
vImg.DrawingBox := MakeFRect(0,BMOverlay.Height,0, BMOverlay.Width,0,0);
vImg.GetExtents;
// export to a temporary dxf file
tempFile := ExtractFilePath(Application.ExeName)+'temp.dxf';
E := TsgDXFExport.Create;
try
E.IsParseWhite := True;
vMet := vImg.ExportToMetafile(vOffX, vOffY, vUSize);
DXFExport.OffsetX := vOffX;
DXFExport.OffsetY := vOffY;
E.UnitSize := vUSize;
E.LoadFromMetafile(vMet);
vMet.Free;
E.SaveToFile(tempFile);
finally
E.Free;
end;
// read it back in. sgPaintBox.OnPaint overlays the bitmap
// I would like to get rid of the visible rectangle somehow
sgPaintBox.LoadFromFile(tempFile); // dummy frame
IsBitMap := true;
finally
vImg.Free;
end;
end else begin
// standard dxf or dwg files - no bitmap overlay required
sgPaintBox.LoadFromFile(sFileName);
IsBitMap := false;
end;
Img := TsgDXFImage(sgPaintBox.Picture.Graphic);
...