Hide Table of Contents

Set Independent Viewport for MBD 3D PDF Example (VBA)

This example shows how to set a view for an independent viewport for a SOLIDWORKS MBD 3D PDF.

'--------------------------------------------------------------
' Preconditions:
' 1. Open an assembly.
' 2. Copy install_dir\data\themes\simple assembly (letter, landscape) to
'    C:\test\simple assembly (letter, landscape).
' 3. In SOLIDWORKS, click the SOLIDWORKS MBD toolbar > 3D PDF Template Editor.
'    a. Click Independent Viewport.
'    b. Click Save As.
'    c. Ensure that Theme Directory is C:\test\simple assembly (letter, landscape).
'    d. Type AllViews in Name.
'    e. Click Save.
'    f. Close the 3D PDF Template Editor.
'
' Postconditions:
' 1. Gets the MBD3DPdfData object.
' 2. Sets the path and file name for the SOLIDWORKS MBD 3D PDF.
' 3. Sets to display SOLIDWORKS MBD 3D PDF after publishing.
' 4. Sets the theme for the SOLIDWORKS MBD 3D PDF.
' 5. Sets the view to display in the independent viewport
'    for the SOLIDWORKS MBD 3D PDF.
' 6. Creates and displays MBDPart1.PDF.
' 7. Examine MBDPart1.PDF.
'---------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swMBDPdfData As SldWorks.MBD3DPdfData

Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swModelDocExt = swModel.Extension    
    'Get MBD3DPdfData object
    Set swMBDPdfData = swModelDocExt.GetMBD3DPdfData    
    'Set path and file name for SOLIDWORKS MBD 3D PDF
    swMBDPdfData.FilePath = "C:\temp\MBDPart1.PDF"    
    'Display SOLIDWORKS MBD 3D PDF
    swMBDPdfData.ViewPdfAfterSaving = True    
    'Set SOLIDWORKS MBD 3D PDF theme
    swMBDPdfData.ThemeName = "C:\test\simple assembly (letter, landscape)\AllViews\theme.xml"    
    'Set view for AllViews
    swMBDPdfData.SetIndependentViewPort "*Top"    
    'Create SOLIDWORKS MBD 3D PDF
    swModelDocExt.PublishTo3DPDF swMBDPdfData    
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:   Set Independent Viewport for MBD 3D PDF 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) 2024 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.