Multiple selections of drop down list, into iproperty as text

Multiple selections of drop down list, into iproperty as text

K.TRYFONIDIS
Advocate Advocate
528 Views
4 Replies
Message 1 of 5

Multiple selections of drop down list, into iproperty as text

K.TRYFONIDIS
Advocate
Advocate

Hello all,

 

The problem here is that i would like to fill in the property value a single string text of the selections the user makes

 

at the dropdown and presses ok button.

 

For example, if the user selects and clicks ok at PRIONI option and then at next pop up selects TORNOS and hit ok and then closes window,

kTRIFONIDIS_0-1642773985104.png

 

the iproperty should look like this:

 

kTRIFONIDIS_1-1642774026595.png

 

NyfanRooting    PRIONI, TORNOS  as a single string text value.

 

 

 

At this moment it only saves the last clicked selection but not the previous ones.

 

 

Do you know a way to fix and save all selections?  Bellow is the code i am using now:

 

I feel i am close but i cant fix it yet..

 

 

Dim oTypes_Array As New ArrayList

oTypes_Array.Add("PRIONI")

oTypes_Array.Add("TRYPANI")

oTypes_Array.Add("TORNOS")

oTypes_Array.Add("MONTAZ")

oTypes_Array.Add("FREZA")

 

Dim oSelected As New ArrayList

 

While True

                oTypes_Selected = InputListBox("CHOOSE:", oTypes_Array, oTypes_Array(0), oRuleNo, X_oProp_Array)

                If IsNothing (oTypes_Selected) Then Exit While

                oSelected.Add(oTypes_Selected)             

End While

 

If oSelected.Count > 0 Then

               

                For Each oText In oSelected

               

                iProperties.Value("Custom", "NyfanRooting") = oText

               

                next

 

End If

 

 

 

 

 

 

0 Likes
Accepted solutions (2)
529 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor
Accepted solution

Try replacing this line:

If IsNothing (oTypes_Selected) Then Exit While

with this one:

If String.IsNullOrEmpty(oTypes_Selected) Then Exit While

or this one:

If oTypes_Selected = "" Then Exit While

 

Also, try replacing this line:

iProperties.Value("Custom", "NyfanRooting") = oText

 with this one:

iProperties.Value("Custom", "NyfanRooting") = iProperties.Value("Custom", "NyfanRooting") & ", " & oText

If that last line doesn't work, try getting the existing value of that iProperty to a variable first, then use that variable in stead of the second iProperties.Value() call in that line of code.  (I assume you want each selected text to follow the one before, with a comma between them, similar to what your image showed.)

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

K.TRYFONIDIS
Advocate
Advocate

Thank you very much! We almost did it, i think it only needs some fine tuning now!

I had to put a temp variable because it didn't work without, i had an error message.

Only problem is that if i choose 4 or more options, only 3 appear in the box of iproperty ( did test for character limit but it seems there isnt one, at least short one, check image)

result.

kTRIFONIDIS_0-1642776506298.png

test for character limit:

 

kTRIFONIDIS_1-1642776554119.png

 



And a minor problem is that it shows (comma) , before first word also which seems awkward.. 😛

here is the code now.

Dim oTypes_Array As New ArrayList 
oTypes_Array.Add("PRIONI")
oTypes_Array.Add("TRYPANI")
oTypes_Array.Add("TORNOS")
oTypes_Array.Add("MONTAZ")
oTypes_Array.Add("FREZA")

Dim oSelected As New ArrayList

While True 
	oTypes_Selected = InputListBox("CHOOSE:", oTypes_Array, oTypes_Array(0), oRuleNo, X_oProp_Array)
	If String.IsNullOrEmpty(oTypes_Selected) Then Exit While 
	oSelected.Add(oTypes_Selected)	
End While 

If oSelected.Count > 0 Then
	
	For Each oText In oSelected
		
		iProperties.Value("Custom", "NyfanRooting") = tempx
	tempx = iProperties.Value("Custom", "NyfanRooting") & ", " & oText
	
	next

End If

 

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor
Accepted solution

Switch these two lines like so:

tempx = iProperties.Value("Custom", "NyfanRooting")
iProperties.Value("Custom", "NyfanRooting") = tempx & ", " & oText

The first line is setting the value of the variable 'tempx' from the iProperty.

The second line is including that value at the start of the new value of the iProperty we are giving it.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

K.TRYFONIDIS
Advocate
Advocate

Sorry for the delay, weekend-off.

 

I can't thank you enough for your help! 🙂

the only minor change i did is switching comma to the end, it feels better for me. I have to find a way to remove last comma, but is not something to rush for now.

kTRIFONIDIS_0-1643008923695.png

 

0 Likes