katto01 Posted September 26, 2020 Posted September 26, 2020 Hello, I am trying to change the change the active layer. I tried this routine but no luck. Public Sub ChangeEntityLayer() Dim objEntity As AcadEntity Dim varPick As Variant Dim strLayerName As String Dim objLayer As AcadLayer strLayerName="Mypoints" Set objLayer = ThisDrawing.Layers(strLayerName) End Sub Any ideas? Thank you Quote
PeterPan9720 Posted September 26, 2020 Posted September 26, 2020 26 minutes ago, katto01 said: Hello, I am trying to change the change the active layer. I tried this routine but no luck. Public Sub ChangeEntityLayer() Dim objEntity As AcadEntity Dim varPick As Variant Dim strLayerName As String Dim objLayer As AcadLayer strLayerName="Mypoints" Set objLayer = ThisDrawing.Layers(strLayerName) End Sub Any ideas? Thank you See On line Hep for Active Layer Sub Example_ActiveLayer() ' This example returns the current layer ' and then adds a new layer. ' Finally, it returns the layer to the previous setting. Dim currLayer As AcadLayer Dim newLayer As AcadLayer ' Return the current layer of the active document Set currLayer = ThisDrawing.ActiveLayer MsgBox "The current layer is " & currLayer.name, vbInformation, "ActiveLayer Example" ' Create a Layer and make it the active layer Set newLayer = ThisDrawing.Layers.Add("TestLayer") ThisDrawing.ActiveLayer = newLayer MsgBox "The new layer is " & newLayer.name, vbInformation, "ActiveLayer Example" ' Reset the layer to its previous setting ThisDrawing.ActiveLayer = currLayer MsgBox "The active layer is reset to " & currLayer.name, vbInformation, "ActiveLayer Example" End Sub What you are trying to do with below code it's for retrieving all layers collection in the drawing not for set layer. Dim objLayer As AcadLayers strLayerName="Mypoints" 'could be used to create new layer and make it as active layer. Set objLayer = ThisDrawing.Layers(strLayerName) Set objLayer = ThisDrawing.Layers Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.