I have a series of layer names that are grouped based on how my programs use them. As an example, I have about 10 layers that start with "!DISPLAY_" (e.g. "!_DISPLAY_FACET"). I need a way to see if any of them exist. The ::has method doesn't work with wildcards?
I have a function that uses the following code and it returns FALSE when I pass it _T("!_DISPLAY_*") as csLayerName (and "!_DISPLAY_FACET" exists):
AcDbLayerTable *pLayerTbl;
AcDbDatabase *pCurDb;
pCurDb = acdbHostApplicationServices()->workingDatabase();
pCurDb->getSymbolTable(pLayerTbl, AcDb::kForRead);
if(pLayerTbl->has(csLayerName)) {
pLayerTbl->close();
return TRUE;
} else {
pLayerTbl->close();
return FALSE;
}
Is there a way to accomplish this with wildcards?
Thanks,
Ed
Solved! Go to Solution.
Solved by Alexander.Rivilis. Go to Solution.
You can iterate LayerTable, get LayerTableRecord and compare its name with help of function acutWcMatch (or acutWcMatchEx) with your's pattern (e.g. with _T("!_DISPLAY_*")).
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Agreed. I see no way to do a direct wildcard search without iterating the SymbolTableRecords.
Perhaps if you explained the purpose of wanting to know if any of your records have been added to the table rather than specific ones, then someone may be able to suggest an alternative approach. For example, are you doing this to see if the DWG has previously been processed by your app? If so, you could (for example) add some Xdata to the drawing or add an Xrecord to the Named Objects Dictionary.
I have some routines that control the layers depending on what the program is trying to accomplish. If there are elements on !_DISPLAY_FACET, depending on what the function is trying to do, I may want to freeze or thaw (or even lock) that layer. When the dialog boxes load, there are check boxes for the different types of elements. I used to put everything on !_DISPLAY so it was easy use the function I showed before to return TRUE or FALSE and set the check boxes accordingly. Now, I need to keep things on separate layers.
I think iterating through the layer table is probably the best way. I just thought that it would be as easy as selecting elements with the wildcard layer names in acutBuildList() like: rb = acutBuildList(-3, 1001, _T("MyApp"), RTDXF0, _T("LINE"), 8, _T("!DISPLAY_*"), RTNONE); which works fine only if there are elements on the layer. I need to control them even if there's nothing on them.
I will post my solution tomorrow.
Thank you,
Ed
Here's my function. I set it up so I can do with or without wildcards. Any comments, suggestions or improvements are always welcome.
Thanks,
Ed
Take a good look what is wrong in this cycle:
for ( ; !pLayerTableIterator->done() ; pLayerTableIterator->step()) { es = pLayerTableIterator->getRecord(pRecord, AcDb::kForRead, FALSE); if(es != Acad::eOk) { acutPrintf(_T("\nLayerTableIterator->getRecord in emdExistsLayer() returned %d"), es); continue; } else { pRecord->getName(chrName); if(acutWcMatchEx(chrName, chrLayerName, TRUE)) { bExists = TRUE; break; // out of the for loop } } // if es pRecord->close(); } // for
If acutWcMatchEx(chrName, chrLayerName, TRUE) != 0 then you forget close pRecord. 😞
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn