Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Issue with MultiValue.List working in other documents

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
sean.boyle77X79
364 Views, 5 Replies

Issue with MultiValue.List working in other documents

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


5 REPLIES 5
Message 2 of 6
A.Acheson
in reply to: sean.boyle77X79

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
Message 3 of 6
sean.boyle77X79
in reply to: A.Acheson

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

Message 4 of 6
A.Acheson
in reply to: sean.boyle77X79

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
Message 5 of 6
sean.boyle77X79
in reply to: A.Acheson

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

 

 

Message 6 of 6
sean.boyle77X79
in reply to: A.Acheson

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.

Post to forums  

Autodesk Design & Make Report