Set Independent Viewport for MBD 3D PDF Example (VB.NET)
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.
'---------------------------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Partial Class SolidWorksMacro
Public Sub main()
Dim swModel As ModelDoc2
Dim swModelDocExt As ModelDocExtension
Dim swMBDPdfData As MBD3DPdfData
swModel = swApp.ActiveDoc
swModelDocExt = swModel.Extension
'Get MBD3DPdfData object
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
''' <summary>
''' The SldWorks swApp variable is pre-assigned for you.
''' </summary>
Public swApp As SldWorks
End Class