
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm wanting to link one assembly's parameters to another, but with an option to change which one it is linked to. Normally i would just link the parameters directly, but when it comes to changing which assembly it is linked to, I can't find a way of changing it without linking it to a new file, then manually going through all the paramaters and sticking a "_1" on the end.
So i've thougth of another idea. I'm thinking to browse to the assembly i am wanting to liknk my parameters to, and if there is a user parameter that matches one in the active document, then set it to the linked assembly's parameter? Here is my attempt, but nothing seems to happen... I can't seem to get the parameters from the selected file. Can anyone advise where i've messed up, or if there is a better way of trying to acheive what i am trying to do.
SyntaxEditor Code Snippet
'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 On Error Resume Next oDoc = ThisApplication.Documents.ItemByName(selectedfile) If Err.Number <> 0 Then oDoc = ThisApplication.Documents.Open(selectedfile, False) _DocOpened = True MessageBox.Show("Must Select an Assembly File", "Error") End If On Error Goto 0 Dim oOcc As AssemblyDocument = ThisDoc.Document Dim oCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition Dim oUserParams As UserParameters = oCompDef.Parameters.UserParameters For Each oParam In oUserParams 'Parameter.Quiet = True Parameter(oOcc,oParam.Name) = Parameter(oDoc,oParam.Name) Next If _DocOpened = True oDoc.Close End If
Solved! Go to Solution.