Example to Retrieve ALL reference files from PDMWorks WorkGroup

I am starting to write some code that can retrieve all the reference files of an Assembly.  I can retrieve the first leave, but my problem is, what about the subassy's and its references and the subassy's under that.  It's looking to me that I have to continue writing code for all the references and this does not seem right.  There has to be a better way.  Can someone help me?

Here is what I have so far...

Dim

connection As PDMWConnection

Dim References As PDMWLinks

Dim reference As PDMWLink

Dim myAssyDoc As PDMWDocument

Dim x As Integer

Dim myPart As PDMWDocument

Dim wasAssyCopied As Integer

Dim wasPartCopied As Integer

Dim subRef As PDMWLink

Dim subRefs As PDMWLinks

connection = CreateObject(

"PDMWorks.PDMWConnection")

connection.Login(

"pdmwadmin", "pdmwadmin", "localhost")

myAssyDoc = connection.GetSpecificDocument(frmMain.lbxWhereUsed.Items.Item(x))

wasAssyCopied = myAssyDoc.Save(

"C:\local_working_directory")

References = myAssyDoc.References

For Each reference In References

Debug.Print(reference.Name)

If LCase(Right(reference.Name, 6)) = "sldasm" Then

myPart = connection.GetSpecificDocument(reference.Name)

wasPartCopied = myPart.Save(

"C:\local_working_directory")

subRefs = myPart.References

For Each subRef In subRefs

Debug.Print(subRef.Name)

Next

ElseIf LCase(Right(reference.Name, 6)) = "sldprt" Then

myPart = connection.GetSpecificDocument(reference.Name)

If Not myPart.Name.ToUpper = frmMain.txtpartnumber.Text.ToUpper + ".sldprt".ToUpper Then

myPart = connection.GetSpecificDocument(reference.Name)

wasPartCopied = myPart.Save(

"C:\local_working_directory")

End If

ElseIf LCase(Right(reference.Name, 6)) = "slddrw" Then

myPart = connection.GetSpecificDocument(reference.Name)

wasPartCopied = myPart.Save(

"C:\local_working_directory")

End If

Next

connection.Logout()

Rodney

SolidworksApi macros