i-logic for multi value list as a input message in assembly

i-logic for multi value list as a input message in assembly

hbilla
Participant Participant
229 Views
6 Replies
Message 1 of 7

i-logic for multi value list as a input message in assembly

hbilla
Participant
Participant

Need a I-logic for the Custom Property with multi value list.

where it will take input from the user with multi value list and will save in the assembly.

0 Likes
Accepted solutions (1)
230 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

Hi @hbilla.  I understand that you want some code that will create a custom iProperty, but we can not create custom iProperties that have multiple values.  We can only create UserParameters that are multi-value.  Even when that UserParameter is set to export, which exposes it as a custom iProperty with the same name and same value, the resulting custom iProperty only has the one value (the current visible value of the parameter).  However, if you just want the code example to contain a list of possible values, and show that list to the user, so that they can select one value from it to set as the custom iProperty's value, then that is certainly possible.  Just need to clarify what you want with as much detail as possible, because code needs to be extremely specific to make it work the way we want it to.

Edit:  Below is an example of how we can create a custom iProperty, and let the user select a value for it from a list containing multiple possible values.

'get current document
Dim oDoc As Inventor.Document = ThisDoc.Document
'specify name of custom iProperty
Dim sPropertyName As String = "Custom Property 1"
'define list of possible values to choose from
Dim oPossibleValues As New List(Of String)
oPossibleValues.Add("Possible Value 1")
oPossibleValues.Add("Possible Value 2")
oPossibleValues.Add("Possible Value 3")
oPossibleValues.Add("Possible Value 4")
'prompt user to choose one from the list
Dim sChoice As String = InputListBox("CHOOSE ONE", oPossibleValues, "", "Title", "List Name")
'if they did not choose one, were done, exit rule
If sChoice = "" Then Return 'nothing chosen, so exit rule
'get the PropertySet for custom properties
Dim oCProps As Inventor.PropertySet = oDoc.PropertySets.Item(4)
'create variable for the custom iProperty object
Dim oCProp As Inventor.Property = Nothing
Try
	'try to find existing property
	oCProp = oCProps.Item(sPropertyName)
	'set its value, if found
	oCProp.Value = sChoice
Catch
	'it did not exist, so create it, and set value at same time
	oCProp = oCProps.Add(sChoice, sPropertyName)
End Try

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 7

hbilla
Participant
Participant

thanks for quick reply.
for example.
I need a Custom I property "Plant Location" in the assembly. I need to create it using the ilogic code. 
for that "Plant Location" i need multi value list like "xxxx", "yyyy", "zzzzz"etc.
these values must be Selected by user by selecting it(not at user parameters). if there is no desired value then user need to enter.
then by clicking ok. it must export the value to excel.

0 Likes
Message 4 of 7

WCrihfield
Mentor
Mentor
Accepted solution

Here is an updated code example.  In this one, if no value is chosen from the list, it will prompt the user to enter a value for the property.  I also spaced things out, and made the comments a bit more visible, to make it easier to look at and read through.  However, I do not know nearly enough about the final step of exporting to Excel that you mentioned to make that happen in this code example yet.  That would require quite a bit more information from you.  For example, I don't know if an existing file will be used, or a new file would need to be created, where the file would be in your file system, what the file name would be, which file extension you need to be working with, which sheet within that file to work with, which rows, columns, or cells within that sheet to write which piece of data to, and more.

'get current document
Dim oDoc As Inventor.Document = ThisDoc.Document

'<<< SPECIFY NAME OF PROPERTY >>>
Dim sPropertyName As String = "Plant Location"

'<<< DEFINE LIST OF POSSIBLE VALUES TO CHOOSE FROM >>>
Dim oPossibleValues As New List(Of String)
oPossibleValues.Add("xxxx")
oPossibleValues.Add("yyyy")
oPossibleValues.Add("zzzz")

'<<< PROMPT USER TO CHOOSE ONE FROM LIST >>>
Dim sChoice As String = InputListBox("CHOOSE ONE", oPossibleValues, "", "Title", "List Name")

'<<< CHECK IF THEY DID NOT CHOOSE ONE >>>
If sChoice = "" Then
	'<<< IF SO, PROMPT THEM TO ENTER A VALUE >>>
	sChoice = InputBox("ENTER VALUE", "Title", "")
End If

'<<< GET PROPERTYSET FOR CUSTOM PROPERTIES >>>
'always present in every document, and always fourth set
Dim oCProps As Inventor.PropertySet = oDoc.PropertySets.Item(4)

'<<< CREATE VARIABLE FOR THE CUSTOM PROPERTY OBJECT >>>
Dim oCProp As Inventor.Property = Nothing
'<<< TRY TO EITHER UPDATE EXISTING PROPERTY, OR CREATE NEW PROPERTY >>>
Try
	'<<< TRY TO FIND EXISTING PROPERTY >>>
	oCProp = oCProps.Item(sPropertyName)
	'<<< SET ITS VALUE, IF FOUND >>>
	oCProp.Value = sChoice
Catch
	'<<< NOT FOUND, SO CREATE IT AND SET VALUE AT SAME TIME >>>
	oCProp = oCProps.Add(sChoice, sPropertyName)
End Try

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 7

hbilla
Participant
Participant

thanks for the code and i modified a little bit as per my requirment.

0 Likes
Message 6 of 7

hbilla
Participant
Participant

is there any chance instead of input box.. we need dragdown box.

 

0 Likes
Message 7 of 7

WCrihfield
Mentor
Mentor

Not sure what a drag down box is, but if you mean a 'combo box', which has both drop-down list, and a text editing field, then no, there is no easy or simple way to prompt the user with one of those.  We can easily create the 'InputListBox' and the 'InputBox' as in that example.  And we can also easily create an 'InputRadioBox', which is essentially a small dialog with two buttons, one representing the value (True or Yes), while the other represents the value (False or No), where we can put custom text inside those buttons for more meaningful understanding of what they mean in a specific situation.  To create and use a combo box, you would have to create something like an iLogic Form, or similar.  Those can contain more complex controls, and multiple controls.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)