ilogic replace reference file in drawing when opened invisible

ilogic replace reference file in drawing when opened invisible

Anonymous
Not applicable
974 Views
2 Replies
Message 1 of 3

ilogic replace reference file in drawing when opened invisible

Anonymous
Not applicable

Hi all,

 

I have a piece of code that should replace a file reference in a drawing. 

This is done by first looking if a drawing exists, and when it does i save the drawing under a different name.

Next i want to replace the file reference to make the drawing represent another model. 

The problem is when i open a drawing invisible the reference is not replaced.

When the the drawing is opened visible the reference replace does work.

the problem is that when i open a drawing visible it has to load all the graphics and i get some pop-up messages if i want to modify the file and i don't want any input when the process is running.

 

I checked all the paths and everything is running as it should. 

 

Function DrawingReplace(OldLoc As String, newname As String)
Dim OldName As String = Left(OldLoc, Len(OldLoc) -3) & "dwg"
Dim DrawDoc As DrawingDocument = ThisApplication.Documents.Open(OldName, False)

Dim DrawingName As String = (Left(newname, Len(newname) -3) & "dwg")

If Dir((Left(newname, Len(newname) -3) & "dwg")) = "" Then
DrawDoc.SaveAs(DrawingName, False)
End If

Dim oFD As FileDescriptor
 oFD = DrawDoc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor
  oFD.ReplaceReference(newname)
Dim oControlDef As ControlDefinition  = ThisApplication.CommandManager.ControlDefinitions.Item("UpdateCopiedModeliPropertiesCmd")
oControlDef.Execute

 
 DrawDoc.Update()

DrawDoc.Close

End Function

Kind regards, 

 

Geert

0 Likes
Accepted solutions (1)
975 Views
2 Replies
Replies (2)
Message 2 of 3

omartin
Advocate
Advocate
Accepted solution

Hey Geert, seems like it should be working only thing is, after you do the replace ref I don't see you saving the drawing before close.

Was my reply Helpful ? send a Kudos or accept as solution
0 Likes
Message 3 of 3

Anonymous
Not applicable

Haha, thank you!

could not imagine the solution would be this simple.

 

download.jpeg

0 Likes