- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have the code below to open a part that's gets his name from a multivalue text parameter.
The partnames are collected from the assembly components.
I could not get these names with .ipt extension , so I have to add this myself as you can see in the code below.
It works but is not perfect and will fail when more than 9 the same occurrences are present in the assembly.
Next problem is that to open the file I have to define also the complete path of that file.
This is also a problem , because Inventor should be able to find the parts anywhere in the workspace... to often the code will fail otherwise.
Does anyone has any suggestions to improve the code below?
Thank you in advance
PS: don't worry about the messageboxes popping up, they are just acting as a logger for the time being
'get user input oSelection = Parameter("ActiveParts") 'catch null selection If oSelection = "" Then Return 'exit rule Else 'set parameter value Parameter("ActiveParts") = oSelection End If Dim doc As Document = ThisApplication.ActiveDocument 'provide user feedback MessageBox.Show("You selected: " & oSelection, "iLogic") NewName = Left(oSelection,(Len(oSelection)-2))' NOT GOOD!!, if more then 9 occurences in the assembly this will fail MessageBox.Show("I found variable: " & NewName , "Info") oFullFileName = (NewName & ".ipt") MessageBox.Show("I found variable: " & oFullFileName , "Info") oPath = ThisDoc.WorkspacePath() MessageBox.Show("I found variable: " & oPath , "Info") ThisDoc.Launch(oPath & "\parts\S_MountingPlates\S_MountingPlates_L\" & oFullFileName) ' NoT Good!!! location can change, 'Inventor has to search everywhere in workspace not only the given location.
Solved! Go to Solution.