Page 1 of 1

Adding Polyline Void (Dcal for Delphi)

PostPosted: Mon Jul 31, 2017 6:55 pm
by dhs
Hi again. Yet another exception that I cannot explain:

I am trying to add a void to a polyline, but the drawing keeps crashing out with an exception class $C0000005 with message 'access violation at 0x0091c3e5: write of address 0x00000006'.
Once again I have written a little test program (below), and the exception is happening on the plvoid_add (a few lines from the bottom of the main function). Once again I cannot see any problem with my code (I have similar code that adds voids to polygons/slabs without any issue). Hopefully somebody can spot my error.

Code: Select alllibrary Tests;

uses
  System.sysutils,
  //DCAL for Delphi Header Files
  UConstants in '../../Header Files/UConstants.pas',
  UInterfaces in '../../Header Files/UInterfaces.pas',
  UInterfacesRecords in '../../Header Files/UInterfacesRecords.pas',
  URecords in '../../Header Files/URecords.pas',
  UVariables in '../../Header Files/UVariables.pas';

{$E dmx}  //dmx is the extension for DCAL Dll's
{$R *.res}



function Main(dcalstate : asint; act : action; pl, pargs : Pointer) : wantType; stdcall;

var
  ent, vent : entity;
  pv  : polyvert;
  i   : integer;

begin
  ent_init (ent, entpln);
  for i := 1 to 3 do begin
    polyvert_init (pv);
    pv.shape := pv_vert;
    pv.bulge := 0.0;
    pv.pnt.x := -400 + 200*i;
    if i = 2 then pv.pnt.y := 200 else pv.pnt.y := 0;
    pv.pnt.z := 0;
    polyvert_add (pv, ent.plnfrst, vent.plnlast);
  end;
  ent.plnhite := 1;
  ent.plbase := 0;
  ent.plnclose := true;
  ent.plnCover := true;
  ent_add (ent);
  ent_draw (ent, drmode_white);

  ent_init (vent, entpln);
  plvoid_init (ent, vent);
  for i := 1 to 3 do begin
    polyvert_init (pv);
    pv.shape := pv_vert;
    pv.bulge := 0.0;
    pv.pnt.x := -200 + 100*i;
    if i = 2 then pv.pnt.y  := 150 else pv.pnt.y := 50;
    pv.pnt.z := 0;
    polyvert_add (pv, vent.plnfrst, vent.plnlast);
  end;
  vent.plnclose := true;
  vent.plnhite := 1;
  vent.plbase := 0;
  if not plvoid_add(ent, vent) then wrterr ('Did not add void');
  ent_draw (ent, drmode_white);

  Result := XDone;
end;

exports
   Main;

begin

end.


Thanks,
David H.