The DataCAD Developer Network (DDN) is an online resource for information and support for DCAL® (DataCAD Applications Language) developers as well as anyone interested in creating fonts, toolbars, hatch patterns, or linetypes for use in DataCAD.
#71353 by dhs
Thu Apr 27, 2017 10:27 pm
I'm having some angst with this one, so hopefully somebody can point me in the right direction:

I am trying to add a symbol to a drawing and then add an entsym entity using the created symbol with a modelling matrix.

My symbol consists of 1 or more polylines, and the main reason for making it into a symbol is so that I can treat it as a 3D entity and apply a modelling matrix to it.

The first time I managed to compile the DCAL code and try it out I was delighted to see that it did just as I expected. I tested it with a single polyline in the symbol and the symbol was placed and rotated about all 3 axis just as I wanted ... almost too good to believe I got it right first time!

But my delight was short-lived. When I test the same code with 2 polylines in the symbol the drawing crashes out. Either of the 2 polylines work fine by themselves, but not if both are included at once.

I have pasted a code extract below. (The indented lines are my original code; the non-indented lines are debugging code that I added to try to work out where the problem is happening ... I find it useful to add debugging code non-indented as it is easy to find and remove it once the problem is fixed):

! create a symbol to contain all the shadows that are currently transformed by mat
! (the symbol itself will be rotated back into position using invmat once it is inserted)
SetShadSymbolName (symname);
mode_init (shadmode);
mode_group (shadmode, shadow);
addr := ent_first (mode);
while ent_get (ent, addr) do
addr := ent_next (ent, mode);
ent_draw (ent, drmode_white);
end;
setpoint (ref, 0.0);
sym_create (sym, shadmode, ref, symname, true, true);
msg_OK ('symbol created');
ent_init (shadow, entsym);
shadow.symname := symname;
shadow.symmod := invmat;
ent_add (shadow);
if ent_get (ent, shadow.addr) then
msg_OK ('symbol added ok');
else
msg_OK ('symbol added? but cannot get it');
end;
ent_draw (shadow, drmode_white);
msg_OK ('All done');


From the debugging code I know that shadmode defines the expected entities (they are drawn to the screen correctly by the debugging code), I also know that the symbol is being created and the the shadow entity is added and can be retrieved from the database (the 'symbol added ok' message is displayed), but the drawing crashes out on the ent_draw (before the 'All done' message is displayed). This is the exact same code that works fine when the group only contains a single polyline.

The 2 entities I am testing with are both closed polylines with just 4 polyverts and with plnBase & plnHite as zero (and the z of each of the polyverts is also zero).

symname is a symstr that has a value about 50 characters long (assigned by the SetShadSymbolName call near the top of code extract). The name I am using contains spaces and colons in addition to normal letters and numbers, but I don't think that is the problem as it works with a single entity in the symbol. Sample of name I am using is 'SHADOW Syd 21Jun 8am Created:20170427 05:29:23' (although it gets converted to all upper case when the symbol is created). I include the created date/time to ensure that I do not redefine an existing symbol with the same name.

I'm testing this using DataCAD 11.

Can anybody offer any suggestions on why the drawing is crashing or how I can overcome this problem ? Or is it simply not wise to try to use 2D entities like 3D ones by creating symbols ?

Many thanks,
David H.
#71363 by David A. Giesselman
Fri Apr 28, 2017 4:41 pm
David,

If you remove the "ent_draw" call and use the "U" key to regen DataCAD's display list, does it still crash?

Dave
#71369 by dhs
Sun Apr 30, 2017 2:42 am
Thanks for your input & offer to look at it Dave,

I have found the error ... it was my error (elsewhere in the macro code). I was effectively adding each polyline to the drawing twice.
I had code in a called procedure that was creating the polyline entity and adding it to the database etc. The calling procedure then did another ent_add on the just created (and added) entity. I have removed the second ent_add and the crash no longer occurs.

The interesting thing is that this did not seem to cause a problem if I just left them as polylines, it only occurred when I used the polylines to create symbols (and only if there was more than 1 polyline involved). That led me to (incorrectly) assume that the problem was in the symbol creation code.

Thanks,
David H.

Who is online

Users browsing this forum: No registered users and 8 guests

About DataCAD Forum

The DataCAD Forum is a FREE online community we provide to enhance your experience with DataCAD.

We hope you'll visit often to get answers, share ideas, and interact with other DataCAD users around the world.

DataCAD

Software for Architects Since 1984