×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

DocMgr API help - open, whereused, replacereference, save, close

DocMgr API help - open, whereused, replacereference, save, close

DocMgr API help - open, whereused, replacereference, save, close

(OP)
Hi. I am trying to write a stand-alone app that will replace references in an assembly and then save the doc and close it. I am having issues with replacing the references and then saving. here is some of my code:

For Each folder In My.Computer.FileSystem.GetDirectories(DIR)
            toolno = UCase(Microsoft.VisualBasic.Right$(folder, Len(folder) - (1 + Len(DIR))))
            i = -1
            For Each file In My.Computer.FileSystem.GetFiles(folder)
                filename = Microsoft.VisualBasic.Right$(file, Len(file) - (1 + Len(folder)))
                If UCase(filename) = "MAKETIFF" Or UCase(filename) = "HP1050CPRT" Then
                    My.Computer.FileSystem.DeleteFile(file)
                ElseIf UCase(Microsoft.VisualBasic.Left$(filename, 4)) = "BEAD" Then
                    i = i + 1
                    ReDim Preserve newname(i)
                    ReDim Preserve oldname(i)
                    newname(i) = toolno & "_" & filename
                    oldname(i) = file
                    swdoc = tapp.GetDocument(oldname(i), SwDocumentMgr.SwDmDocumentType.swDmDocumentUnknown, True, ie)
                    src = tapp.GetSearchOptionObject
                    src.AddSearchPath(folder)
                    If swdoc.WhereUsed(src) IsNot Nothing Then
                        assembly = swdoc.WhereUsed(src)
                    End If
                    swdoc.CloseDoc()
                    My.Computer.FileSystem.RenameFile(oldname(i), newname(i))
                    End If
            Next
            f = 0
            If i > -1 Then
                swdoc = tapp.GetDocument(assembly(0), SwDocumentMgr.SwDmDocumentType.swDmDocumentUnknown, True, ie)
                src = tapp.GetSearchOptionObject
                src.AddSearchPath(folder)
                Do Until f = i + 1
                    Call swdoc.ReplaceReference(oldname(f), folder & "\" & newname(f))
                    f = f + 1
                Loop
                i = 0

                saved = swdoc.Save()
                swdoc.CloseDoc()
            End If
        Next


any help is greatly appreciated.
Brad

RE: DocMgr API help - open, whereused, replacereference, save, close

bOILERbRAD,
I do not know the answer to your question.
Are you using SolidWorks Document Manager API SDK, which requires an access key?
 

Standing
SolidWorks Pro 2009 x64, SP3.0, PDMWorks Workgroup, SolidWorks BOM,
HP xw8600, 64-bit Windows Vista Business, Service Pack 1
Intel Xeon CPU, 3.00 GHz, 16 GB RAM, Virtual memory 166682 MB, nVidia Quadro FX 4600

RE: DocMgr API help - open, whereused, replacereference, save, close

I think when you replace a reference with SWDM, the change is automatically saved.  You do not need to open-save-close.

RE: DocMgr API help - open, whereused, replacereference, save, close

(OP)
Thanks for your quick replies.

Standing,
Yes I am using the Document Manager SDK (I have a key).

Tick,
If I do not open the part with the SWDM, how does VB know in which part references are to be replaced?  

RE: DocMgr API help - open, whereused, replacereference, save, close

(OP)
I got it figured out. Apparently the refrences are case sensitive... DOH!

Thanks for your help anyways!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources