iProperty with pull down menu based on csv or excel

iProperty with pull down menu based on csv or excel

m.belkom
Observer Observer
784 Views
8 Replies
Message 1 of 9

iProperty with pull down menu based on csv or excel

m.belkom
Observer
Observer

Hi all,

 

I'm looking for a way to create an iProperty with an pulldown list, which value's are feeded from an external file,

for example an csv or excel sheet.

Can anyone point me in to the right direction?

Just want to mention that i'm a beginner with Inventor. So some more detailed info and patience is much appreciated 😉

0 Likes
785 Views
8 Replies
Replies (8)
Message 2 of 9

mcgyvr
Consultant
Consultant

You can't have a dropdown directly in the iproperties but you can use ilogic to pop up a dialog box and have the list of selections shown there and then set the iproperty to be whatever you selected..

ilogic rules can be triggered on events like "Before Save", "File Open",etc...

Do you have your excel list created? Can you post it here?

Can you also specify exactly which iproperty you want to fill out based on this list?

Then also please let us know when you would like to be prompted to fill this out? (which event trigger)..

 

Once we have that someone can write the code for you..

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 3 of 9

Gabriel_Watson
Mentor
Mentor

I am in the same boat, and this is as far as I got. The alternate code for pulling data from Excel keeps giving errors when active (it is commented out now), but at least most of the code is there. See attached.

Message 4 of 9

A.Acheson
Mentor
Mentor

Here is a quick overview and get started guide to ilogic. Here is a link to using ilogic message box and input boxes. 

 

Below is a simple example with an explanation of how it works. Place it into a new internal ilogic rule. Create a multivalue user parameter of either text or number depending on the units called "iprop"

Save an excel workbook with name "iProperty" and place some values in Sheet1, Cells, A3 -A20.

 

Run the below rule 

'Add the values to the parameter from the excel range
MultiValue.List("iprops") = GoExcel.CellValues("iProperty.xlsx", "Sheet1", "A3", "A20") 'Give the fulll filename of the file or the filename if the excel file is saved inb the same folder as this document

'Allow the user pick a value from the stored list( similar to the parameter drop down)
iprop = InputListBox("Pick One", MultiValue.List("iprops"), iprop, Title := "iProperties", ListName := "iprops")

'Set a custom iproperty to the selected value
iProperties.Value("Custom", "iprop") = iprop

'Give the value of custom iprop to a simple variable
Ans = iProperties.Value("Custom", "iprop")

'Show the value of the variable in a message box
MessageBox.Show(Ans, "Custom Property "iprop")

 Any questions on that, feel free to ask away. No question is too trivial at the beginning of the road.



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

m.belkom
Observer
Observer

Hi ! Thanks for the suggestion and the explaination.

I came a long way (i think..), but I encounter the following error when I select an entry from the selection list.

 

"Error in rule: Desc1, in document: Standard (mm).ipt

Unable to cast object of type 'System.String' to type 'System.Windows.Forms.IWin32Window'. "

 

From the More Info TAB I've collected the following :

 

System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Windows.Forms.IWin32Window'.
at ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

Any suggestions of what I must change?

0 Likes
Message 6 of 9

A.Acheson
Mentor
Mentor

I do see an error here where an extra quote is used so likely the system string error.

MessageBox.Show(Ans, "Custom Property "iprop")

 

Corrected version with string value between quotations showing for message box header 

MessageBox.Show(Ans, "Custom Property-iprop") 

If this is not the issue please post the rule you are working with. 

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

WCrihfield
Mentor
Mentor

Hi @m.belkom.  Just so you are aware, you can use a list of values (from Excel or elsewhere) to choose from when initially creating an iProperty, but after the iProperty is created it can only hold one value at a time.  An iProperty can not contain a multi-value list of possible values like a user parameter can.  If you are planning on creating something like an iLogic Form and would like to present the user with a list of possible values to choose from, you can use a user parameter from the Parameters dialog box after you have created one like that.  We all would like to have the ability to create and use multi-value iProperties, but that capability does not exist yet.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 9

nmunro
Collaborator
Collaborator

Just as a possible solution, the iPropWiz add-in does support list driven properties. Fort text type properties you can also assign (and edit) multiple values to the property from a  list.

        


https://c3mcad.com

0 Likes
Message 9 of 9

JelteDeJong
Mentor
Mentor

Another solution that might work for you is to create your own dialogue window using iLogic. Below you find a very simple example of a rule that presents the user with a window where he/she can select a value. That value is then written to the "Part number" iProperty. (Here is also the list with possible values in the rule...)

But it's also possible to create a window with all the properties that you need to change. Values can be taken from all different kinds of sources. If you start customizing the possibilities are endless, but what the best solution is for you depends on how complicated you want to make it. Do you consider making your own window?

Dim list As New List(Of String)
list.Add("aaa")
list.Add("bbb")
list.Add("ccc")

Dim newValue = InputListBox("Prompt", list, list.Item(0) , Title := "Title", ListName := "List")
iProperties.Value("Project", "Part Number") = newValue

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com