derived part - change source?

derived part - change source?

mslosar
Advisor Advisor
1,127 Views
3 Replies
Message 1 of 4

derived part - change source?

mslosar
Advisor
Advisor

Can this be done in ilogic or vb? I have someone here who wants to be able to use the code to be able to switch the source file in a derive part. I know copy design does exactly this in vault. Their department at this time does not have vault and it's unknown if they'll ever get it.

0 Likes
Accepted solutions (1)
1,128 Views
3 Replies
Replies (3)
Message 2 of 4

Jesper_S
Collaborator
Collaborator
Accepted solution

Hi.

 

Try this.

 

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

For Each oRefFile In oDoc.file.ReferencedFileDescriptors
'get the full file path to the original internal references
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
Return
ElseIf oFileDlg.FileName <> "" Then
selectedfile = oFileDlg.FileName
End if

‘replace the reference
oRefFile.ReplaceReference (selectedfile)     
InventorVb.DocumentUpdate()
oOrigRefName = “”                                        
Next

iLogicVb.UpdateWhenDone = True

//Jesper


//Jesper

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

mslosar
Advisor
Advisor

I'll give it a try, thanks. 🙂

0 Likes
Message 4 of 4

NorthernCADMonkey
Enthusiast
Enthusiast

I know this is a old thread, but 

 

I have been using this on previous versions of IV, but we just upgraded to 2023 and now it does not work.

 

The rule runs, but when I get to point to select a replacement for the derived part everything is blank except for the folders. I can not see any ipt files.

 

Could this be because of model states? 

 

Does anyone know a fix for this.

 

Thaanks

IVPro 2025
Vault Pro 2025
0 Likes