Parameter values combo box

Parameter values combo box

stane
Explorer Explorer
3,120 Views
9 Replies
Message 1 of 10

Parameter values combo box

stane
Explorer
Explorer

Hey guys!

I am developing a grid parameter editor of model FamilyInstance elements. In my grid, I would like to mimic a drop down combo box (like the one in Revit properties editor) for those parameters that have StorageType == StorageType.ElementId. How do i know what values to populate the combo box of a specific parameter with (which ElementId's are valid for a specific parameter)?

//Pseudo code for populating my combo box with values when it gets focus.
//I need LIST_OF_VALID_VALUE_ELEMENTS(p).

Parameter p = SelectedFamilyInstanceParameter;

foreach (Element e in LIST_OF_VALID_VALUE_ELEMENTS(p) )
{
    myComboBox.Items.Add(e.Name, e.Id);    
}

I just can't seem to find a solution for this. Any help would be greatly appreciated.

Thanks!

 

0 Likes
3,121 Views
9 Replies
Replies (9)
Message 2 of 10

Mustafa.Salaheldin
Advisor
Advisor

Please clarify more and provide pictures if possible.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 3 of 10

stane
Explorer
Explorer

Hmm, perhaps I made it more confusing than it needed to be talking about combo boxes and all that 🙂

Basically what I need is a way to figure out which Elements(or ElementIds) from the active document are valid as a value for an arbitrary built in parameter with StorageType == StorageType.ElementId.

I am out of office now and cannot provide screenshots, but will do so tomorrow.

Thanks for your time!

0 Likes
Message 4 of 10

stane
Explorer
Explorer

So here's a screenshot. This is the original revit parameter editor. I am trying to create(mimic) the combobox like the one here, so I need a way to find out which values to display in combobox for each and every parameter with StorageType == StorageType.ElementId.

Thanks!

0 Likes
Message 5 of 10

jeremytammik
Autodesk
Autodesk

Dear Stane,

 

Thank you for your query and screen snapshot.

 

Different sets of element ids are valid selection options for different parameters.

 

It is impossible to answer your question in general as it stands.

 

One specific example of doing something like this is provided by the ADN Revit API training lab Lab3_4_ChangeSelectedInstanceType:

 

https://github.com/jeremytammik/AdnRevitApiLabsXtra/blob/master/XtraCs/Labs3.cs#L296-L420

 

It determines the valid applicable family types for a selected family instance.

 

For other situations, such as the example you show in your screen snapshot, other element ids will be valid options for a given parameter.

 

I am not aware of any existing generic solution for this.

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 6 of 10

stane
Explorer
Explorer

Hello Jeremy!

Thanks for your answer. I am already using exactly the same approach as you mentioned to determine valid family types for the selected family instance. That's why I thought there might be a similar approach to automatically determine valid values for a parameter.

So, just to check if I got this right; If I want to present my user with valid values for parameters, I have to manually determine what Elements are valid for each Parameter with StorageType == StorageType.ElementId in a manner like this:

 

Parameter p = el.LookupParameter(MyParamName);

List<ElementId> ListOfValidParamValues = new List<ElementId>();

if (p.Definition.ParameterGroup == BuiltInParameterGroup.PG_PHASING)
{
    foreach (Phase p in Document.Phases)
    {
        ListOfValidParamValues.Add(p.Id);
    }
}
else if(p.Definition.ParameterGroup == SOMETHING_ELSE)
{
    //determine valid parameters in some other way
}

Is it ok to determine valid values based on ParameterGroup, or would something else be better?

Thanks!

0 Likes
Message 7 of 10

jeremytammik
Autodesk
Autodesk

Dear Stane,

 

Thank you for your update and understanding.

 

I believe the parameter group only refers to how parameters are grouped together under different headings in the property pane.

 

I do not think that it has much to do with the function of the parameter, or the valid values for element ids that can be assigned.

 

I am afraid the valid element ids vary and depend on each individual parameter.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 8 of 10

stane
Explorer
Explorer

"I do not think that it has much to do with the function of the parameter, or the valid values for element ids that can be assigned."


Yeah, I just figured out so....:(

 

 

"I am afraid the valid element ids vary and depend on each individual parameter."

 

So, is there a way to figure out programatically which element ids are valid for each individual parameter separately, one by one ?

 


Thanks again!

 

0 Likes
Message 9 of 10

jeremytammik
Autodesk
Autodesk

Dear Stane,

 

I am not aware of any officially supported method for this.

 

You can try it out, e.g., write a program that assigns each and every existing element id in the entire database as a value to each and every parameter taking an element id data type, then commit the transaction, and see whether (i) an exception is thrown (best case) or (ii) the database is corrupted (worst case).

 

I will be interested to hear the result  🙂

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 10 of 10

stane
Explorer
Explorer

Alright!

I will explore a bit in this direction you suggest and let you know with my findings 🙂

Thank you for your time Jeremy!

 

Regards!

0 Likes