assign level to "Mass Floors" parameter of mass FamilyInstance

assign level to "Mass Floors" parameter of mass FamilyInstance

aditazz
Contributor Contributor
957 Views
4 Replies
Message 1 of 5

assign level to "Mass Floors" parameter of mass FamilyInstance

aditazz
Contributor
Contributor

Revit 2014, C# .NET

 

How do I assign level to "Mass Floors" parameter of mass FamilyInstance programmatically?

 

I have succesfully loaded and inserted a mass family instance and tried to access "Mass Floors" in the way below.

 

FamilyInstance newMassInstance = doc.Create.NewFamilyInstance(location, familySymbol, level, StructuralType.NonStructural);
Parameter mfParameter = newMassInstance.get_Parameter("Mass Floors");
if (mfParameter != null)
{
    mfParameter.Set(level.Name);    <<--- this does not work
    //mfParameter.Set(2);                 <<--- this does not work either
}

 

Thanks

0 Likes
958 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

Dear Aditazz,

 

Does that make sense at all?

 

Can you achieve what you are trying to do manually, through the user interface?

 

Relationships between levels and other Revit database elements are generally established using the level element id, not its name, and not the numeral '2'.

 

But what does the Mass Floors parameter have to do with levels?

 

If it makes sense at all, then the data type of the Mass Floors parameter must be ElementId, and you must set it using 

 

 

  mfParameter.Set( level.Id );

 

Cheers,

 

Jeremy



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

0 Likes
Message 3 of 5

aditazz
Contributor
Contributor

I should have posted this screen image to make it clear. Yes, I can do this from Revit user interface.

0 Likes
Message 4 of 5

jeremytammik
Autodesk
Autodesk

All such Revit database element properties are represented by parameters.

 

These are accessed programmatically using the Parameter class.

 

It only supports certain basic data types such as string, integer, element id, etc.

 

Afaik, most properties that have an 'Edit...' button in the user interface cannot be accessed programmatically, because the underlying data does not fit into the supported Parameter class data types.

 

In this specific case, it looks like you would need a list of element ids.

 

Cheers,

 

Jeremy



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

0 Likes
Message 5 of 5

andrzej_m
Participant
Participant

Old question but still unanswered, so to gain some forum points:

 

To change new mass instance mass floor levels You need to use MassInstanceUtils:

MassInstanceUtils.AddMassLevelDataToMassInstance(Doc, newMassInstance.Id, massLevel.Id);

 

Cheers,

AndrzejM

0 Likes