Revit 2025 Macros

Revit 2025 Macros

sragan
Collaborator Collaborator
1,636 Views
6 Replies
Message 1 of 7

Revit 2025 Macros

sragan
Collaborator
Collaborator

I can't get any of my previous macros to work with Revit 2025.  I have spent practically all day installing Visual Studio Code, and the SDK on one of the Revit Macro Links.   

 

Then I copied the macros to the 2025 Macro Folder, and I changed the targeted framework in the csproj file as listed here:

 

Help | Upgrade Revit Macros | Autodesk

 

I don't understand visual studio code at all - it doesn't seem to work at all like VS or Sharp Develop.  I tried a few turorials, but I can't even tell what is going on in it, or what the error is.   All in all, VS Code looks like a total piece of *#$##.

 

But it starts having errors on the first Autodesk.Revit.Attributes.Transaction line.   and it says "Document" and "Element" cant be found.  Am I missing a reference I have to add?   I'm not sure how to do that in Visual Studio Code, or if it even has that feature.  

 

Anyhow, If i open my code in Visual Studio 2019, it says "Project contains incorrect configuration mappings.  Open the configuration manager to fix them."   But when i click the button, nothing happens.   

 

In Visual Studio, I also get the message  "The type  Enum is defined is in an assembly that is not referenced.  YOu must add a reference to assembly "Systme.Runtime, Verion = 8.0.0.0, Culture = neutral, PublicKeyToken......"

 

How do I add that, and where do i find it?

 

 

 

 

 

0 Likes
Accepted solutions (3)
1,637 Views
6 Replies
Replies (6)
Message 2 of 7

ricaun
Advisor
Advisor
Accepted solution

The docs looks incorrect is showing to use net7.0-windows, Revit 2025 is net8.0-windows.

 

ricaun_0-1730373700995.png

 

Don't know if that's the issue but usually is easier to create a new Macro and copy the code to the new project.

 

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes
Message 3 of 7

sragan
Collaborator
Collaborator

I will have to try changing that.   I kind of noticed it wasn't 8, but I blindly followed the instructions without thinking twice.

 

And yes, I was also going to try to recreate the Macro, but I can't figure out how to add references to things like System.Windows.Forms.   I think I need to install a NuGet package to do that, but I haven't got it working yet.   If I type NuGet:Add in the command bar, nothing comes up.

 

Next thing to try is to point the Macros to Visual Studio, since I've seen your video Rican.  Or I wonder if it would be possible to point it to one of the older Sharp Develop editors installed with something like Revit 2024?

 

 

 

 

 

0 Likes
Message 4 of 7

ricaun
Advisor
Advisor
Accepted solution

Usually the references of the Forms can be added by a configuration in the csproj.

 

ricaun_1-1730385505852.png

<PropertyGroup>
  <UseWindowsForms>true</UseWindowsForms>
  <UseWPF>true</UseWPF>
</PropertyGroup>

Just add the UseWindowsForms to add all the references for Forms and UseWPF for wpf references.

 


@sragan  escreveu:
Next thing to try is to point the Macros to Visual Studio, since I've seen your video Rican. Or I wonder if it would be possible to point it to one of the older Sharp Develop editors installed with something like Revit 2024?

Probably Sharp Develop does not support net core, I don't think is possible to use to work with a Macro for Revit 2025.

 

I suppose you are using Visual Studio to open/build the macro, that's much better than VS Code.

 

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes
Message 5 of 7

sragan
Collaborator
Collaborator

That didn't seem to work the first time I tried it, but after a second attempt, that seemed to do the trick.

 

0 Likes
Message 6 of 7

sragan
Collaborator
Collaborator
Accepted solution

For those of you new to Visual Studio Code (like I am), once you start a new module, and type in some code, you have to open a new terminal with the path pointing to your project directory.  Then you have to type in "dotnet build" to build the project and to get it to show up as a runnable project in the Macro Editor.

 

This is explained in the Revit 2025 Help under "Customize Revit" and  "Automating Tasks with Macros".

 

Guess I should have started there.

 

0 Likes
Message 7 of 7

sragan
Collaborator
Collaborator
0 Likes