LocalContext vs. AutoCAD Layer?

Hi, everybody:

I want to dynamiclly switch between different group of AIS objects or their combination. In AutoCAD, it is fulfilled with Layer. I want to know if the concept of LocalContext is similar with Layer? i.e. I can distribute my AIS objects into different LocalContext and when one LocalContext is activated, the others is invisible, but when I switch to that LocalContext, all those AISObjs belong to that LocalContext still can be seen?

It will be highly appreciated If someone could show me some examples.

fhchina's picture

Could somebody help me?

François Lauzon's picture

Hello Fhchina,
local context work much like a stack, when you open a new one, it become active and only this one is active, when you close it, the previous one become active, so you can't have multiple local context active at the same time. It's not designed to be used like you want, and I think it is much easier to use AIS_InteractiveContext methods like Erase/Display to show or hide (put them in the collector) your object based on some condition (level, layer,...).

Good Luck,
Francois.

François Lauzon's picture

Hi Fhchina,
Local Context are not like layers. Local Context are use for temporary presentations and selections. I suggest you have a look at the visu.pdf Visualization User's Guide, chapter 3 (about AIS).

You might also want to check the SetOwner/GetOwner/HasOwner methods, you could attach all the attributes you want there (level, color, name, ...). To do what you want, you will have to use the interactive context (look at the manual for more details...)

Good Luck,
Francois.

fhchina's picture

Thank you, Francois.

I want to know the meaning of `temporary'.

In AutoCAD, layer is a built-in structure of DWG database. In OCC, it may be just an AIS technique. I think I can add some features of layers to my application based on LocalContext.

The most key aspect I want to know is: An AIS_InteractiveObject can be owned by one LocalContext and only One( when not using Netural Point). Yes or No?

Could I easily switch between different LocalContext when not to close them?

Could I combine different LocalContext to show simutaneously?

Thanks.

fhchina