.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Toggle Layer (Change IsFrozen Property of Specific Layer)

5 REPLIES 5
Reply
Message 1 of 6
Hugh_Compton
447 Views, 5 Replies

Toggle Layer (Change IsFrozen Property of Specific Layer)

I'm trying to develop some VB.Net code to toggle a layer (toggle it's IsFrozen property). The layer's name is "0cm-Annot-ADT".

If the 0cm-Annot-ADT layer is current then I wish to make the layer "0" current then freeze layer "0cm-Annot-ADT".
If the layer "0cm-Annot-ADT" is frozen then I wish to unfreeze it.
I have attached my code so far but I'd welcome a simpler method if you have one.
Thanks.
5 REPLIES 5
Message 2 of 6
Hugh_Compton
in reply to: Hugh_Compton

I have attached some much revised code in my second attempt.

The new code will freeze and thaw the layer BUT when the layer has been thawed all of the entities become invisible ???

I have a regen command at the end of the code but it doesn't help 😞
Message 3 of 6
Anonymous
in reply to: Hugh_Compton

Hugh,

I know this is an old post but would just like to give a solution so other people know how to solve this issue.
The reason that you cant see the entities that have been thawed is because you are trying to regen the drawing before the transaction is complete. Here is what the end of your code should look like;

Finally
tr.Commit()
tr.Dispose()
ed.Regen() 'regen autocad
End Try
End Sub

all should be good now when you thaw or freeze a layer. 🙂
Message 4 of 6
Hugh_Compton
in reply to: Hugh_Compton

Hi Wills

I tried your suggestion but the thawed layer still doesn't show 😞

I can get the layer to show once thawed by either closing then reopening the drawing or by manually freezing and thawing the layer in the layer manager. This defeats the point of me having a layer toggle routine.

Does anyone have a layer toggle routine hey'd be willing to share?
Message 5 of 6
Anonymous
in reply to: Hugh_Compton

Hugh,

Attached is txt file with your code that i have used. I have not really modified it at all. In my last post i didnt specify what subprocedure in your code to modify. The code should be modified in the freeze layer sub routine as shown below. Just have to regen autocad after you dispose of the transation. My apologies i didnt specify that in previous post.

Catch ex As Exception
MsgBox("Error in FreezeLayer " & ex.Message)
Finally
tr.Commit()
tr.Dispose()
ed.Regen() 'regen autocad
End Try
End Sub 'freezes received layer or unfreezes layer depending on boolean received

Hope this helps.

Regards
Message 6 of 6
Hugh_Compton
in reply to: Hugh_Compton

Hi Wills

After much time I have found why my entites will not appear when thawed. It appears as though somehow the entities are having their visibility turned off. To remedy this I have added some code to the SetLayerCurrent routine (see attached text file) that turns their visibility on.

This solution works but I have no idea why their visibility should change (maybe something to do with using ACA 2010?).

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost