70002203 How to get the entities of a vdInsert before exploding it

Article 70002203
Type HowTo
Product Engine
Version 9
Date Added 5/4/2022 12:00:00 AM
Fixed 10.1001.0.2 (5/4/2022 12:00:00 AM)
Submitted by JK

Summary

How to get the entities of a vdInsert before exploding it

Solution

Try a code like:

// in a Delphi form, add a button and a vdraw.ocx ActiveX component
procedure TForm1.Button1Click(Sender: TObject);
  Type TFigure_Array = array of VDrawi5_tlb.vdFigure; // define a type that is array of vdFigures
var
  vdins : VdrawI5_TLB.vdInsert;
  comp : VdrawI5_TLB.vdFigure;
  i:integer;
  d:integer;
  aExpl: TFigure_Array;
  str : String; // to display the results
begin
  // test.vdcl is a simple small drawing with 5-6 objects like lines and circles etc.
  // insert it as a vdBlock/vdInsert in an empty document
  vdins := vdraw1.ActiveDocument.Entities.InsertBlock(VarArrayOf([0,0,0]),'c:\test\test.vdcl',1,1,0); 
  aExpl:= vdins.Explode(false);
  
  d:=0; str :=' ';
  for i := VarArrayLowBound(aExpl, 1) to VarArrayHighBound(aExpl, 1) do
    begin
        d:=d+1;
        comp:= aExpl[i]; 
        str:=str+ comp.Handle +', ' ;
    end;
  button1.Caption := inttostr(d)+ ' vdfigures with handles: ' + str;
end;

Send comments on this topic.