Prod.: Engine, ver.: 6019, ID: 60001307, Wish : Opening large DWG file throws OutOfMemory exception

Wish : Opening large DWG file throws OutOfMemory exception

Article60001307
TypeWish
ProductEngine
Version6019
Date Added2/4/2011
FixedYes [2/7/2011]
Submitted byGeovani Miranda
Keywords

Subject

Opening large DWG file throws OutOfMemory exception

Summary

Opening large DWG file throws OutOfMemory exception

Solution

In version 6020 a new property ImportDWGFlags of vdFileProperties was added.

It gets one or more of the following values :

Enum  value Description
None 0 Default value. with no flags for normal import.
IgnoreUnusedBlocks 1 Open drawing without importing unused vdBlock objects for lower memory consumption.
IgnoreXProperties 2 Open drawing without importing any
IgnoreAll 3 Open drawing without importing unused blocks and all Xproperties
ConvertToDxf 4 Converts the dwg to a temporary dxf file and open the dxf file
ConvertToDxf_IgnoreUnusedBlocks 5 Both of ConvertToDxf and IgnoreUnusedBlocks are used.
ConvertToDxf_IgnoreAll 7 Both of ConvertToDxf and IgnoreAll are used.
AnalyzePolylineCurves 8 Convert imported polylines with spline data to simple polylines by analyzing spline curves to points.

The default value for vdFileProperties.DWGFlags  is AnalyzePolylineCurves

Example in C#:
    vdDocument.FileProperties.ImportDWGFlags  = 
DWGImportFlags.IgnoreAll;
   
vdDocument.Open("someDrawing.dwg");



In Delphi the code you need in order to open big DWG drawings using the ImportDWGFlags property is :
procedure TForm1.Button1Click(Sender: TObject);
var  
     doc : VectorDraw_Professional_TLB.IvdDocument; // you need this reference
     flag : boolean;
begin
  vdraw1.DisableMouseStockEvents:=true;
  vdraw1.DisplayFrames:=63;
  vdraw1.StatusBarMenu:=true;
  vdraw1.StatusBar:=true;
  vdraw1.StatusBarPaper:=true;
  vdraw1.EnableAutoGripOn:=true;
  doc := vdraw1.ActiveDocument.WrapperObject as VectorDraw_Professional_TLB.IvdDocument;
  // or  doc.FileProperties.ImportDWGFlags:= 3;
  doc.FileProperties.ImportDWGFlags:= DWGImportFlags.DWGImportFlags_ConvertToDxf_IgnoreUnusedBlocks;
  flag:=vdraw1.activedocument.Open('',0,0);  
end;