Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic replace reference file in drawing when opened invisible

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
837 Views, 2 Replies

ilogic replace reference file in drawing when opened invisible

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

2 REPLIES 2
Message 2 of 3
omartin
in reply to: Anonymous

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
Message 3 of 3
Anonymous
in reply to: omartin

Haha, thank you!

could not imagine the solution would be this simple.

 

download.jpeg

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report