Let's start the week with two pretty fundamental topics:
A long time ago, compiling the Revit SDK Samples updated for each new major release was major undertaking due to hundreds of compiler errors.
In the last couple of years, happily, it became a piece of cake.
This time around, unfortunately, it was a lot trickier again.
The source of the problem is pretty basic and not really hard to fix: the references to the Revit API assemblies in each of the 190 sample projects is set up for different developers' specific environments.
All you need to do is to hunt them all down and point them all to the official Revit installation location C:\Program Files\Autodesk\Revit 2021.
Hey, development team, can't you please do that for us yourself, before releasing the SDK to the general unsuspecting public?
It would just save a couple of hour's work for every single developer that inadvertently runs into this issue.
Anyway, this time around, I copied the original state of the Revit SDK to the RevitSdkSamples GitHub repository before analysing the problem and applying the fixes, so you can easily retrace my steps or download the final results of my fixes and save yourself the effort of reinventing this particular wheel.
Here is a list of some of my commits, releases, and error logs:
I performed the following steps to locate the API assemblies and fix these errors:
HintPath
in SDKSamples.targetsHintPath
settings in individual project filesHintPath
in SDKSamples.VB.targetsHintPath
in SDKSamples.Steel.targetsThat enabled the first successful compilation, still producing a bunch of warnings, though:
Most of the warnings concern the ever-recurring architecture mismatch issue and can be resolved using my DisableMismatchWarning.exe utility implemented back in 2013 and available from the DisableMismatchWarning GitHub repository. I ran it individually on each of the projects causing the warning. The result is
I will leave the remaining five warnings in there for now.
I hope that I can persuade the development team to clean up the SDK before their next release of it to save us having to repeat these steps again next time around.
Talking about the Revit SDK samples, let's address another (even more) beginner's question, on reading the value of a parameter, raised in a comment on unofficial parameters and BipChecker:
Question: I am trying to read the following parameters of a wall: volume and area.
I have been using getparameter
, get_parameter
and lookupparameter
, but the return value is always empty.
Are there any tutorials, examples or links where I may get the answer?
Answer: Reading the value of a parameter is a very basic and fundamental task in the Revit API, so it is covered in depth by the getting started material.
Please work through that before doing anything else, if you have not done so already.
The main steps are:
Exploring the element properties and determining exactly which parameters to use to retrieve the desired information is vastly simplified by RevitLookup, an interactive Revit BIM database exploration tool to view and navigate element properties and relationships.
If you have not already installed and started using that, you should do so right away!
Once you have completed those preparations, reading those two parameter values can be accomplished like this in code:
Element e = null; // get the BIM element double a = e.get_Parameter( BuiltInParameter.HOST_AREA_COMPUTED ); double v = e.get_Parameter( BuiltInParameter.HOST_VOLUME_COMPUTED );
The age-old article discussing compound wall layer volumes shows a practical example of retrieving those two values.
Be scarier than the virus