How to create an enumeration-typed parameter

How to create an enumeration-typed parameter

Anonymous
Not applicable
1,060 Views
2 Replies
Message 1 of 3

How to create an enumeration-typed parameter

Anonymous
Not applicable

The Developers Guide explains how to create e.g. shared String parameter and import them into the project.

I actually want to create a parameter which has a fixed set of possible values, which is normally referred to as enumeration type in programming languages. The user shall be able to choose one literal from a combo box in the Properties view.

 

Anybody knows how to do this?

 

PS I dont have the requirement that it is a shared parameter, it can also be "only" a project parameter, but i didnt found out how to create these.

0 Likes
1,061 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

8 Years later i got pretty much the same question. And since nobody answered since 2012 I am wondering if there is a solution for this problem meanwhile?

 

I created some project parameters using a shared parameter file.So it looks like this:

 

projectinformation.PNG

 

Now I want some enumerated values for some of my attributes. e.g. I want a dropdown menu for attribute "gebäudeklasse" with the possible values , "gebäudeklasse 2" and "gebäudeklasse 3".

 

My code to create the parameters so far:

 

 

 

Category projCategory = doc.Settings.Categories.get_Item(BuiltInCategory.OST_ProjectInformation);
CategorySet projCategorySet = app.Create.NewCategorySet();
projCategorySet.Insert(projCategory);

string paramFile = @"D:\Daten\SharedParameterFile.txt";
var parameter = new XPlan_Parameter();
DefinitionFile defFile = default(DefinitionFile);

List<string> projectInformationList = new List<string>();
projectInformationList.Add("Bezeichnung des Bauvorhabens");
projectInformationList.Add("Art der Maßnahme");
projectInformationList.Add("Art des Gebäudes");
projectInformationList.Add("Gebäudeklasse");
projectInformationList.Add("Bauweise");

foreach (var p in projectInformationList)
{
    defFile = parameter.CreateDefinitionFile(paramFile, app, doc, p, "ProjectInformation");
}

foreach (DefinitionGroup dg in defFile.Groups)
{
    foreach (var projInfoName in projectInformationList)
    {
       if (dg.Name == "ProjectInformation")
        {
        ExternalDefinition externalDefinition =    dg.Definitions.get_Item(projInfoName) as ExternalDefinition;

        Transaction tProjectInfo = new Transaction(doc, "Insert Project Information");
        {
        tProjectInfo.Start();
        ProjectInfo projectInfo = doc.ProjectInformation;
        InstanceBinding newIB = app.Create.NewInstanceBinding(projCategorySet);
         if (externalDefinition != null)
             {                                 doc.ParameterBindings.Insert(externalDefinition, newIB, BuiltInParameterGroup.PG_GENERAL);
             }
          }
         tProjectInfo.Commit();
      }                    
   }
}

 

 

Message 3 of 3

jeremytammik
Autodesk
Autodesk

Thank you for picking up this old thread.

 

Here is a more detailed description of the issue and a list of possible ideas for handling it, also pretty old:

 

https://thebuildingcoder.typepad.com/blog/2015/11/drop-down-enumerated-parameter-values.html

 

Cheers,

 

Jeremy

 



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

0 Likes