
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Solved! Go to Solution.