It is a special day for me today, since it is my Birthday (number will remain unknown) Let’s just say is my 21st part… (unknown). I’m not sharing this with all of you to wish me “Happy Birthday” or get extra attention, I just like to reflect on what the year that passed has left me and I take it as a moment of reflection on my failures, accomplishments and my needs and wants to learn from life and from topics that interest me such as technology.
Sharing a little quote with all of you today and then back to Revit API.
I want to share a couple of interesting questions that came up this past week in our Revit API forum community, if you haven’t seen it before, it is one of the greatest resources to solve your questions or simply chat with the community about the API. Here is the link.
The first question is from Mendo123 asking the community about how to quickly check if the user is working in a WorkSharing Environment. I know a lot of you probably already know how, but is it always to have this information handy for when we need it and also for our new Revit API developers.
Here is the question.
Question: Sorry if this has been asked but what is the easiest way of determining if the user is working in a WorkSharing environment?
Originally I was comparing the username against the doc.title but proved to be a very rushed and messy Idea.
The answer came by one of our legacy contributors to the Forum, Mr. Revitalizer. where he suggested the use of the bool check on the Document.
Answer: Document.IsWorkshared will do the trick.
Here is what the description on the RevitAPI.CHM file says on the property suggested.
Identifies if worksharing (i.e. editing permissions and multiple worksets) have been enabled in the document. Also, see IsDetached, which will check if the workshared Document has been detached.
Thanks Revitalizer for the quick and nice tip.
Next, the second question is about how to get parameters from a system Family eg. Keynote, asked by Anders.
Question:Hope some one can help me to get type parameters from a system family. I can get the instants like Area & Volume, but not eg. Keynote
With component families do I use eg Door.Symbol.get_Parameter(BuiltInParameter.KEYNOTE_PARAM); But I can't get it to work with system families like floors. Where do I fail ?? :-)
FilteredElementCollector FMFloorCollector = new FilteredElementCollector(OpenDoc);
FMFloorCollector.OfClass(typeof(Floor));
foreach (Floor FMFloor in FMFloorCollector)
{
Floor_Keynote = FMFloor.get_Parameter(BuiltInParameter.KEYNOTE_PARAM);
Floor_Family = FMFloor.get_Parameter(BuiltInParameter.ALL_MODEL_FAMILY_NAME);
Floor_Mark = FMFloor.get_Parameter(BuiltInParameter.ALL_MODEL_MARK);
Floor_Type = FMFloor.get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_NAME);
Floor_Description = FMFloor.get_Parameter(BuiltInParameter.ALL_MODEL_DESCRIPTION);
Floor_Area = FMFloor.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED);
Floor_Volume = FMFloor.get_Parameter(BuiltInParameter.HOST_VOLUME_COMPUTED);
}
There were quite a few posts in response to the question, but one was selected as the accepted solution at the end. For those of you curious about it here is the link
to the complete question. Here is also the answer by peterjegan.
Answer: Anders, It looks like you are trying to get information from instances of a floor. You are not having trouble with instance-based parameters, but you can't get type-based parameters. I would suggest that you find each instance, get the instance-based information, then find the type and get the type-based information. I would suggest this:
foreach (Floor FMFloor in FMFloorCollector) { //instance params Parameter Floor_Family = FMFloor.get_Parameter(BuiltInParameter.ALL_MODEL_FAMILY_NAME); Parameter Floor_Mark = FMFloor.get_Parameter(BuiltInParameter.ALL_MODEL_M ARK); Parameter Floor_Type = FMFloor.get_Parameter(BuiltInParameter.ALL_MODEL_T YPE_NAME); Parameter Floor_Area = FMFloor.get_Parameter(BuiltInParameter.HOST_AREA_C OMPUTED); Parameter Floor_Volume = FMFloor.get_Parameter(BuiltInParameter.HOST_VOLUME _COMPUTED); Element el = FMFloor as Element; ElementId typeid = el.GetTypeId(); Element floortype = OpenDoc.GetElement(typeid); //type params Parameter Floor_Keynote = floortype.get_Parameter(BuiltInParameter.KEYNOTE_P ARAM); Parameter Floor_Description = floortype.get_Parameter(BuiltInParameter.ALL_MODEL _DESCRIPTION); }
Note that get_Parameter(string) is obsolete, but get_Parameter(BuiltInParameter) still works.
Thank you to our community of developers in the Revit API forum for the continuous collaboration on day to day questions with the use of the API.
Cheers, and until next time.