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.

Moderator: pjdixit

#75140 by dhs
Tue Nov 06, 2018 3:07 pm
Hi,
To create an entity on a layer that is not the current layer in Classic DCAL I have previously saved the current layer, switched to another layer to create the entity, and then switched back to the saved layer... similar procedure to copy any entity to another (non-current) layer.

This is not possible in D4D as the Lyr_Set procedure does not work. I seem to recall that simply changing the layer in the entity record does not work, so can anybody tell me a method to copy an entity to another layer in D4D ?

Thanks,
David H.
#75143 by David A. Giesselman
Tue Nov 06, 2018 4:02 pm
dhs wrote:... I seem to recall that simply changing the layer in the entity record does not work, so can anybody tell me a method to copy an entity to another layer in D4D ?

Are you calling ent_update after changing the layer field?
#75146 by dhs
Tue Nov 06, 2018 5:53 pm
Dave G wrote: Are you calling ent_update after changing the layer field?

Yes, I am calling ent_update. The following code is from a small test macro that I wrote:
Code: Select all     lyr_create ('Test Layer', lyr_addr);
     mode_init (mode);
     mode_lyr (mode, lyr_curr);
     addr := ent_first (mode);
     if ent_get (ent, addr) then begin
         ent.lyr := lyr_addr;
         ent_update (ent);       // crashes on this call
     end;
     callNone(retval);


It fails on the ent_update call with "DataCAD (internal diagnostics) fault 19 Error from: 736" and crashes out of the drawing.
#77113 by sam_bar
Mon Oct 21, 2019 7:39 am
David A. Giesselman wrote:
dhs wrote:... I seem to recall that simply changing the layer in the entity record does not work, so can anybody tell me a method to copy an entity to another layer in D4D ?



Tray to write somthing between
ent.lyr := lyr_addr;

//and
ent_update (ent);

// for example
pause(0.01);


Mybee that may help

Samuel Bar
Israel
#77114 by dhs
Mon Oct 21, 2019 1:06 pm
Tray to write somthing between


Thanks for the suggestion. I think I may have tried that in the past, but not absolutely sure. It would be a last resort to add a delay as I would have doubts about its reliability in all circumstances.

But in fact, my original post was incorrect:
lyr_set does in fact work in D4D. My original testing of this was trying to copy an entity to a newly created layer, so I was calling lyr_create followed by lyr_set (with lyr_set using the lyr that was returned by lyr_create). The layer was being created but lyr_set was not working (so I assumed that lyr_set did not work). The actual situation is that lyr_create does not correctly return the address of the newly created layer.
The workaround for this is to do a lyr_find to get the layer address after it is created but before calling lyr_set. This is an imperfect workaround as it is possible for D4D to create multiple layers with the same name, but it is the best solution I have been able to come up with and works in any practical situation where you would try to avoid duplicate names anyway (I think the DataCAD interface stops users creating duplicate names in recent versions, so you just need to ensure that your macro doesn't create duplicates).

Who is online

Users browsing this forum: No registered users and 2 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 AEC Professionals Since 1984