AnsweredAssumed Answered

Solidworks PDM: Determine if file reference is external reference

Question asked by jason van clark on Apr 13, 2020
Latest reply on Apr 14, 2020 by Joshua Fredrickson

I am using the 'GetReferenceTree' method of the IEdmFile class to get the references for a given file and it is working well.  However, I would like to know if a given reference is an 'external reference' (i.e. a reference caused by an in-context feature).  Does anyone know if there is a way to determine this?  The applicable line in my example code below is line 31 and 32.  I'd like to add something to the effect of 'If parent is external reference then...'

Private Sub GetReferencedFiles(
    ByVal Reference As IEdmReference10,
    ByVal FilePath As String,
    ByVal Level As Integer,
    ByVal ProjectName As String,
    ByRef RefFilesDictionary _
    As Dictionary(Of String, List(Of String)),
    vault As IEdmVault20)

        Try
            Dim Top As Boolean = False
            If Reference Is Nothing Then
                'This is the first time this function is called for this
                'file reference tree; i.e., this is the root
                Top = True
                Dim File As IEdmFile5 = Nothing
                Dim ParentFolder As IEdmFolder5 = Nothing
                File = vault.GetFileFromPath(FilePath, ParentFolder)

                'Get the file reference tree for this file
                Reference = File.GetReferenceTree(ParentFolder.ID)


                'get the drawings for this file
                Dim pos2 As IEdmPos5
                pos2 = Reference.GetFirstParentPosition2(0, False, EdmRefFlags.EdmRef_File + EdmRefFlags.EdmRef_Item + EdmRefFlags.EdmRef_Dynamic + EdmRefFlags.EdmRef_Static)
                'pos2 = Reference.GetFirstParentPosition2(0, False, EdmRefFlags.EdmRef_Dynamic)
                Dim drawings As New List(Of String)
                While Not pos2.IsNull
                    Dim parent As IEdmReference7
                    parent = Reference.GetNextParent(pos2)
                    If parent.FoundPath.ToUpper.Contains(".SLDDRW") Then
                        drawings.Add(parent.FoundPath)
                    End If
                End While

Outcomes