AnsweredAssumed Answered

Need help with SW DM API for Where Used Functionality

Question asked by Vignesh N. on May 3, 2018
Latest reply on May 3, 2018 by Vignesh N.

Hi All ,


I have an issue with Where used function from Solidworks Document Manager API.


I try to fetch the drawing from the Part using where used function. But my return object is nothing.


Code :


Imports SolidWorks.Interop.swdocumentmgr

Imports System

Imports System.IO

Imports System.Diagnostics

Imports System.Collections.Generic

Imports System.Text

Public Class Form1



    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click





        Const sLicenseKey As String = "Lickey"

        Const sDocFileName As String = "C:\temp\Clone_Trail\Part1.SLDPRT"

        Dim dmClassFact As SwDMClassFactory

        Dim dmDocMgr As SwDMApplication3

        Dim dmDoc As SwDMDocument17

        Dim dmDoc2 As SwDMDocument17

        Dim nRetVal As SwDmDocumentOpenError

        Dim dmSearchOpt As SwDMSearchOption

        Dim dmExtRefOption As SwDMExternalReferenceOption

        Dim numExtRefs As Integer

        Dim value As System.Object







        dmClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory")

        dmDocMgr = dmClassFact.GetApplication(sLicenseKey)

        dmExtRefOption = dmDocMgr.GetExternalReferenceOptionObject

        dmSearchOpt = dmDocMgr.GetSearchOptionObject

        dmSearchOpt.SearchFilters = (SwDmSearchFilters.SwDmSearchForDrawing)







        dmDoc = dmDocMgr.GetDocument(sDocFileName, GetDocType(sDocFileName), False, nRetVal)

        value = dmDoc.WhereUsed(dmSearchOpt)

    End Sub



    Private Function GetDocType(ByVal name As String) As SwDmDocumentType

        Dim nDocType As SwDmDocumentType = SwDmDocumentType.swDmDocumentUnknown

        If name.EndsWith("SLDPRT") Then

            nDocType = SwDmDocumentType.swDmDocumentPart

        ElseIf name.EndsWith("SLDASM") Then

            nDocType = SwDmDocumentType.swDmDocumentAssembly

        End If





        Return nDocType

    End Function


Help is much appreciated !!!!


Vignesh N