Hide Table of Contents

Get Section View Data Example (VB.NET)

This example shows how to get the data for a section view in a part.

'-------------------------------------------------------------------------
' Preconditions:
' 1. Open install_dir\samples\tutorial\cosmosxpress\aw_rubber_duct.sldprt.
' 2. Create a section view with three sections:
'    a. Right-click Front in the FeatureManager design tree
'       and click Section View.
'    b. Set X Rotation to 45.00deg in Section 1.
'    c. Select Section 2, click Top, and
'       set X Rotation to 45.00deg.
'    d. Select Section 3, click Right, and
'       set X Rotation to 45.00deg.
'    e. Click Save twice.
' 3. Click View > Display > Section View twice.
' 4. Open the Immediate window.
'
' Postconditions:
' 1. Gets and prints data about each section in
'    the section view to the Immediate window.
' 2. Examine the Immediate window.
'
' NOTE: Because the part is used elsewhere, do not save changes.
'------------------------------------------------------------------------

Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics
 
Partial Class SolidWorksMacro
 
    Public Sub main()
 
        Dim swModel As ModelDoc2
        Dim swModelViewMgr As ModelViewManager
        Dim swSectionViewData As SectionViewData
        Dim swSelMgr As SelectionMgr
        Dim status As Boolean
 
        swModel = swApp.ActiveDoc
        swSelMgr = swModel.SelectionManager

        'Get section view
        swModelViewMgr = swModel.ModelViewManager
        swSectionViewData = swModelViewMgr.GetSectionViewData("")

        DisplayDebugInformation(swSectionViewData, swSelMgr)

        swModel.ClearSelection2(True)
 
    End Sub
 
    'Select the planes and print each section's data
    Sub DisplayDebugInformation(ByVal data As SectionViewData, ByVal selMgr As SelectionMgr)
        Dim p1 As Feature
        Dim p2 As Feature
        Dim p3 As Feature
        Dim swMathTransform As MathTransform
        Dim transform As Object
 
        p1 = data.FirstPlane
        If Not p1 Is Nothing Then p1.Select2(True, 1)
        p2 = data.SecondPlane
        If Not p2 Is Nothing Then p2.Select2(True, 2)
        p3 = data.ThirdPlane
        If Not p3 Is Nothing Then p3.Select2(True, 4)
 
        Debug.Print("----------Section 1----------")
        Debug.Print("Offset: " & data.FirstOffset)
        Debug.Print("Rotation X: " & data.FirstRotationX)
        Debug.Print("Rotation Y: " & data.FirstRotationY)
        Debug.Print("Color: " & data.FirstColor)
        Debug.Print("Reverse direction: " & data.FirstReverseDirection)
        Debug.Print("----------Section 2----------")
        Debug.Print("Offset: " & data.SecondOffset)
        Debug.Print("Rotation X: " & data.SecondRotationX)
        Debug.Print("Rotation Y: " & data.SecondRotationY)
        Debug.Print("Color: " & data.SecondColor)
        Debug.Print("Reverse direction: " & data.SecondReverseDirection)
        Debug.Print("----------Section 3----------")
        Debug.Print("Offset: " & data.ThirdOffset)
        Debug.Print("Rotation X: " & data.ThirdRotationX)
        Debug.Print("Rotation Y: " & data.ThirdRotationY)
        Debug.Print("Color: " & data.ThirdColor)
        Debug.Print("Reverse direction: " & data.ThirdReverseDirection)
        swMathTransform = data.GetDynamicCenterTransform(3)
        Debug.Print("Dynamic center transform:")
        transform = swMathTransform.ArrayData()
        If Not IsNothing(transform) Then
            Debug.Print("  Rotate: " & Format(transform(0), "###0.0#####") & " " & Format(transform(1), "###0.0#####") & " " & Format(transform(2), "###0.0#####"))
            Debug.Print("          " & Format(transform(3), "###0.0#####") & " " & Format(transform(4), "###0.0#####") & " " & Format(transform(5), "###0.0#####"))
            Debug.Print("          " & Format(transform(6), "###0.0#####") & " " & Format(transform(7), "###0.0#####") & " " & Format(transform(8), "###0.0#####"))
            Debug.Print("  Translate: " & Format(transform(9), "###0.0#####") & " " & Format(transform(10), "###0.0#####") & " " & Format(transform(11), "###0.0#####"))
        End If
        Debug.Print("----------Section Cap---------")
        Debug.Print("Show section cap: " & data.ShowSectionCap)
 
    End Sub
 
    ''' <summary>
    ''' The SldWorks swApp variable is pre-assigned for you.
    ''' </summary>
    Public swApp As SldWorks
 
 
End Class


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 Section View Data Example (VB.NET)
*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) 2015 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.