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

#76590 by dhs
Fri Jun 28, 2019 5:38 pm
I have a scenario where I need to move a newly created entity behind a group of previously created entities.
I could not find any specific D4D method to do this, but found that I could change the order of the entities using ent_relink as per the following code:

Code: Select all  ent_add (ent);
  mode_init (ExistEntMode);
  mode_group (ExistEntMode, FirstExistEnt);
  adr := ent_first (ExistEntMode);
  while ent_get (ExistEnt, adr) do begin   
    adr := ent_next (ExistEnt, ExistEntMode);
    ent_get (ent, ent.addr);     { crashes after several iterations if this ent_get is  not included }
   if not addr_equal (ent.addr, ExistEnt.addr) then
      ent_relink (ent, ExistEnt);
  end;


The above works (it moves the existing entities to after ent one by one), but does anybody know if there is a better (more efficient?) way (in D4D) to move an entity behind other entities?

On a side note: My initial code did not include the ent_get in the loop and has been working fine until today when I tested it in a scenario where there were about a dozen entities in the ExistEnt group. With a bit of trial and error I managed to ascertain that my macro crashed if there were more than about a half dozen ent_relinks in a row. Adding the ent_get into the loop appears to have fixed the crash.

I have updated my DCAL manual to included some extra notes about ent_relink, as well as about other issues and information that I've encountered since I last updated it. The latest version of my manual can always be downloaded from https://www.dhsoftware.com.au/dcalmanual.htm.

Who is online

Users browsing this forum: No registered users and 9 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