Today, let me point out ArchSample, a heretofore unmentioned Revit SDK sample that I happened to notice answering a recent case, how to determine a currently active transaction, and an update to the ADN Revit MEP sample AdnRme:
- ArchSample and Retrieving Element Properties
- How to determine active or current transaction
- AdnRme for Revit MEP 2016
Before getting to those, let me add that I am still travelling in Greece, heading back to Athens now from the Greek island of Euboea on my way to the second I love 3D – Athens meetup this evening, followed by the AngelHack hackathon this weekend. For more details, please refer to The 3D Web Coder.
ArchSample and Retrieving Element Properties
This was prompted by a recent case on retrieving the element properties of a model:
Question: I am trying to traverse the Revit model to access all element properties.
For this, I am retrieving the elements from a filtered element collector.
Now I would like to get the data shown in the property palette for each element.
Is there any way to get the collection of all the properties associated with an element?
Answer: Yes, certainly; this is pretty easy.
In fact, it is covered by the Revit API getting started material.
Please work through that and you will see for yourself.
In short, there are a couple of properties and methods on the Revit Element class to look at, e.g., Parameters and the various overloads of GetParameter. Read about those in the Revit API help file RevitAPI.chm.
Once you have done that, you can take a look at the Revit SDK ArchSample sample add-in – I believe it already does almost exactly what you are asking for.
It is very similar to the external command Lab4_2_ExportParametersToExcel defined in both C# and VB by the ADN Revit API Xtra training material... not yet migrated to Revit 2016, though.
The FireRating Revit SDK sample demonstrates both export and import, in VB, of a custom shared parameter.
This functionality is also duplicated in C# by three ADN Xtra commands:
Actually, you can search the Revit SDK main Visual Studio solution globally for 'Excel' and other keywords to find several further related samples.
I hope this helps.
How to Determine if there is an Active or Current Transaction
Yet another helpful clarification on transactions by Arnošt Löbel:
Question: Is there any way to determine if there is an active or current transaction?
Answer: Yes, there is. However, the answer depends on what you mean by active and current transaction. Should I assume you mean the same thing by both the words – that is the active transaction that may be currently open (i.e. between Start and either Commit or RollBack) in a given document?
If so, there is a way:
If Document.IsModifiable returns TRUE, then there is an active transaction open in that document.
However, if IsModifiable returns FALSE, it does not necessarily mean there is no active transaction. It can also mean that there is a transaction except that the document cannot be modified regardless, for example during a failure resolution. A true indicator of a situation when there is no active transaction in a document is that when both IsModifiable and IsReadOnly returns FALSE.
You should also read the remarks on the Document.IsModifiable property in the Revit API help file RevitAPI.chm:
"This is not a permanent state such as, for example IsReadOnlyFile. Value of this property can change dynamically multiple times within the lifetime of an open document. Regardless of the mode a document is opened with, the model can only be modified inside an open transaction. Furthermore, even with a transaction open, the model is not always modifiable. Though this is rather a rare situation, it can happen, most likely during model regeneration, failure processing, or some events. An attempt to modify a non-modifiable document will result in throwing a ModificationOutsideTransactionException."
AdnRme for Revit MEP 2016
I migrated the ADN MEP sample AdnRme to Revit MEP 2016.
The migration was absolutely trivial, simply changing the Revit API assembly references to point to the new version.
Zero errors and zero warnings.
The most up-to-date version is always provided in the AdnRme GitHub repository, and the first Revit 2016 version is now available from there as release 2016.0.0.0.