Hide Table of Contents

Create Section View in Model Example (VBA)

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

'---------------------------------------------------------------------------
' Precondition: Open:
'    install_dir\samples\tutorial\multibody\multi_bridge.sldprt
'
' Postcondition: The graphics area displays a section view with
'                three sections that are capped in color.

' NOTE: Because the model is used elsewhere, do not save changes.
'----------------------------------------------------------------------------
Option Explicit

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

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swModelDocExt = swModel.Extension
    Set swModelViewMgr = swModel.ModelViewManager

    Set 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)
   

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

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

End Sub

Sub FillPlaneData(data As SectionViewData, selMgr As SelectionMgr)
   

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

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

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

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

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

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:   Create Section View in Model 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.