4 Replies Latest reply on Aug 13, 2018 2:44 AM by Martin Valdhans

    Automatic Border Not Remembering Layer

    Jonathan Westcott

      I have been trying to bulk update sheet formats but have noticed strange behaviour with the automatic borders.

      In my system, by default the automatic borders are set to a level called "ZONES" in document properties and the line thickness is set to 0.25mm.

       

      2018-02-15 16_07_18-Document Properties - Borders.png

       

      When I reload a sheet format all the other items in the sheet move to the correct layer but the Automatic Border doesn't.

      It seems to ignore the setting in document properties and resets to the border layer to "-None-".

       

      2018-02-15 16_10_34-SOLIDWORKS Premium 2017 x64 Edition - [Drawing (Based on FRM-0003) - Sheet1 _].png

       

      I now want to reset it back to "ZONES" but as the automatic border is configured through a program "swCommand_Border_Editor" I'm wondering if it is possible to set this layer via API as I can't find any commands to do it?

       

      Any ideas would be appreciated.

        • Re: Automatic Border Not Remembering Layer
          Brian Camilly

          I'm having the same issue, intermittently. My border lands on a layer that is hidden and can not be moved to a different layer with out deleting it and re-adding.

           

          I hope someone find a solution to this.

          • Re: Automatic Border Not Remembering Layer
            Martin Valdhans

            Hi Jonathan,

            following macro will change the Layer of all sketch segments and annotations in drawing template.

            Open your Drawing and run this code

             

            'vLayName --> target-layer name

             

            Dim swApp                       As SldWorks.SldWorks
            Dim swDoc                       As SldWorks.ModelDoc2
            Dim swDraw                      As SldWorks.DrawingDoc
            Dim swSketch                    As SldWorks.Sketch
            Dim swSketchSeg                 As SldWorks.SketchSegment
            Dim swAnn                       As SldWorks.Annotation
            Dim swView                      As SldWorks.View

            Dim vSketchSeg                  As Variant
            Dim vLayName                    As String
            Dim vAnn                        As Variant

            Sub main1()

            Set swApp = CreateObject("SldWorks.Application")
            Set swDoc = swApp.ActiveDoc
            Set swDraw = swDoc

            swDraw.EditTemplate
            Set swSketch = swDoc.GetActiveSketch2
            swDoc.ClearSelection2 (True)
            vSketchSeg = swSketch.GetSketchSegments
            vLayName = "FORMAT"

            For i = 0 To UBound(vSketchSeg)
                Set swSketchSeg = vSketchSeg(i)
                swSketchSeg.Layer = vLayName
            Next

            Set swView = swDraw.GetFirstView
            vAnn = swView.GetAnnotations

            For j = 0 To UBound(vAnn)
                Set swAnn = vAnn(j)
                swAnn.Layer = vLayName
            Next

            swDraw.EditSheet
            swDoc.ForceRebuild3 True

            End Sub

              • Re: Automatic Border Not Remembering Layer
                Jonathan Westcott

                Hi Martin,

                 

                This is true for sketch segment etc, but automatic borders are not sketch segments and are unaffected by this macro.

                The only way I have found to edit the layer for an Automatic Border is to launch the "Automatic Border Editor" and manually change the layer.

                It looks like the API does not extend to this tool (Automatic Border Editor). You seem to be able the launch it with API but can't actually run any of its command with API.