Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

bOILERbRAD

Mechanical
Aug 11, 2008
17
0
0
US
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
 
Replies continue below

Recommended for you

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
 
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?
 
Status
Not open for further replies.
Back
Top