Copy TsgCADImage to metafile

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

Moderators: SDS, support, admin

Post Reply
edbored
Posts: 20
Joined: 26 Jul 2005, 00:15
Location: Canada

Copy TsgCADImage to metafile

Post by edbored » 27 Apr 2015, 09:55

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:

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;
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:

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!

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

Re: Copy TsgCADImage to metafile

Post by support » 27 Apr 2015, 21:35

Hello Ed,

The following line in your workaround code is not correct:

Code: Select all

vDWG := TsgCADImage.Create ; // vDWG is type TsgCADImage
TsgCADImage is a base class for all CAD formats, so you should create an instance of TsgCADImage descendant depending on a file format:

Code: Select all

var
  Img: TsgCADImage;
...

Img := TsgCADdxfImage.Create;   // for DXF files
Img := TsgDWGImage.Create;      // for DWG files
Img := TsgHPGLImage.Create      // for PLT files
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
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

edbored
Posts: 20
Joined: 26 Jul 2005, 00:15
Location: Canada

Re: Copy TsgCADImage to metafile

Post by edbored » 27 Apr 2015, 23:13

<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

Post Reply