Still getting back into normal work flow after some time off, I have a bunch of stuff to share:
Before designing or implementing a Revit add-in, it is well worth pondering the status, use and cost of Revit in depth.
Who is supposed to make use of your add-in?
Who is supposed to install – and pay for – Revit?
Revit is a very specialised, high-level and costly BIM design tool.
I would expect a limited number of people to be directly involved in creative hard-core BIM work.
Many add-ins can add immense value to the BIM and construction process with no need for such a tight integration with Revit.
Many add specific data items or perform read-only analysis and reporting tasks.
For all such tasks, it may be well worthwhile thinking of shifting your app development platform to a much more accessible – and cheaper – environment, e.g., Forge.
Two of my recent samples demonstrate the implementation of equivalent functionality using Revit and its API versus Forge and JavaScript:
Interestingly enough, moving your app development out of the specialised .NET Revit API into a much more generic JavaScript based development platform makes development easier, faster, enables much better integration with other components, and provides access to a larger number of existing libraries for almost any conceivable task.
Furthermore, if you really do require Revit specific functionality, e.g., you wish to modify the BIM and write RVT
files, and want to provide your app to a large or unlimited number of users in a flexible fashion, not necessarily bound to a full-fledged Revit desktop installation, be aware that we are continuing to work hard on a Forge design automation API
to provide all you need online, aka Revit I/O.
Continuing in this vein, are you interested in easy and ubiquitous access to your Revit model properties?
Well, you can have that right now, even without any Revit installation whatsoever.
The Forge Model Derivative API extracts
a streamlined copy of all geometry, BIM element hierarchy and properties from over fifty file formats, and Revit RVT
files are just one of them.
As mentioned a
while ago, Augusto Goncalves implemented
the viewer-javascript-extract.spreadsheet
Forge sample to read all the properties on all BIM elements in an RVT
file and export them to an XLSX
spreadsheet.
My new colleague
Michael
Beale now
released another sample that adds the functionality to access a Revit BIM stored in BIM360: the
BIM360 Revit Export to Excel sample
demonstrates how to access and extract Revit data on your BIM360 account using 3-legged OAuth
to log in, a simple viewer extension and code to read the Revit meta-data and format it into an Excel spreadsheet file:
Many thanks to Augusto and Michael for putting these together!
Augusto uses Michael's sample to answer the StackOverflow question on Forge Viewer: unique IDs for clickable objects:
Question: I am experimenting with Revit and the Forge Viewer. I noticed that Forge has its own unique IDs for everything you can click on in the Revit model, so I used those instead of the Revit identifiers.
For example, the door of my building has the id: "3003".
My question is: where is this data stored and how can I change "3003" into "Door 1"?
Answer: The Viewer gives access to three types of IDs when dealing with Revit files:
dbId
: this is viewer specific and used to manipulate elements within the viewer, such as for the .getProperties()
method.ElementID
: exposed as part of the Name
property in the viewer. When you select something, the Property panel title is in the form of 'Name [12345]'. You can parse this name string and extract the element id.UniqueID
: exposed as the externalId
property in the .getProperty()
response.The BIM360 Revit Export to Excel sample mentioned above exports properties into a spreadsheet, which ought to answer your question.
Philippe Leefsma demonstrates similar functionality in his Configurator – Meta Properties sample.
The office model is displayed, and its properties displayed in a panel on the right-hand side.
You can select any BIM element and see all its properties as well.
The buttons on the right-hand side of the property panel enable search, export to CSV
and JSON
, and adding new properties.
Each property can also be deleted.
If you would like to learn more about Forge, don't miss the chance to join one of the upcoming accelerators:
Back to pure Revit API related topics, Irneb raised an issue with the Visual Studio Revit Add-In Wizards in his issue #6 – install script alteration suggestion, and solved it with pull request #7 – path to profile folder.
He says:
In the install.bat file you're getting to the documents folder by building up the path using the username. Unfortunately, this isn't always the case. Also, the C drive is not necessarily where the user's home folder resides.
I suggest changing the 6th line from this:
set "D=C:\Users\%USERNAME%\Documents\Visual Studio 2015\Templates\ProjectTemplates"
to this:
set "D=%userprofile%\Documents\Visual Studio 2015\Templates\ProjectTemplates"
That should at least help where the user's home folder isn't in the usual position (or named the same as the username).
What is a bit cumbersome though is if the Documents folder under that has been relocated. Unfortunately, the only place this is available is in registry. Else you can get to it using vbscript or PowerShell.
Here's a way to use PowerShell inside a BAT
file:
set T="%TEMP%\docspath.tmp" powershell -Command "[Environment]::GetFolderPath('MyDocuments') | Out-File '%T%' -Encoding ascii" set /p DOCSPATH=< "%T%" del "%T%"
Thereafter the line above can be changed to this instead:
set "D=%DOCSPATH%\Visual Studio 2015\Templates\ProjectTemplates"
Though it just feels way too complicated for my taste.
I fully agree.
I'm definitely not a Windows shell or installation expert, and I am sure there are much more elegant ways to address this.
Still, being as it is, the updated version is captured in release 2018.0.0.1.
The difference to the previous version consists
of just two modified lines in TemplateRevitCs.csproj
and install.bat
.
RevitLookup is the main Revit BIM database exploration tool.
Question: I am trying to install RevitLookup on Revit 2017, and having a bit of difficulty figuring out how to go about the installation in Revit.
I downloaded it from GitHub and unpacked the ZIP
file. Now, according to the instructions, I have to do the following:
AddIns
folder.I located the folder with this path: Local disk (C:) – Program Data – Autodesk – Revit – Addins – 2017
Now, I am wondering how to identify the assembly DLL and whether I need to specify a 'key' in order to sign it.
Secondly, I can’t find the add-in manifest anywhere in the repository.
Answer: To understand the Revit add-in installation process properly in depth, I suggest that you study the Revit API getting started material.
It explains all you need to know about installing a Revit add-in.
So does the developer guide in the Revit help, specifically in its more succinct section on add-in registration.
No, you do not need to sign anything.
Normally, you do not need to make any changes at to the add-in manifest.
It is provided right there, in the repository
folder CS
:
Furthermore, very conveniently, YouTube presents several videos on installing RevitLookup.
Another little note on RevitLookup.
Prompted by the issue #35 – RevitLookup doesn't snoop all members, I enhanced the documentation with the caveat – RevitLookup cannot snoop everything:
Question: I tried snooping a selected Structural Rebar element in the active view and found not all of the Rebar class members showed up in the Snoop Objects window. One of many members that weren't there: Rebar.GetFullGeometryForView
method.
Is this the expected behaviour? I was thinking I could get all object members just with RevitLookup and without the Revit API help file RevitAPI.chm
.
Answer: RevitLookup cannot report all properties and methods on all elements.
For instance, in the case of GetFullGeometryForView, a view input argument is required. How is RevitLookup supposed to be able to guess what view you are interested in?
For methods requiring dynamic input that cannot be automatically determined, you will have to make use of more intimate interactive database exploration tools, e.g. RevitPythonShell.