Issue with MultiValue.List working in other documents

Issue with MultiValue.List working in other documents

sean.boyle77X79
Contributor Contributor
476 Views
5 Replies
Message 1 of 6

Issue with MultiValue.List working in other documents

sean.boyle77X79
Contributor
Contributor

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")


0 Likes
Accepted solutions (1)
477 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor
Accepted solution

Hi @sean.boyle77X79 

 

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")

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 6

sean.boyle77X79
Contributor
Contributor

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

0 Likes
Message 4 of 6

A.Acheson
Mentor
Mentor

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")

 

 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 6

sean.boyle77X79
Contributor
Contributor

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

 

 

0 Likes
Message 6 of 6

sean.boyle77X79
Contributor
Contributor

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

0 Likes