static TCHAR szNewLayerName[100] = _T("");
Acad_System::GetInputString(_T("LayerName:"),szNewLayerName);
AcDbObjectId idLayer = Acad_System::GetLayerIDFromName(szNewLayerName);
if (idLayer.isNull()) return;
AcDbLayerTableRecordPointer pLayer(idLayer,AcDb::kForWrite);
pLayer->setIsFrozen(!pLayer->isFrozen());
first, make sure that there are some entitys on some layer(for example, "A", ), and make sure that your selected layer is not the CAD's current layer. then execut the code above . you will find that the layer status in the CAD toolbar change as your desire. but the entitys on the selected layer are not. I have to use command "re" to refresh. I believe this is a bug. because setIsLock and setIsOff work well while setIsFrozen not.
Take a look at the applyCurDwgLayerTableChanges function.
@cnngtdly wrote:[...]I believe this is a bug. because setIsLock and setIsOff work well while setIsFrozen not.[...]
It is not a bug. It is by design. Otherwise, AutoCAD would have to find all the entities (iterate database), which belong to this layer and make them invisible. And if your program will freeze immediately thousands of layers? How long you would be ready to wait? And you freeze the layers, and then once with applyCurDwgLayerTableChanges used an altered state of the layers.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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
yes, I understand your worry about the efficency , but "setIsOff " can also make the entitys belonging a layer invisialble. but "setIsOff" can do it automaticly without "applyCurDwgLayerTableChanges" . "setIsOff" and "setIsFrozen" , these two function, both make entitys invisible, I guess , "setIsOff" makes the layer invisible. and "setIsFrozen" makes all the entitys belonging to a certain layer invisible, so "setIsFrozen" takes more time, is that right?
Nice to see you, my dear friend, are you also an engineer like Alexander?
you are good at ARX coding. I have been working on ARX for years, but still did not quite understand it.
I am an artist, not an engineer. Further to Alexander's reply, Off layers still generate display list geometry, whereas frozen layers do not, therefore thawing a layer requires a regen. Turning a layer On or Off does not; the geometry is already generated, it only needs to be displayed or hidden.
I am afraid only applyCurDwgLayerTableChanges() is not enough. I added this global function , but the invisible entiys did not appear again untill I zoom the whole window.
@cnngtdly wrote:
I am afraid only applyCurDwgLayerTableChanges() is not enough. I added this global function , but the invisible entiys did not appear again untill I zoom the whole window.
I hope that you close AcDbLayerTable and all AcDbLayerTableRecords before you call applyCurDwgLayerTableChanges(). Other way is calling ads_regen():
void ads_regen();
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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
I can guarantee that AcDbLayerTable and all AcDbLayerTableRecords have been closed . but still not work in AutoCAD 2008 . I feel a little confused.
static TCHAR szNewLayerName[100] = _T("");
Acad_System::GetInputString(_T("LayerName:"),szNewLayerName);
AcDbObjectId idLayer = Acad_System::GetLayerIDFromName(szNewLayerName);
if (idLayer.isNull()) return;
{
AcDbLayerTableRecordPointer pLayer(idLayer,AcDb::kForWrite);
pLayer->setIsFrozen(!pLayer->isFrozen());
}
applyCurDwgLayerTableChanges();
the entitys on the selected layer can disappear normally, but won't appear again untill "regen" or "zoom".