Hide Table of Contents

Get Broken-Out Section Feature Data Example (VBA)

This example shows how to get broken-out section feature data from a drawing view.

'----------------------------------------------------------------------------
' Preconditions: Open a drawing that contains a view with a broken-out
' section feature.
'
' Postconditions:
' 1. Inspect the Immediate window.
' 2. The radius of the broken-out section is increased.
' ---------------------------------------------------------------------------

Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swDDoc As SldWorks.DrawingDoc
Dim varSheet As Variant
Dim varViews As Variant
Dim I As Long
Dim J As Long
Dim K As Long
Dim swFeat As SldWorks.Feature
Dim swFeatData As SldWorks.BrokenOutSectionFeatureData
Dim swDepthRef As SldWorks.Entity
Dim varBS As Variant
Dim doRelease As Boolean
Dim varskSeg As Variant
Dim segCtr As Long
Dim segType As Long

Option Explicit
Sub main()

    Set swApp = Application.SldWorks
    Set swDoc = swApp.ActiveDoc
    Set swDDoc = swDoc
    swDoc.ClearSelection2 True
    varSheet = swDDoc.GetViews
    For I = LBound(varSheet) To UBound(varSheet)
        varViews = varSheet(I)
        For J = 1 To UBound(varViews) ' skip the sheet view
            Dim swView As SldWorks.View
            Set swView = varViews(J)
            Debug.Print "View: " & swView.Name
            Debug.Print ("  Number of broken-out sections in this view: " & swView.GetBreakOutSectionCount)
            varBS = swView.GetBreakOutSections
            If (Not (IsEmpty(varBS))) Then
                For K = LBound(varBS) To UBound(varBS)
                    Set swFeat = varBS(K)
                    Call EditFeature(swFeat)
                    Set swFeatData = swFeat.GetDefinition
                    swFeatData.AccessSelections swDoc, Nothing
                    Set swDepthRef = swFeatData.DepthReference ' depth reference is not set
                    If (swDepthRef Is Nothing) Then
                        Debug.Print ("              Depth of exposure in meters: " & swFeatData.Depth)
                    Else
                        swDepthRef.Select True
                    End If
                    swFeatData.ReleaseSelectionAccess
                    Set swFeatData = Nothing
                Next K
            End If
        Next J
    Next I
End Sub


Sub GetExistingValue()

    swFeatData.EditSketch = True
    varskSeg = swFeatData.SketchSegment
    If (Not (IsEmpty(varskSeg))) Then
        Debug.Print ("              Number of sketch segments: " & swFeatData.GetSketchSegmentCount)
    End If
End Sub


Sub EditFeature(inFeat As SldWorks.Feature)

    Debug.Print ("      Iterating on broken-out section: " & inFeat.Name)
   

    Set swFeatData = inFeat.GetDefinition
    swFeatData.AccessSelections swDoc, Nothing
   

    GetExistingValue
   

    If (doRelease = False) Then
        If (Not (IsEmpty(varskSeg))) Then
            For segCtr = LBound(varskSeg) To UBound(varskSeg)
                Dim swSeg As SldWorks.SketchSegment
                Set swSeg = varskSeg(segCtr)
                segType = swSeg.GetType
                Select Case segType
                    Case swSketchLINE
                        Dim swSegLine As SldWorks.SketchLine
                        Set swSegLine = swSeg
                        Debug.Print ("                  Segment type: Line")
                        Set swSegLine = Nothing
                    Case swSketchARC
                        Dim swSegArc As SldWorks.SketchArc
                        Set swSegArc = swSeg
                        Debug.Print ("                  Segment type: Arc")
                        Debug.Print ("                      Old radius: " & swSegArc.GetRadius)
                        Dim newRad As Double
                        newRad = swSegArc.GetRadius + 0.005
                        Debug.Print ("                      New radius: " & newRad)
                        swSegArc.SetRadius (newRad)
                        Set swSegArc = Nothing
                    Case Else
                        Debug.Print ("                  Segment type: Unknown")
                End Select
            Next segCtr
        End If
        inFeat.ModifyDefinition swFeatData, swDoc, Nothing
        swDoc.ClearSelection
    Else
        swFeatData.ReleaseSelectionAccess
    End If
   

    varskSeg = Empty
    Set swFeatData = Nothing
   

End Sub

 



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Get Broken-Out Section Feature Data Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2014 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.