Getting Lines on unlocked layers at one go

By Balaji Ramamoorthy

Recently a developer asked this question and here is the code snippet. The code snippet can be modified to fetch entities based on any such criteria. The “acedssget” method can take filter in the form a result buffer. It can be formed using the “acutBuildList” method, but I havent used it in this code snippet since the layers that are unlocked are not known until we iterate the Layer table. Instead, the result buffer is created node by node based on the number of unlocked layer that we find.

resbuf* pLineResbuf;
resbuf* pIter = 0;
 
wchar_t szLineBuff[] = L"LINE";
pLineResbuf = acutNewRb(0);
pIter = pLineResbuf;
pIter->resval.rstring = new wchar_t[wcslen(szLineBuff) + 1];
wcscpy(pIter->resval.rstring, szLineBuff);
 
wchar_t szConditionBuff1[] = L"";
pIter->rbnext = acutNewRb(-4);
pIter = pIter->rbnext;
pIter->resval.rstring = new wchar_t[wcslen(szConditionBuff2) + 1];
wcscpy(pIter->resval.rstring, szConditionBuff2);
 
ads_name selectset; 
acedSSGet(L"_X", NULL, NULL, pLineResbuf, selectset); 
 
long length=0;
acedSSLength (selectset, &length);
 
acutPrintf(L"nNumber of Entities: %d", length);
 
for (int idx=0; idxisA()->name());
}
 
acedSSFree(selectset);
acutRelRb(pLineResbuf);

Comments

3 responses to “Getting Lines on unlocked layers at one go”

  1. Anonymoose Avatar
    Anonymoose

    Why go through all of that, when the acedSSGet() function supports the :L option which rejects objects on locked layers?
    Are you kidding us or what?
    Command: (ssget “:L”)
    Select objects: ALL
    25012 found
    2033 were on a locked layer.

  2. Hello,
    “Are you kidding us or what?”
    No, I wouldnt dare to. :)
    I did try the “:L” option which is undocumented but I could only get it to work when used along with the filter only select “_X” option. So decided to include all that info into the filter resbuf instead.
    Yes, it is indeed lenghthier, but in my opinion it will help developers to modify that code to suit to their specific filtering criteria.

  3. Tony Tanzillo Avatar
    Tony Tanzillo

    Hi. The :L option seems to work for me regardless of whether using “_X” all filter or not, but it may have something to do with the local language you’re using.
    While this method is undocumented,I think that is only because no one has been asked to document it, and it is in very extensive use out here in the real world.
    Not only that, but the managed PromptSelectionOptions class’s ExcludeObjectsOnLockedLayers property is the public API for the :L option in the AutoCAD .NET api, which is documented.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading