Today, let's return to the recurring topic of getting started with the Revit API, its SDK samples, and programming in general:
- My First Revit Plugin enhancements
- Getting started with web programming – FreeCodeCamp
- ModelessForm_ExternalEvent initialisation
My First Revit Plugin Enhancements
A couple of people recently mentioned issues getting started with the Revit API, e.g. in the Revit API discussion forum threads on Revit API Visual Studio error/warnings and IExternalCommand could not be found.
There are several ways to quickly get started with the Revit API, which I present as completely and succinctly as I can in the getting started overview.
The first problem you might encounter is getting your add-in loaded into Revit.
That is simple to resolve once you understand what is going on.
Once way is to follow the developer guide section on getting started and work through the hello world samples presented there.
Another way is to follow the My First Plugin video tutorial.
Elie Accari very kindly shared a couple of valuable enhancement suggestions for it in his thread on My First Plugin – quick modification:
I refer to the high entropy body of knowledge in My First Plugin.
Other threads mentioned issues some users are facing getting the plugin to work.
The above linked page includes a feedback email which has bounced back ("myfirstplugin wasn't found at autodesk.com"), so I am posting here in case new users seek to implement the same modification.
Issue #1: Location of the Plugin
Not all users have access to the
AddIns folder in
Program Files, but all users have access to the %AppData%\Roaming\Autodesk\Revit\addins\
Issue #2: Unfamiliar Behaviour
The code does not properly copy the group. It just places it where you click, which could be in the middle of the other room. A more familiar way is to do a Copy-From:-To:. Only 3 lines of code including 2 modifications are required.
Modification #1: Pick 2 points and calculate the distance between the two, instead of picking only 1 point.
To do so, replace the following code in the original lesson:
//Pick a point XYZ point = sel.PickPoint("Please pick a point to place group");
With the following:
//Pick a point XYZ pointFrom = sel.PickPoint("Pick a point to copy From"); XYZ pointTo = sel.PickPoint("Pick a point to copy To"); //Calculate the distance between the two points XYZ ptDist = pointTo - pointFrom;
Modification #2: Use the Copy method instead of Place
Replace the following line between the
With this line:
ElementTransformUtils.CopyElement(doc, elem.Id, ptDist);
Finally, a suggestion: the text seem to entice Revit users into programming. In this regard, I would consider doing the following:
Add Lesson 0 (or renumber the lessons): Implement the same code in a macro using the Edit / SharpDevelop IDE readily accessible from inside Revit, without going to Microsoft Visual Studio.
Then Lesson 1 could become: Now let's do this again by converting this macro into an add-in.
Ever so many thanks to Elie for his constructive criticism and extremely helpful advice and suggestions!
I passed it on to my colleagues for consideration next time the tutorial is re-recorded.
Getting Started with Web Programming – FreeCodeCamp
By the way, in case you are interested in getting started with web programming in addition to the desktop and .NET based Revit API, I can recommend the training sequence provided by freeCodeCamp covering the following list of topics:
- Front End Development Certification
- HTML5 and CSS
- Responsive Design with Bootstrap
- Basic Front End Development Projects
- Object Oriented and Functional Programming
- Basic Algorithm Scripting
- JSON APIs and Ajax
- Intermediate Front End Development Projects
- Intermediate Algorithm Scripting
- Advanced Algorithm Scripting
- Advanced Front End Development Projects
- Claim Your Front End Development Certificate
- Data Visualization Certification
- React Projects
- Data Visualization Projects
- Claim Your Data Visualization Certificate
- Back End Development Certification
- Automated Testing and Debugging
- Node.js and Express.js
- API Projects
- Dynamic Web Application Projects
- Claim Your Back End Development Certificate
- Video Challenges
- Computer Basics
- The DOM
- Chrome Developer Tools
- Big O Notation
- Computer Science
- Data Visualization
- Embedded and Internet of Things
- Game Development
- Machine Learning
- Math for Programmers
- Software Engineering Principles
- User Experience Design
- Visual Design
- Open Source for Good
- Coding Interview Preparation
- Coding Interview Training
- Mock Interviews
If you are a complete beginner undecided what language to start with, the 11-minute video on what programming language should I learn? Front-end? Back-end? Machine learning? might help:
Before closing, let me mention another little hint resolving an issue encountered by Aziz in the ModelessForm_ExternalEvent SDK sample:
Question: I am new to develop in Revit API getting started tutorials and all is going well until now, when I started with the SDK samples.
I am just trying to implement the
ModelessForm_ExternalEvent sample, but it keeps throwing me an exception stating that Object reference not set to an instance of an object.
Answer: However, after more trials, I tried to change something and it did magically work. I created a class instance from but not assigning it a null value. I am sharing it below in case someone else is experiencing the same issue:
// class instance Public static Application thisApp = new Application();