ilogic change source of linked ipt

ilogic change source of linked ipt

Darrell.johnson
Enthusiast Enthusiast
749 Views
4 Replies
Message 1 of 5

ilogic change source of linked ipt

Darrell.johnson
Enthusiast
Enthusiast

Hi everybody,

 

i found this post:

 

https://forums.autodesk.com/t5/inventor-customization/ilogic-change-source-of-embeded-excel-sheet/m-...

 

Is it possible to change the source of linked inventor parts (.ipt) in a simialar way?

 

0 Likes
Accepted solutions (1)
750 Views
4 Replies
Replies (4)
Message 2 of 5

machiel.veldkamp
Collaborator
Collaborator

Do you mean derived components?

 

Try this:

 

 

Dim oDoc as Document
oDoc = ThisDoc.Document
Dim oRefFile As FileDescriptor
Dim oOrigRefName As Object
Dim selectedfile As String

For Each oRefFile In oDoc.File.ReferencedFileDescriptors
	'get the full file path to the original internal ref3erences
	oOrigRefName = oRefFile.FullFileName

	'present a File Selection dialog
	Dim oFileDlg As Inventor.FileDialog = Nothing
	InventorVb.Application.CreateFileDialog(oFileDlg)
	oFileDlg.InitialDirectory = oOrigRefName
	oFileDlg.CancelError = True
	On Error Resume Next
	oFileDlg.ShowOpen()
	If Err.Number <> 0 Then
		MessageBox.Show("1", "Title")

		Return
	ElseIf oFileDlg.FileName <> "" Then
		

		selectedfile = oFileDlg.FileName
		MessageBox.Show(selectedfile, "Title")
	End If

	'replace the reference
	oRefFile.ReplaceReference(selectedfile)
	
	InventorVb.DocumentUpdate()
	oOrigRefName = ""
Next

iLogicVb.UpdateWhenDone = True

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

___________________________
Message 3 of 5

Darrell.johnson
Enthusiast
Enthusiast

I want to change the marked path via iLogic.

 

Anmerkung 2019-07-25 115822.png

0 Likes
Message 4 of 5

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, is this what you need?

 

Dim oFileDlg As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "Inventor Files (*.iam;*.ipt)|*.iam;*.ipt|All Files (*.*)|*.*"
oFileDlg.DialogTitle = "Select a File"
oFileDlg.InitialDirectory = ThisDoc.Path
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If oFileDlg.FileName = "" Then Exit Sub
selectedfile = oFileDlg.FileName

 doc = ThisDoc.Document
 Dim oFD As FileDescriptor
 oFD = doc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor
 oFD.ReplaceReference(selectedfile)
 doc.Update()

 I hope it helps solve your problem. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 5 of 5

Darrell.johnson
Enthusiast
Enthusiast

This is exactly what I needed. Thank you very much 



 

0 Likes