Hide Table of Contents

Create Section View at Specified Location Example (VBA)

This example shows how to create a section view at a specified location.

'-------------------------------------------------------------------
' Preconditions: Open public_documents\samples\tutorial\advdrawings\foodprocessor.slddrw.
'
' Postconditions:
' 1. Creates a section view created at the specified location.
' 2. Examine the graphics area.
'--------------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swDrawing As SldWorks.DrawingDoc
Dim vChildComponents As Variant
Dim swFirstDrawingView As SldWorks.View
Dim swDrawingView As SldWorks.View
Dim swDrRootComponent As SldWorks.DrawingComponent
Sub main()
    Set swApp = Application.SldWorks
    Set swDrawing = swApp.ActiveDoc
    If swDrawing Is Nothing Then
        MsgBox "There is no active document"
        Exit Sub
    End If
    ' Always returns the drawing sheet first
    Set swFirstDrawingView = swDrawing.GetFirstView
    ' Get first drawing view
    Set swDrawingView = swFirstDrawingView.GetNextView
    ' Get  root drawing component
    Set swDrRootComponent = swDrawingView.RootDrawingComponent
    Dim iChild As Long
    If swDrRootComponent.GetChildrenCount > 0 Then
        vChildComponents = swDrRootComponent.GetChildren
        For iChild = 0 To UBound(vChildComponents)
        Next iChild
    End If
    ' Select the drawing view and create line for the section view
    Dim boolstatus As Boolean
    boolstatus = swDrawing.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, swSelectOptionDefault)
    swDrawing.ClearSelection2 True
    swDrawing.CreateLine2 0.091354, 0.284441, 0#, 0.253455, 0.140062, 0#    
    ' Set arguments for call to create section view
    Dim x As Double, y As Double, z As Double
    Dim notAligned As Boolean, isOffsetSection As Boolean, chgdirection As Boolean, scwithmodel As Boolean, partial As Boolean, dispsurfcut As Boolean
    Dim label As String
    Dim sectionView As SldWorks.View
    x = 0.65
    y = 0.08908737704918
    z = 0
    notAligned = False
    isOffsetSection = False
    chgdirection = False
    scwithmodel = False
    partial = False
    dispsurfcut = False
    label = "A"
    ' Create section view
    Set sectionView = swDrawing.CreateSectionViewAt3(x, y, z, notAligned, isOffsetSection, label, chgdirection, scwithmodel, partial, dispsurfcut, (vChildComponents))
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 at Specified Location 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) 2020 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.