Hide Table of Contents

Pack and Go Part and Linked Equation (VB.NET)

This example shows how to determine if a part document includes any equations and whether those equations are linked files. The example also shows how to add the part document and any linked equations to Pack and Go.

'----------------------------------------
' Preconditions:
' 1. Specified part and equation documents
'    (microphonehousing.sldprt and equations.txt)
'    exist.
' 2. c:\temp exists.
' 3. Open the Immediate window.
'
' Postconditions:
' 1. Specified part document is opened.
' 2. Part and linked equation documents
'    are added to Pack and Go and copied to
'    c:\temp.
' 3. To verify, examine c:\temp.
'
' NOTE: Because the model is used elsewhere,
' do not save any changes made to it.
'-----------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System
Imports System.Diagnostics

Partial Class SolidWorksMacro

    
Public Sub Main()

        
Dim swModel As ModelDoc2
        
Dim swModelDocExt As ModelDocExtension
        
Dim swEqnMgr As EquationMgr
        
Dim swPackAndGo As PackAndGo
        
Dim fileName As String
        Dim errors As Integer
        Dim warnings As Integer
        Dim i As Integer
        Dim nCount As Integer
        Dim eqnLinked As Boolean
        Dim pgFileNames As Object
        Dim status As Boolean
        Dim statuses As Object
        Dim myPath As String


        fileName = "C:\Program Files\SolidWorks Corp\SolidWorks\samples\tutorial\api\microphonehousing.sldprt"
        swModel = swApp.OpenDoc6(fileName, swDocumentTypes_e.swDocPART, swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, warnings)
        swModelDocExt = swModel.Extension
        Debug.Print(
"File = " & swModel.GetPathName)
        Debug.Print(
" ")

        
' Get Equation manager object
        swEqnMgr = swModel.GetEquationMgr

        
' List the equations, get whether they're linked
        ' to files, and get the paths where they're stored
        nCount = swEqnMgr.GetCount
        
For i = 0 To nCount - 1
            Debug.Print(
"  Equation #" & i & " = " & swEqnMgr.Equation(i))

            eqnLinked = swEqnMgr.LinkToFile
            Debug.Print(
"  Equation linked to file? " & eqnLinked)

            
If eqnLinked Then
                Debug.Print("  Path and filename of linked equation: " & swEqnMgr.FilePath)
            
End If
        Next i

        Debug.Print(
" ")

        
' Get Pack and Go object
        Debug.Print("  Pack and Go")
        swPackAndGo = swModelDocExt.GetPackAndGo

        
' Get current paths and filename of the documents
        status = swPackAndGo.GetDocumentNames(pgFileNames)
        Debug.Print(
"    Add these SolidWorks files to Pack and Go: ")
        
If Not pgFileNames Is Nothing Then
            For i = 0 To UBound(pgFileNames)
                Debug.Print(
"      The file to pack up is: " & pgFileNames(i))
            
Next i
        
End If

        ' Set document paths and names for Pack and Go
        status = swPackAndGo.SetDocumentSaveToNames(pgFileNames)

        
' Override path where to save documents
        myPath = "c:\temp\"
        status = swPackAndGo.SetSaveToName(True, myPath)

        
' Pack and Go both SolidWorks and non-SolidWorks files
        statuses = swModelDocExt.SavePackAndGo(swPackAndGo)

    
End Sub

    ''' <summary>
    ''' The SldWorks swApp variable is pre-assigned for you.
    ''' </summary>
    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

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Pack and Go Part and Linked Equation (VB.NET)
*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) 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.