Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
a81383
208 Views, 1 Reply

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