Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Revit Add-ins Tutorial needs an update for version 2021.1

Message 1 of 9
481 Views, 8 Replies

Revit Add-ins Tutorial needs an update for version 2021.1

I was working through the Revit Tutorial and discovered the following issue:

In lesson 6 of the Tutorial, there are references to the Room Class.   It appears that in Revit 2021.1 and later the Room class has been moved from Autodesk.Revit.DB to Autodesk.Revit.DB.Architecture.   And this causes lesson 6 to not work as described as it can't find the class when you edit your code.  This tutorial should include instructions for people using the newer version of Revit to include this using statement:
"using Autodesk.Revit.DB.Architecture;"
This should probably be added to lesson 1 which adds the using statements, though that particular using statement won't get used until lesson 6.

Message 2 of 9

It is always good to highlight issues with the tutorials as I suspect there are probably quite a few similar out of date items.  Likelihood is you are right regarding things not happening as originally anticipated by the author of such tutorials. However room has always been in the DB.Architecture namespace. So this means what you are seeing may be related to something else not aligned to newer versions.






Message 3 of 9

I'm using C#, so using statement, not import for me.
If that class has always been within the Architecture folder then , maybe there was just some editorial mistake and the using statement I suggested was just accidentally deleted. At any rate, I added that using statement and the code seems to work fine now. The Tutorial should probably be updated to include it for future readers. It's quite a good Tutorial otherwise. One other thing - I'm a software developer, so it's not an issue for me but the Author seems to be targeting an audience that has not coded before. (Which is fine) But what might be problematic is the Author reusing the same variable names within different scopes. (repeating a variable name in a method that's used elsewhere outside the method) And the author does not call out that he's doing this and explain variable scope. I would recommend the Author just use different variable names to avoid confusion by "new coders" or explain variable scope.
Message 4 of 9

Hi @mikeboyle4NFEU, I have just finished My First Plugin blog as a first timer in Revit API and I have not encountered this namespace discrepancy. Could you kindly point to exact place giving this issue if you still remember? I will try to update if the situation persist.

Carol Gitonga, Developer Advocacy and Support, ADN Open
Message 5 of 9

Hello, this is Mike Boyle (using my other email address). Here are the issues I found:

the using statements shown in both lesson 1 and shown again in lesson 3 do contain:
“using Autodesk.Revit.DB”
But it also needs, and is missing:
“using Autodesk.Revit.DB.Architecture”

And in Lesson 7 Step 3 the PlaceFurnitureInRooms method is defined using a generic list, but the type of the generic list is not declared in the parameter list.

Here is the line the way it appears in the documentation:
public void PlaceFurnitureInRooms(Document doc, IList rooms, XYZ sourceCenter, GroupType gt, XYZ groupOrigin)

It should be:
public void PlaceFurnitureInRooms(Document doc, IList rooms, XYZ sourceCenter, GroupType gt, XYZ groupOrigin)

Message 6 of 9

In your post, I see no difference between the 'it looks like' and 'it should be' lines. Maybe the angle brackets were stripped. Maybe they were stripped in the documentation as well. Tricky beasts, escape codes.


Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 7 of 9

@mikeboyle4NFEU , Thank you for the follow up on this issue. I would tend to think that for new users of Revit API have taken time and interest to learn some concepts on .NET framework and interacted with the IDE like Visual studio or VS code. Once you reference the RevitAPI and RevitAPIUI dll files on your project. The IDE provides an intellisense feature to help you import the right/correct namespaces for any object, interface, class you wish to consume on your code. One does not need to memorize the namespaces. Prior preparations to start learning Revit API are provided here:



Carol Gitonga, Developer Advocacy and Support, ADN Open
Message 8 of 9

On the Using statement.  I too am using C# in visual studio 2015.   And I definitely had to add the explicit Using statement "Using AutoDesk.Revit.DB.Architecture".   Without it I was getting a "Type or Namespace not found" error for the Rooms Type.  I just commented out that using statement  from my code, and the error reappears.

and yes it appears my Chevron bracket (The brackets that look like sideways "V"'s) text did get stripped by the editor when I posted what he text should look like.

I'll substitute [ ]  brackets in for the sideways V brackets, which I'm guessing the text editor is thinking are XML brackets.

public void PlaceFurnitureInRooms(Document doc, IList[Reference] rooms, XYZ sourceCenter, GroupType gt, XYZ groupOrigin)


Message 9 of 9

I bet it's the editor which is making the correct syntax non-visible in the documentation as well.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups

Rail Community