I updated my Visual Studio Revit add-in wizards and am taking the time to publish them today, which is Ascension Day and a holiday in Neuchâtel.
That also gives me some extra time to prepare for the June 3-4 Tech Summit presentation of my cloud-based round-trip 2D Revit model editing project.
The presentation must be pre-submitted by May 20, and a full recording by May 27, so pressure is rising. I completed the implementation and still want to catch up on documenting it here on the blog as well. You will be happy to hear that the auto-updating functionality using the Idling event now works fine.
Old and New Wizardry
I am starting to create numerous Revit 2014 add-ins now for quick testing purposes. As soon as that stage is reached, I immediately update my Visual Studio Revit C# add-in wizard.
The 2014 version generates the same boiler-plate code as the Revit 2013 one did, which can be simply deleted if not needed.
Last time around, I egoistically did not implement the VB version until later.
This time though, better realising how much appreciated it is, I took care of that as well, right up front.
It is important to understand how easy it is to modify the wizards for your own needs, and make copies with variations to support different requirements.
Here is an overview of previous explanations of various aspects that also show how create your own flavours:
- Original introduction, benefits, and usage example for C# and VB.
- Personalised minimal C# version for Revit 2011.
- A short additional usage note.
- 64-bit versions for C# and VB.
- Support for the Revit 2012 API for C# and VB.
- Updated C# and VB versions placing assembly DLL alongside add-in manifest and including other changes.
- Revit 2013 C# version including more skeleton code.
- Revit 2013 VB version.
Installing to non-x86 Program Files
I had a new issue to struggle with this time around, mentioned in the list above as well, dealing with 64-bit systems.
My Windows 7 virtual machine is a 64-bit system.
The $(ProgramFiles) used in the Visual Studio project template file automatically resolves that to "C:\Program Files (x86)", which is the wrong location.
Revit 2014 is installed in "C:\Program Files" with no x86 suffix.
Researching this, I found a resolution described and explained in this discussion on MSBuild and $(ProgramFiles) issue with 32/64 bits.
Unfortunately, that did not work at all. MSBuildExtensionsPath64 is not recognised in the Visual Studio wizard, at least in my simple use of it.
In the end, I simply checked what system variables are actually set on my system and found ProgramW6432 instead. That works fine.
Now both the C# and the VB versions work perfectly for me.
Revit Add-in Wizard Usage
I can simply install the wizard zip files in the appropriate locations, start up Visual Studio, create a new C# or VB Revit add-in project using the wizard default settings, and immediately hit F5 to start up Revit.exe in the debugger.
Revit is started up, my add-in is automatically loaded, and I am able to click on my new external command in the External Tools menu to test it immediately without having entered even one single byte of code myself.
The new command even executes in zero document state, although the default external command skeleton implementation throws an exception trying to access a property on the current UI document, which is null. It shows you that everything is working correctly right away, though.
Revit 2014 C# and VB Add-in Wizard Download
So, what are the appropriate locations, then? And where are the zip files?
Right here!
To install, simply copy the zip file of your choice to the matching Visual Studio project template folder in your local file system:
-
Revit2014AddinWizardCs.zip – copy to
[My Documents]\Visual Studio 2010\Templates\ProjectTemplates\Visual C# -
Revit2014AddinWizardVb.zip – copy to
[My Documents]\Visual Studio 2010\Templates\ProjectTemplates\Visual Basic
I hope you find this useful and look forward to your suggestions for improvement.
Jeremy,
This is off topic to this post, but had a question for you regarding the API and weather something was possible.
Do you have access to all parameters in the project, including calculated values, via the API? If not, which values do you have access to? Assuming you have access to a parameter, are you able to create a link between that parameter and another (via the API)? For example (assuming you have access to the area parameter of a room), could I create an addin that would allow me to pick an existing parameter, and create a direct link to a newly created parameter (of the same type) that would update if the existing parameter updated?
Posted by: david | May 12, 2013 at 00:53
Dear David,
Regarding access to parameters, please use RevitLookup and find out for yourself.
Certainly, you can use the Dynamic Model Update DMU in an add-in to update the value of a parameter based on changes in another one.
Cheers, Jeremy.
Posted by: Jeremy Tammik | May 12, 2013 at 03:43
Didn't work on W8, however works great on W7. Many thanx Jeremy.
Posted by: Nik Mulconray | September 30, 2013 at 07:51
Dear Nik,
Thank you for your confirmation and appreciation.
I am using Win7 myself.
I cannot fix it for Win8 until someone forces me to move there myself, so you will either have to do it yourself or find someone else to support you there.
Please also note this updated version:
http://thebuildingcoder.typepad.com/blog/2013/06/sun-direction-shadow-calculation-and-wizard-update.html#2
Cheers, Jeremy.
Posted by: Jeremy Tammik | September 30, 2013 at 08:05
I cannot find the Room tab in Ribbon on Revit Structure 2014, please help.
Posted by: habib | January 05, 2014 at 13:56
Jeremy,
Thanks for the template . . . I installed the files from the zip in the c# project template folder, edited the csproj file in notepad to change the revit.exe location to Revit 2014 instead of Revit Architecture 2014 (my company has the suite, perhaps this is the difference?) and it works perfectly. Now I can start changing my macros to add ins!
Posted by: Paul Gibson | September 09, 2014 at 12:34
Dear Paul,
Thank you for the appreciation. The pleasure is all mine. It is indeed. Yay, way to go!
Cheers, Jeremy.
Posted by: Jeremy Tammik | September 10, 2014 at 16:13
Dear Habib,
Try searching in Revit Architecture instead of Revit Structure.
Rooms are specific to architecture.
Cheers, Jeremy.
Posted by: Jeremy Tammik | September 10, 2014 at 16:15
Jeremy,
I have a unrelated question, Im trying to write a addin in c# in visual studio and I use
form.ShowDialog();
where form is my visual studio designed form, but no items on the form are displayed.
Do I really have to manually add items to a blank form ???
it works if I manually new form();
new every control I want to use on the form manually.
Ive tried googling the subject but I dont seem to find any results.
Regards,
Emil
Posted by: Emil Thor Emilsson | November 03, 2014 at 06:40
Dear Emil,
That sounds like a very strange problem, and your description is rather strange as well.
I have implemented and published samples of two kinds of System.Windows.Forms Form instances: statically created in the IDE, and dynamically created by code.
Examples of dynamically created forms are provided by the RoomEditorApp, in the GeoSnoop module:
https://github.com/jeremytammik/RoomEditorApp/blob/master/RoomEditorApp/GeoSnoop.cs
Also by the ScheduleData add-in, in the DisplayScheduleData method in the discussion:
http://thebuildingcoder.typepad.com/blog/2012/05/the-schedule-api-and-access-to-schedule-data.html
Statically defined forms are used e.g. in the BipChecker and PlaceInstances samples:
https://github.com/jeremytammik/BipChecker
BuiltInParamsCheckerForm.cs(6):
public partial class BuiltInParamsCheckerForm
: Form
https://github.com/jeremytammik/PlaceInstances
PlaceInstancesForm.cs(19):
public partial class PlaceInstancesForm
: Form
Cheers, Jeremy.
Posted by: Jeremy Tammik | November 03, 2014 at 15:00
I do apologize, what happened was the designer generated code really makes a InitializeComponent() function which initializes all the components used in the form. I forgot to call that.
So problem solved, thank you for your help
Regards,
Emil
Posted by: Emil Thor Emilsson | November 04, 2014 at 06:53
Dear Emil,
No problem whatsoever.
I'm glad you got it sorted.
This explanation is much less strange than your problem description, thank God :-)
Cheers, Jeremy.
Posted by: Jeremy Tammik | November 05, 2014 at 11:43