Back again from my vacation in Avignon.
We had a wonderful drive back up again through the gorges of the
Buëch river
with a beautiful camp near Rosans.
I knew the place from last year, and here are two photos from that visit.
Here is Cornelius at the camp fire in the evening:
Here is our camp site in the early morning dew:
We were lucky with the weather, sleeping outside with no roof, preferring the open sky to a tent, and it started raining just after we left but not before.
Looking at old and new subjects to write about, I just discovered a rather overdue issue, a question raised quite a while ago by Arun Shankar of
Reed Business
in a comment on the discussion on
adding a shared parameter to a DWG file:
Question:
Is it possible to add a shared parameter to an RFA file using the DotNet Revit API?
The example for adding shared parameters to a DWG file does not work for RFA files.
Can you please post some sample code for adding shared parameters to an RFA file?
<!–
First answer, missing the point, as pointed out by Matt Mason:
From: Matt Mason [mailto:matt.mason@avat.com]
Sent: Thursday, June 11, 2009 05:35
To: Jeremy Tammik
Subject: Add Shared Parameter to Family
Jeremy,
Regarding your recent blog post – I think you perhaps misunderstood the original question.
The developer wants to add a shared parameter to an RFA file as a type or instance parameter. This can be done with the FamilyManager.AddParameter() which takes an ExternalDefinition argument.
While it still may be necessary to add it to a project bound to a category, the first step to having the shared parameter in content is to add it to the family itself.
Best Regards,
Matt
Answer:
To address this issue, we first need to understand that shared parameters are always added to some category.
Is there any category that we can use to identify RFA files, or one specific RFA file?
If not, then we will not be able to define any shared parameters for these files.
To explore this issue a bit further, let me discuss a generic approach to analyse the elements added a given action in Revit.
In this case, we will determine what elements are added to the model when an RFA file is loaded, i.e. a new family.
We can explore this as follows using the
Revit API introduction labs
element lister tool implemented in the external command Lab2_1_Elements, which creates a text file listing all Revit database elements and some of their basic properties.
Actually, we have already mentioned this approach in the discussion on
exploring element parameters.
- Start off by creating an empty Revit model.
- List all its elements into a text file RevitElementsBeforeLoadingFamily.txt.
- Load a new family, for instance the door family Loaded M_Double-Flush.rfa.
- List the elements again into RevitElementsAfterLoadingFamily.txt.
Now we can determine the elements added by loading the family by comparing the two files using a
diff
tool:
C:tmp > diff
RevitElementsBeforeLoadingFamily.txt
RevitElementsAfterLoadingFamily.txt
2160a2161,2172
> Id=127149; Class=Family; Category=Doors; Name=M_Double-Flush
> Id=127705; Class=Element; Category=?; Name=M_Double-Flush
> Id=127706; Class=FamilySymbol; Category=Doors; Name=1830 x 1981mm
> Id=127707; Class=Element; Category=?; Name=1830 x 1981mm
> Id=127708; Class=FamilySymbol; Category=Doors; Name=1830 x 2083mm
> Id=127709; Class=Element; Category=?; Name=1830 x 2083mm
> Id=127710; Class=FamilySymbol; Category=Doors; Name=1730 x 2134mm
> Id=127711; Class=Element; Category=?; Name=1730 x 2134mm
> Id=127712; Class=FamilySymbol; Category=Doors; Name=1730 x 2032mm
> Id=127713; Class=Element; Category=?; Name=1730 x 2032mm
> Id=127714; Class=FamilySymbol; Category=Doors; Name=1830 x 2134mm
> Id=127715; Class=Element; Category=?; Name=1830 x 2134mm
From this, we see that one family, five family symbols, and five other elements were added.
The family and family symbols all have the category ‘Doors’, the five other elements’ category is undefined.
Therefore, I do not see any way to add a shared parameter to the RFA file or the family itself.
We could add a shared parameter for the Doors category, in which case it would become available on all door family instances as well.
This is demonstrated by the Revit FireRating SDK sample and the Revit API introduction labs 4-1, 4-2 and 4-3, but that is probably not your intention.
–>
Answer:
As pointed out in a private note by
Matt Mason,
adding a shared parameter to an RFA file is a completely different issue from adding it to a DWG file instance in a project.
In the latter case, we work in the project file and bind a shared parameter to a certain category specific to the inserted DWG file.
For an RFA file, you wish to define the shared parameter in the content, and the first step is to add it to the family itself.
You can add a shared parameter to an RFA file as a type or instance parameter by using the new Family API provided in Revit 2010.
It provides the new method FamilyManager.AddParameter().
Its use is demonstrated by the Revit SDK samples AutoParameter, DWGFamilyCreation and WindowWizard, which are located in the FamilyCreation subdirectory of the Samples folder.
It provides the following overloads:
- AddParameter(ExternalDefinition, BuiltInParameterGroup, Boolean): Add a new shared parameter to the family.
- AddParameter(String, BuiltInParameterGroup, Category, Boolean): Add a new family type parameter to control the type of a nested family within another family.
- AddParameter(String, BuiltInParameterGroup, ParameterType, Boolean): Add a new family parameter with a given name.
To add a shared parameter, you would use the overload taking an ExternalDefinition argument.
DWGFamilyCreation and WindowWizard both only add standard type parameters using the third overload with the fourth isInstance argument set to false, whereas AutoParameter uses both the first and third overloads to create instance, type and shared parameters.
Very many thanks to Matt for pointing this out!



Leave a Reply