Hide Table of Contents

Create Section View in Model Example (VB.NET)

This example shows how to create a section view in a model.

' Preconditions: Open:
'    install_dir\samples\tutorial\multibody\multi_bridge.sldprt.
' Postconditions: The graphics area displays the section view with
' three sections that are capped in color.

' NOTE: Because the model is used elsewhere,
' do not save changes when closing it.
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics

Partial Class SolidWorksMacro

Dim swModel As ModelDoc2
Dim swModelDocExt As ModelDocExtension
Dim swModelViewMgr As ModelViewManager
Dim swSelMgr As SelectionMgr
Dim svData As SectionViewData
Dim plane1 As Feature, plane2 As Feature, plane3 As Feature
Dim boolstatus As Boolean

    Sub main()

        swModel = swApp.ActiveDoc
        swModelDocExt = swModel.Extension
        swModelViewMgr = swModel.ModelViewManager

        swSelMgr = swModel.SelectionManager

        boolstatus = swModelDocExt.SelectByID2(
"Front", "PLANE", -0.04751707843116, 0.04466659468449, 0.1209999999999, False, 1, Nothing, 0)
        boolstatus = swModelDocExt.SelectByID2(
"Top", "PLANE", -0.06781533387408, 0.00100317525596, 0.1263684575364, True, 2, Nothing, 1)
        boolstatus = swModelDocExt.SelectByID2(
"Right", "PLANE", -0.000808330303073, 0.07304457560201, -0.003890984556108, True, 4, Nothing, 1)

        svData = swModelViewMgr.CreateSectionViewData()
        FillPlaneData(svData, swSelMgr)

        boolstatus = swModelViewMgr.CreateSectionView(svData)
" Section bodies are valid: " & boolstatus)

End Sub

    Sub FillPlaneData(ByVal data As SectionViewData, ByVal selMgr As SelectionMgr)

        plane1 = selMgr.GetSelectedObject6(1, 0)
        plane2 = selMgr.GetSelectedObject6(2, 0)
        plane3 = selMgr.GetSelectedObject6(4, 0)

        data.FirstPlane = plane1
        data.FirstReverseDirection =
        data.FirstOffset = -0.01
        data.FirstRotationX = 0.296705972839036
        data.FirstRotationY = 0.174532925199433
        data.FirstColor = RGB(255, 0, 0)

        data.SecondPlane = plane2
        data.SecondReverseDirection =
        data.SecondOffset = 0.01
        data.SecondRotationX = 0.296705972839036
        data.SecondRotationY = 0.174532925199433
        data.SecondColor = RGB(0, 255, 0)

        data.ThirdPlane = plane3
        data.ThirdReverseDirection =
        data.ThirdOffset = -0.01
        data.ThirdRotationX = 0.296705972839036
        data.ThirdRotationY = 0.174532925199433
        data.ThirdColor = RGB(0, 0, 255)

        data.Redraw =
        data.ShowSectionCap = True
        data.KeepCapColor = True

    End Sub

    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

Subject:   Feedback on Help Topics
Page:   Create Section View in Model Example (VB.NET)
*   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:


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

Web Help Content Version: API Help (English only) 2013 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.