Deleting "Automatic Border""

I’m trying to delete the Automatic Border on drawings that unexpectedly showed up. I can find the Border Feature in the Feature Tree, but when I delete it, nothing happens… it’s still there. I’m beginning to suspect this is a SolidWorks quirk. Does anyone know anything about this.

Here’s the code I’m using:

Set swFeat = swModel.FirstFeature
BorderDeleted = False
Do While Not swFeat Is Nothing
    Debug.Print swFeat.Name & Chr(9) & swFeat.GetTypeName2
    If swFeat.GetTypeName2 = "DrSheet" Then
        Set swSheetFeat = swFeat.GetFirstSubFeature
        Do While Not swSheetFeat Is Nothing
            Debug.Print Chr(9) & swSheetFeat.Name & Chr(9) & swSheetFeat.GetTypeName2
            If swSheetFeat.GetTypeName2 = "DrTemplate" Then
                Set swSheetFormatFeat = swSheetFeat.GetFirstSubFeature
                Do While Not swSheetFormatFeat Is Nothing
                    Debug.Print Chr(9) & Chr(9) & swSheetFormatFeat.Name & Chr(9) & swSheetFormatFeat.GetTypeName2
                    If swSheetFormatFeat.GetTypeName2 = "EditBorderFeature" Then
                        swDraw.EditTemplate
                        Debug.Print "-->" & Chr(9) & Chr(9) & "DELETE " & swSheetFormatFeat.Name & Chr(9) & swSheetFormatFeat.GetTypeName2
                        swSheetFormatFeat.Select2 False, -1
                        swModel.Extension.DeleteSelection2 0
                        swDraw.EditSheet
                        BorderDeleted = True
                        Exit Do
                    End If
                    Set swSheetFormatFeat = swSheetFormatFeat.GetNextSubFeature
                    If BorderDeleted Then Exit Do
                Loop
                End If
            Set swSheetFeat = swSheetFeat.GetNextSubFeature
            If BorderDeleted Then Exit Do
        Loop
    End If
    Set swFeat = swFeat.GetNextFeature
    If BorderDeleted Then Exit Do
Loop

Thank You

swSheetFormatFeat.Select2 False, -1
selects nothing.

I dug pretty deep, found undocumented object “ZONEBORDER” in swSelectType_e it is not there, but it works in SelectByID2

selSuccess = swModel.Extension.SelectByID2("Border1", "ZONEBORDER"

EditDelete :skull:
DeleteSelection2 :skull:

swModel.EditSketch before .SelectByID2 :skull:

But the frame object itself cannot be removed from the API - only manually or by deleting EditBorderFeature directly.


DRW2.SLDDRW (79.9 KB)

1 Like

mihkov,

Thank you for giving it a shot.

1 Like

I’m a bit confused, I don’t have a boarder on my drawings

You can add it if you want.

Could you accomplish the same thing by replacing the sheet format?

I think Automatic Border was added in like 2016 or so. It will be present if you have SW create some fresh templates. We had been using some really really old templates, and just saving them as the new version every year. So our templates didn’t have automatic border either.

However, I ended up having to create fresh ones this year because something in our existing sheet formats was causing centerlines to be created with the wrong font in 2025…. It’s definitely recommended to so periodically.

Yes, replacing the sheet format does eliminate the border.

The border is “owned” by the sheet format. If you have an old sheet format that doesn’t have a border, replacing the sheet format will eliminate the border.