I am having trouble with the sym_write function in D4D (the classic DCAL version seems to work fine). The symbol file is created, but does not appear to contain any entities. Came across this in a project I am working on so wrote a test macro which has the same symptoms.
The test macro adds and draws a circle (which works as expected), and then tries to create a symbol with the circle entity (and any other entities in the same group although there should not be any others ... I tried mode_ents with just the single entity with the same result). The symbol file is created in the macro folder and the circle shows in the preview when selecting the symbol to insert. If I insert the symbol unexploded I get the insertion point showing but not the circle (pressing '<' says symbol has been undone and removes the insertion point). Inserting it exploded does not appear to add anything to the drawing (pressing '<' undoes the line I added before inserting the symbol).
Code of y test macro is below and compiled version is attached. Any advice would be appreciated!
The test macro adds and draws a circle (which works as expected), and then tries to create a symbol with the circle entity (and any other entities in the same group although there should not be any others ... I tried mode_ents with just the single entity with the same result). The symbol file is created in the macro folder and the circle shows in the preview when selecting the symbol to insert. If I insert the symbol unexploded I get the insertion point showing but not the circle (pressing '<' says symbol has been undone and removes the insertion point). Inserting it exploded does not appear to add anything to the drawing (pressing '<' undoes the line I added before inserting the symbol).
Code of y test macro is below and compiled version is attached. Any advice would be appreciated!
Code: Select all
library SymTest;
{$E dmx} //dmx is the extension for DCAL Dll's
{$R *.res}
uses
SysUtils,
Vcl.dialogs,
System.UITypes,
UConstants in '..\..\DCAL for Delphi Header Files\21.03\UConstants.pas',
UDCLibrary in '..\..\DCAL for Delphi Header Files\21.03\UDCLibrary.pas',
UInterfaces in '..\..\DCAL for Delphi Header Files\21.03\UInterfaces.pas',
UInterfacesRecords in '..\..\DCAL for Delphi Header Files\21.03\UInterfacesRecords.pas',
URecords in '..\..\DCAL for Delphi Header Files\21.03\URecords.pas',
UVariables in '..\..\DCAL for Delphi Header Files\21.03\UVariables.pas';
function Main(dcalstate : asint; act : action; pl, pargs : Pointer) : wantType; stdcall;
var
ent : entity;
mode : mode_type;
sym : sym_type;
begin
if act <> AlSize then begin
mode_init (mode); // do this first so it does not corrupt values assigned to other variables
ent_init (ent, entcrc);
setpoint (ent.crccent, 0);
ent.crcrad := 1000 * metricconv;
if ent_add (ent) then begin
ent_draw (ent, drmode_white);
mode_group (mode, ent);
symcreate (sym, mode, ent.crccent, 'TestCrc', false, false);
if sym_write (sym, 'TestCircle.dsf') = fl_ok then
messagedlg ('Symbol Created', mtInformation, [mbOK], 0)
else
messagedlg ('Symbol Create Failed', mtInformation, [mbOK], 0);
end
else
messagedlg ('ent_add Failed', mtInformation, [mbOK], 0);
end;
Result := XDone;{Necessary}
end;
exports
Main;{This is the entry function that will be called by DataCAD.
All DCAL Dlls will have this function.}
begin
end.
Attachments
(2.21 MiB) Downloaded 512 times
David Henderson
dhSoftware - Add-on Macros for DataCAD
dhSoftware - Add-on Macros for DataCAD