Hi, please would someone be able to help me. I have an assembly document, and inside this assembly my code needs to open up other documents, and convert the contents from a multivalue list parameter inside of said docs, to a list in the code.
So I'm using MultiValue.List to do this, the List portion says that you can use a doc name to specify which assembly to read the values from, but for some reason it always reads from the assembly it's being run in. It does however work if you change the doc name to a tree name, but seeing as the doc can be inside an unknown amount of assemblies down in the main doc, I would prefer to use the file name to identify it.
I will paste my code below, is the function potentially broken or an I missing something? Any help would be greatly appreciated! Thanks
Dim asmDoc As AssemblyDocument = ThisApplication.Documents.ItemByName("C:\DOVAULT\1. Projects\0000420420-69 - Sheamus Astroneering LLC\6. Drawings\0000420420-69-2.000-Column CL01.iam") Dim asmOpen As Document = ThisApplication.Documents.Open("C:\DOVAULT\1. Projects\0000420420-69 - Sheamus Astroneering LLC\6. Drawings\0000420420-69-2.000-Column CL01.iam", True) Dim revisionCommentHistoryList As New List(Of String) For Each item In MultiValue.List(asmDoc, "revisionCommentHistory") revisionCommentHistoryList.Add(item) Next MessageBox.Show("Drawings:" & vbCrLf & "" & vbCrLf & String.Join(vbCrLf, revisionCommentHistoryList.ToArray()), "test")
Solved! Go to Solution.
Solved by A.Acheson. Go to Solution.
I would prefer to use the Inventor API for this operation. As you have already learned targeting the correct object through the ilogic API can be difficult and it doesn't give much indication of what is going on.
See sample.
Dim revisionCommentHistoryList As New List(Of String)
revisionCommentHistoryList.Clear
Dim def As PartComponentDefinition = ThisDoc.Document.ComponentDefinition
Dim userparam As UserParameter = def.Parameters.UserParameters.Item("revisionCommentHistory")
Dim expresList As ExpressionList = userparam.ExpressionList
For Each item In expresList
revisionCommentHistoryList.Add(item)
Next
d0 = InputListBox("Prompt", revisionCommentHistoryList, d0, Title := "Title", ListName := "List")
Thank you this works very well. I've noticed in a lot of situations the Inventor API is a lot more consistent than the iLogic one, that's a lesson for the future
Yes these ilogic API snippets can be difficult to target. If you look at the help page here for this one it suggests the following.
Parameters componentOrDocName Type: System.Object
The name of the component occurrence or document. I usually tackle these using the filename picked up using System.IO Method. Then you can work from the document itself rather than occurrence. Using the document display name doesn't always work because the occurrence name may not match.
Dim fileName as string = IO.Path.GetFileName(".....filename")
MultiValue.List(fileName, "revisionCommentHistory")
d0 = InputListBox("Prompt", MultiValue.List(fileName, "revisionCommentHistory"), d0, Title := "Title", ListName := "List")
Would you happen to know how to repopulate the revisonCommentHistory Multi-Value list parameter? The intention for this snippet is to extact the values from the parameter multivalue list, into the New List in the code called revisionCommentHistoryList, it then adds a new value to this list. And it should then repopulate the revisionCommentHistory Multi-Value list with the items from the code list.
I'm trying to use the ExpressionList.SetExpressionList however I think I'm writing it wrong
I found the solution, the values in the list have to have triple quotation marks from some reason, so like this """Value 1""", """Value 2""" etc
Can't find what you're looking for? Ask the community or share your knowledge.