I'm trying to delete programmatically several empty layers (Draft environment). It works fine, except when the empty layer to be deleted is the active one inside a BlockView, in which case it fails.
I've been able to access to each BlockView and, although it's possible to manipulate each element inside the BlockView (lines, circles, balloons...) and to move them from one layer to another if necessary, I haven't been able to identify the Active Layer inside the BlockView, neither to Activate programmatically inside the BlockView another layer in order to delete the empty layer (I think the problem is that I can't find any "sheet" object a "Layers" object inside the BlockView). Any suggestion about how could it be done?
Thanks in advance.
P.S.: My code so far (Visual Basic), just in case someone finds it helpful:
Set objApp = GetObject(, "SolidEdge.Application")
Set objDraft = objApp.ActiveDocument
Set objBlocks = objDraft.Blocks
For Each objBlock In objBlocks
Set objBlockViews = objBlock.Views
For Each objBlockView In objBlockViews
' change all the lines inside the BlockView
' to the "Default Layer" layer
Set objLines2d = objBlockView.Lines2d
For Each objLine2d In objLines2d
objLine2d.Layer= "Default Layer"
Set objSheets = objDraft.Sheets
For Each objSheet In objSheets
Set objLayers = objSheet.Layers
For Each objLayer In objLayers
If objLayer.IsEmpty = True Then
' we activate the "default" layer, just in case
' objLayer is the current active layer
Call objSheet.Layers.Item("Default Layer").Activate
' message error in the following line if objLayer is thr Active layer inside a BlockView, even if objLayer is empty