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

#74020 by dhs
Sat Jun 02, 2018 9:13 pm
Just wondering if anybody else has used the lyr_isLocked function in Dcal for Delphi ?
I seem to be getting unpredictable results with it in the following logic:

Code: Select allprocedure TdhForm.FormCreate(Sender: TObject);
  MyLyr : TLyr;     //class which simply holds layer address so that it can be added to the list as an object
  lyr     : lyraddr;
  lyrname : shortstring;
  ndx : integer;
  lyr := lyr_first;
    MyLyr := TLyr.Create(lyr);
    getlyrname (lyr, lyrname);
    if lyr_isLocked (lyr) then
      lyrname := lyrname + ' (LOCKED)';
    ndx := ListBox1.Items.AddObject(string(lyrname), MyLyr);
    ListBox1.Selected[ndx] := LyrEqual (lyr, GetLyrCurr);
    lyr := lyr_next(lyr);
  until isnil (lyr);

With the above code I am getting ' (LOCKED)' appended to layer names pretty much at random.
Have I done something obviously wrong here or is the lyr_isLocked function buggy ? (I am using Dcad

David H.
#74024 by David A. Giesselman
Mon Jun 04, 2018 10:30 am
What does the Create method for your TLyr class look like?
#74025 by dhs
Mon Jun 04, 2018 1:34 pm
Hi Dave,
Here's the entire class:

Code: Select allunit Lyr;

  uses URecords;

    TLyr = Class(TObject)
          MyAddr : lyrAddr;
         constructor Create(Addr : lyraddr);
         property Addr : lyraddr
             read MyAddr;

 constructor TLyr.Create(Addr : lyraddr);
   MyAddr  := Addr;

As you can see, it's a simple assignment statement in the create. Subsequent logic retrieving the lyraddr from the list objects is working as expected.

David H.
#74028 by David A. Giesselman
Mon Jun 04, 2018 1:47 pm

I'm not sure why it would be giving you unpredictable results. If you modify your code to call "lyr_get" you could inspect the .group field of the Rlayer record. If that field is equal to -1, the layer is not locked.

#74039 by David A. Giesselman
Mon Jun 04, 2018 4:40 pm
dhs wrote:Thanks Dave,

Your suggestion of inspecting the .group field of the layer record is working as expected.

No worries David, although I am intrigued as to why the function call was returning different results.
#74064 by dhs
Wed Jun 06, 2018 5:50 pm
Happy send you the entire project source if you want to debug it etc to see why it is returning incorrect values, but the workaround you suggested seems to working ok.

I was working on a simple Text Replace macro as an exercise to re-familiarise myself with D4D. (It is now completed and available for download from my web site for anybody that is interested.) It will only process normal text entities, as I don't think MText or PText are accessible from DCAL or D4D (?). Any chance that these entity types will be accessible by D4D in the future ?

David H.

Who is online

Users browsing this forum: No registered users and 1 guest

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.


Software for AEC Professionals Since 1984