- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Resolving drawing links with new model states
Hi,
After converting a factory part to a model state part, the drawing links need to be resolved. Is there a best way to do this? I'm able to resolve links within the models themselves but I don't have a lot of experience coding within drawings. Below is close to the code that I use to resolve the assembly links. That I tried to change to work with drawings but doesn't work.
DWG = ThisDoc.PathAndFileName(False) & ".IDW" Dim odraw = ThisApplication.Documents.Open(DWG, True) Dim Path As String Dim Filename As String Dim FilenameBase As String Dim FullFileName As String Dim Resolvedfile As String Dim FilenameWithoutExt As String Dim FilenameWithMS As String For Num = 1 To 9 Dim oFD As FileDescriptor oFD = odraw.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor Path = ThisDoc.Path FullFileName = ThisDoc.PathAndFileName(True) ' MessageBox.Show(FullFileName, "FullFileName") FilenameBase = Right$(FullFileName, Len(FullFileName) -InStrRev(FullFileName, "\")) ' MessageBox.Show(FilenameBase, "FileNameBase") Extension = Right(FilenameBase, 4) ' MessageBox.Show(Extension, "Extension") FilenameWithoutExt = Replace(FilenameBase, Extension, "") ' MessageBox.Show(FilenameWithoutExt, "FilenameWithoutExt") Filename = (FilenameWithoutExt & "-0" & Num & Extension) ' MessageBox.Show(Filename, "Filename") FilenameWithMS = FilenameBase & "<" & FilenameWithoutExt & "-0" & Num & ">" ' MessageBox.Show(FilenameWithMS, "FilenameWithMS") Resolvedfile = Path & FilenameWithMS ' MessageBox.Show(Resolvedfile, "Resolvedfile") If oFD.FullFileName = Filename Then oFD.ReplaceReference(Resolvedfile) End If Next odraw.Update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
In the line
Resolvedfile = Path & FilenameWithMS
a backslash is missing
Resolvedfile = Path & "\" & FilenameWithMS
The line
If oFD.FullFileName = Filename Then
compares a FullFileName (with path) with a Filename (without path). This will never be true.
Should be?:
If oFD.FullFileName = Path & "\" & Filename Then
Is there any error message or does still happen nothing?
AFAIK the ReplaceReference method requires a FullFileName. The FullFileName did not contain the model state in brackets. I think this part of the filename will be ignored.
ModelStates are all saved within one part document. There's no difference in the filename. How did you create the model state files? Have you created one file per model state, which is not the way it should be? It's a bit unclear what you've done and i'm slightly confused. ![]()
Is it possible to post one drawing, the old factory file and the new corresponding model state file? Or can you show the code for resolve the files in your assembly?
R. Krieg
RKW Solutions
www.rkw-solutions.com