Copy TsgCADImage to metafile
Moderators: SDS, support, admin
Copy TsgCADImage to metafile
I'm trying to overcome a problem in using CADImportVCL with Report Builder.
The problem (in v 6.1 and v9.1) is that loading a .DWG into a Report Builder ppImage causes any text to be rendered incorrectly on the report canvas.
In 6.1, DXFs did not affect text renders correctly.
In 9.1, anything descended from TCADImage causes text to be incorrectly placed on the canvas.
My workaround in 6.1 for DWG images was to load the drawing into a temporary TsgDWGImage, convert this to metafile, then assign the metafile to the ppImage:
When I try this in v9.1, the drawings are not rendered at all (appear to be blank, not 'nil').
That is, the following (almost exactly the same code) does not work in v9.1:
I've tried with sgConsts.KeepOriginal:=true; - no difference in behaviour.
Given that the problem with rendering text has been around for awhile, I'm thinking it will be quicker to figure out how to fix the workaround.
Can someone suggest how I might be able to get the above working?
Thanks!
The problem (in v 6.1 and v9.1) is that loading a .DWG into a Report Builder ppImage causes any text to be rendered incorrectly on the report canvas.
In 6.1, DXFs did not affect text renders correctly.
In 9.1, anything descended from TCADImage causes text to be incorrectly placed on the canvas.
My workaround in 6.1 for DWG images was to load the drawing into a temporary TsgDWGImage, convert this to metafile, then assign the metafile to the ppImage:
Code: Select all
vDWG := TsgDWGImage.Create ; // vDWG is type TsgDWGImage
try
vDWG.LoadFromFile(fName);
vDWG.IsWithoutBorder:=True;
vDWG.BackgroundColor:=clWhite;
vDWG.DefaultColor:=clBlack;
vDWG.UseWinEllipse:=True;
vDWG.DrawMode:= dmBlack;
vDWG.NullWidth:=0;
vDWG.IsShowLineWeight:=True;
vDWG.LineScaled:=true;
vDWG.GetExtents;
mf := vDWG.ExportToMetafile(3276700);
ppImage1.Picture.Metafile:= mf;
finally
mf.Free;
vDWG.Free;
end;
That is, the following (almost exactly the same code) does not work in v9.1:
Code: Select all
vDWG := TsgCADImage.Create ; // vDWG is type TsgCADImage - the only change...
try
vDWG.LoadFromFile(fName);
vDWG.IsWithoutBorder:=True;
vDWG.BackgroundColor:=clWhite;
vDWG.DefaultColor:=clBlack;
vDWG.UseWinEllipse:=True;
vDWG.DrawMode:=dmBlack;
vDWG.NullWidth:=0;
vDWG.IsShowLineWeight:=True;
vDWG.LineScaled:=true;
vDWG.GetExtents;
mf := vDWG.ExportToMetafile(3276700);
ppImage1.Picture.Metafile:= mf;
finally
mf.Free;
vDWG.Free;
end;
I've tried with sgConsts.KeepOriginal:=true; - no difference in behaviour.
Given that the problem with rendering text has been around for awhile, I'm thinking it will be quicker to figure out how to fix the workaround.
Can someone suggest how I might be able to get the above working?
Thanks!
Re: Copy TsgCADImage to metafile
Hello Ed,
The following line in your workaround code is not correct:
TsgCADImage is a base class for all CAD formats, so you should create an instance of TsgCADImage descendant depending on a file format:
Could you specify the exact Report Builder version you are using (e.g. Enterprise 16.02 for Delphi 7)? We will test the text rendering problem with a corresponding Report Builder trial.
Mikhail
The following line in your workaround code is not correct:
Code: Select all
vDWG := TsgCADImage.Create ; // vDWG is type TsgCADImage
Code: Select all
var
Img: TsgCADImage;
...
Img := TsgCADdxfImage.Create; // for DXF files
Img := TsgDWGImage.Create; // for DWG files
Img := TsgHPGLImage.Create // for PLT files
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Copy TsgCADImage to metafile
<thud>
<thud>
<thud>
(That's me banging my head on my desk - I have almost EXACTLY the same notes to myself about using descendents in my notes... <sigh>)
Thanks. I'm a little red-faced - code converting to metafiles is working just fine now.
I'm currently testing with D7 Enterprise (but I have RadStudio XE6/XE7 enterprise installed as well).
I have RB16.0 build 337 Enterprise, but also received link to latest version.
I'll do the RB upgrade and retest with RB16.02 Enterprise, then report results here.
I can even convert my test project to either XE6, XE7 (or both) if you like. (I can't convert the final projects to XE(n) - about 600k lines of code in each of two projects - too much retesting for unicode changes!)
I can send the test project to you, but I have to strip out some third-party stuff first (do you want it?).
Also - I've been working with "Nico' at Digital Metaphors about what I could do in Report Builder - I can send private email to both of you (via your 'support@' account) if you think that will expedite things.
Thanks, Mikhail - I greatly appreciate the support with the product.
Even when it makes me look like an idiot.
EdB
<thud>
<thud>
(That's me banging my head on my desk - I have almost EXACTLY the same notes to myself about using descendents in my notes... <sigh>)
Thanks. I'm a little red-faced - code converting to metafiles is working just fine now.
I'm currently testing with D7 Enterprise (but I have RadStudio XE6/XE7 enterprise installed as well).
I have RB16.0 build 337 Enterprise, but also received link to latest version.
I'll do the RB upgrade and retest with RB16.02 Enterprise, then report results here.
I can even convert my test project to either XE6, XE7 (or both) if you like. (I can't convert the final projects to XE(n) - about 600k lines of code in each of two projects - too much retesting for unicode changes!)
I can send the test project to you, but I have to strip out some third-party stuff first (do you want it?).
Also - I've been working with "Nico' at Digital Metaphors about what I could do in Report Builder - I can send private email to both of you (via your 'support@' account) if you think that will expedite things.
Thanks, Mikhail - I greatly appreciate the support with the product.
Even when it makes me look like an idiot.

EdB