Reference Level vs Level

Reference Level vs Level

jordanmarr
Enthusiast Enthusiast
2,999 Views
2 Replies
Message 1 of 3

Reference Level vs Level

jordanmarr
Enthusiast
Enthusiast

I have some FamilyInstance objects that show a "Reference Level" of "Level 3" and a "Work Plane" of "Level : Level 3" in the properties window of Revit Structure 2012. 

I am trying to select only these FamilyInstance objects from Level 3; however, when I iterate through all of my FamilyInstance objects in code, the all have a "Level.Name" of "Level 0". 

 

So I need to find the "Reference Level" parameter for filtering purposes, but none of the FamilyInstance objects have this as a parameter. 

 

Where can I find this value in code?

 

Thanks,
Jordan

0 Likes
Accepted solutions (1)
3,000 Views
2 Replies
Replies (2)
Message 2 of 3

ollikat
Collaborator
Collaborator

At least in Revit MEP we can get the level of the family instances from Level property. Exception are hosted families which do not have Level information if they are hosted by some other element than the level itself. It must be read from schedule level parameter instead (BuiltInParameter::SCHEDULE_LEVEL_PARAM).

 

Not sure if this helps...

0 Likes
Message 3 of 3

jordanmarr
Enthusiast
Enthusiast
Accepted solution

Close... it turns out it was stored as a parameter value.  This is the code that eneded up working for me:

 

        /// <summary>
        /// The beam family instances do not directly belong to a level, 
        /// so we cannot use the Level property to determine their level.
        /// Instead, we have to check this parameter value.
        /// </summary>
        /// <param name="f1"></param>
        /// <param name="level"></param>
        /// <returns></returns>
        private bool BeamFamilyInstanceIsOnLevel(FamilyInstance f1, Level level)
        {
            if (f1.Level != null)
            {
                return false;
            }
            
            var parameter = f1.get_Parameter("Work Plane");

            if (parameter == null)
            {
                return false;
            }

            // Ex: "Level : Nivel 3"
            string levelString = parameter.AsString();

            return levelString.EndsWith(level.Name);
        }

 

Thanks,

Jordan

 

0 Likes