Page 1 of 1

How to know if Xrefs are missing

Posted: 11 Jul 2006, 18:39
by fabzouni
Hi,

When I open a dwg file (with tsgimage), sometimes an Xref file is missing, and the displayed image is not complete.

I would like to know if one of the needed Xref file is missing.
Is there any property (of TsgDXFConverter maybe) that could help me to know witch files were not found.

Thanks

Fabzouni

Posted: 12 Jul 2006, 17:07
by support
Hello Fabzouni,

Current version does not allow to determine whether an Xref file or not.
However owners of CADImportVCL Soure Code can solve this problem:
<ul><li>Add the following property into TsgDXFBlock class:

Code: Select all

<b>property</b> XRef: TsgDXFXref <b>read</b> FXref;
</li>
<li>Use the following code (based on Viewer demo - folder ..\cadimportvcl\Delphi\Demos\Viewer\..):
{ Missing Xrefs list. }

Code: Select all

<b>procedure</b> TForm1.Button1Click(Sender: TObject);
<b>var</b>
  vImg: TsgDXFImage;
  vBlock: TsgDXFBlock;
  vMissingXRefs: TStringList;
  I: Integer;
<b>begin
  if not</b> (sgPaintBox.Picture.Graphic <b>is</b> TsgDXFImage) <b>then</b>
    Exit;
  vImg := TsgDXFImage(sgPaintBox.Picture.Graphic);
  vMissingXRefs := TStringList.Create;
  <b>for</b> I := 0 <b>to</b> vImg.Converter.Counts[csBlocks]-1 <b>do
  begin</b>
    vBlock := TsgDXFBlock(vImg.Converter.Sections[csBlocks].Entities[I]);
    <b>if</b> (vBlock.Xref = <b>nil</b>) <b>and</b> (((vBlock.Flags <b>and</b> 36 > 0) <b>or</b> (vBlock.Flags <b>and</b> 4 > 0))
      <b>and</b> (vBlock.XrefPath <> '')) <b>then</b>
      vMissingXRefs.Add(IntToStr(vMissingXRefs.Count+1)+'. "'+vBlock.XrefPath+'"');
  <b>end</b>;
  MessageBox(0, PChar(vMissingXRefs.Text), PChar('Not found Xrefs'), MB_OK <b>or</b> MB_ICONWARNING);
  vMissingXRefs.Free;
<b>end</b>;
</li></ul>
Sergey.

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

Posted: 12 Jul 2006, 17:48
by fabzouni
Hello,

This works very well.
Another question do you plan to add the TsgDXFBlock Xref property into your code ?

It would be great to have a property (of TsgDXFConverter) that gives the list of missing Xref without needing to check all blocks.

Thanks

Fabzouni

Posted: 12 Jul 2006, 18:33
by support
Hello,

<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">This works very well.
Another question do you plan to add the TsgDXFBlock Xref property into your code ?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
This property will be available in the next version of CADImportVCL.
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">It would be great to have a property (of TsgDXFConverter) that gives the list of missing Xref without needing to check all blocks.<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
We'll consider how it can be done and inform you about the results.

Sergey.

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