Can't Delete Sheet Format AutoZones/Borders

Programming and macros
User avatar
loeb
Posts: 68
Joined: Sun Jan 16, 2022 5:55 pm
Answers: 1
x 39
x 10

Can't Delete Sheet Format AutoZones/Borders

Unread post by loeb »

My engineering group is having a problem where the SW Drawing AutoZones/Borders are being created 'by themselves' and often go undetected until later in our work flow, creating additional work to correct them. I want to modify one of our commonly used macros to also automatically delete these if they exist.

"TraverseNode" is a function that successfully creates a collection of all the feature nodes.

I wrote the following code that is able to find the feature in the feature/node tree. It properly gets the name, type, and ID, but I doesn't successfully delete them. I think that my selection method has a problem.

Thank you for your help.

Code: Select all

    TraverseNode swRootNode, swFeatsColl
    For i = 1 To swFeatsColl.Count
        Set swFeat = swFeatsColl.Item(i)
        FeatName = swFeat.Name
        FeatType = swFeat.GetTypeName2()
        FeatID = swFeat.GetID
        Debug.Print i & "    " & "Name: " & FeatName & "    " & "Type: " & FeatType & "    " & "ID: " & FeatID
        If swFeat.GetTypeName2() = "EditBorderFeature" Then
            FeatName = swFeat.Name
            FeatType = swFeat.GetTypeName2()
            FeatID = swFeat.GetID
            Debug.Print i & "    " & "Name: " & FeatName & "    " & "Type: " & FeatType & "    " & "ID: " & FeatID
            swModel.ClearSelection
            BoolStatus = swModel.Extension.SelectByID2(FeatName, FeatType, 0, 0, 0, False, 0, Nothing, 0)
            Debug.Print "SelectByID2: " & BoolStatus 'Returns FALSE !?!?!
            swModel.EditDelete
            Debug.Print "EditDelete: " & BoolStatus 'Returns FALSE !?!?!
            Exit Sub
        End If
    Next
Post Reply