.NET

Reply
Active Contributor
sdphg
Posts: 28
Registered: ‎05-21-2008
Message 1 of 9 (239 Views)
Accepted Solution

Is it possible to create a layer that does not appear in LayerManager?

239 Views, 8 Replies
08-04-2014 08:43 PM
I want to create a layer that can only be managed by code, not by the user. So this layer must not appear in LayerManager, or user can see it in the LayerManager but can do nothing to it, that means user can not hide, delete ... Actually, I need a feature like the MS word revision history. I want to put the revision information in a protected layer, so only program can chose to show or hide it. Any ideas? thank you.

The new AutoCAD "Revision" feature (like Microsoft Word) can be implemented as:

 

layerTableRecord.IsHidden = true; // Hide this layer name from Layer Manager and toolbar

layerTableRecord.IsFrozen = true; // Completely hide all entities in this layer, even Ctrl-A will not select them

layerTableRecord.IsPlottable = false; // Prevent plotting this layer

 

If you still want to keep an entity with its original layer (especially a block with nested entities in multiple layers) to restore back, use Entity.Visible = false to hide it from the screen. You may think to use Entity.XData to mark the entity is 'Revision" entity to restore back later.

 

However, if an entity with Entity.Visible = false, it still can be selected by Ctrl-A (select all). You can make them more protected by store it into a Frozen layer, not Off layer.

 

Mentor
khoa.ho
Posts: 216
Registered: ‎09-15-2011
Message 2 of 9 (229 Views)

Re: Is it possible to create a layer that does not appear in LayerManager?

08-04-2014 10:13 PM in reply to: sdphg

One idea is to create a layer (for Revision purpose), and put all needed entities in this layer. Then use the loop for each entity in the current space, set Entity.Visible = false if this entity (text, line, circle...) is in the "Revision" layer. By that way, users still see this layer on the Layer Manager, but don't see anything in this layer as they are invisible. This layer is also not be able to delete as it is not empty.

 

Your program will turn on or off entity visibility in the certain layer, using Entity.Visible not layer visible.

 

Valued Contributor
FRFR1426
Posts: 78
Registered: ‎04-05-2012
Message 3 of 9 (214 Views)

Re: Is it possible to create a layer that does not appear in LayerManager?

08-04-2014 11:47 PM in reply to: khoa.ho
myLayer.IsHidden = true;

 

Mentor
khoa.ho
Posts: 216
Registered: ‎09-15-2011
Message 4 of 9 (184 Views)

Re: Is it possible to create a layer that does not appear in LayerManager?

08-05-2014 07:08 AM in reply to: FRFR1426

Thanks for your good note. This is a right article about it: http://adndevblog.typepad.com/autocad/2012/05/creating-a-anonymous-layer.html

 

Valued Mentor
jeff
Posts: 330
Registered: ‎05-12-2009
Message 5 of 9 (176 Views)

Re: Is it possible to create a layer that does not appear in LayerManager?

08-05-2014 07:53 AM in reply to: FRFR1426

 

To add to FRFR1426 comment when you change value of IsHidden the only thing I could find to get the layermanager to refresh itself was to open the the LayerTable for write.

 

So any method that changes a IsHidden property I always have had to open the LayerTable for write so it would reflect in LayerManager    

You can also find your answers @ TheSwamp
Mentor
khoa.ho
Posts: 216
Registered: ‎09-15-2011
Message 6 of 9 (175 Views)

Re: Is it possible to create a layer that does not appear in LayerManager?

08-05-2014 07:53 AM in reply to: sdphg

The new AutoCAD "Revision" feature (like Microsoft Word) can be implemented as:

 

layerTableRecord.IsHidden = true; // Hide this layer name from Layer Manager and toolbar

layerTableRecord.IsFrozen = true; // Completely hide all entities in this layer, even Ctrl-A will not select them

layerTableRecord.IsPlottable = false; // Prevent plotting this layer

 

If you still want to keep an entity with its original layer (especially a block with nested entities in multiple layers) to restore back, use Entity.Visible = false to hide it from the screen. You may think to use Entity.XData to mark the entity is 'Revision" entity to restore back later.

 

However, if an entity with Entity.Visible = false, it still can be selected by Ctrl-A (select all). You can make them more protected by store it into a Frozen layer, not Off layer.

 

Active Contributor
sdphg
Posts: 28
Registered: ‎05-21-2008
Message 7 of 9 (157 Views)

Re: Is it possible to create a layer that does not appear in LayerManager?

08-05-2014 08:48 AM in reply to: khoa.ho
Thank you khoa.ho, your solution sounds good, I will give it a shot, and thank you all guys.
Mentor
khoa.ho
Posts: 216
Registered: ‎09-15-2011
Message 8 of 9 (151 Views)

Re: Is it possible to create a layer that does not appear in LayerManager?

08-05-2014 08:54 AM in reply to: sdphg

Once you are done with your test, please mark it as accepted solution to help later readers. I will also give me a try on that. Thanks.

 

Active Contributor
sdphg
Posts: 28
Registered: ‎05-21-2008
Message 9 of 9 (144 Views)

Re: Is it possible to create a layer that does not appear in LayerManager?

08-05-2014 08:59 AM in reply to: khoa.ho
No problem, your solution sounds very reasonable, I will post the my test in details.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.