Revit macro editor

Revit macro editor

jaboone
Advocate Advocate
2,298 Views
10 Replies
Message 1 of 11

Revit macro editor

jaboone
Advocate
Advocate

I would rather start building a project in the macro editor then transfer it to VS.  The ide is throwing an error saying that revit exe is built in 4.5.2, but the ide only goes up to 4.5.  It is also throwing errors on two lines of code.

 

The primary reference "..\..\..\..\..\..\RevitAPIUI.dll" could not be resolved because it was built against the ".NETFramework,Version=v4.5.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5". (MSB3274)

 

The type or namespace name 'Selection' does not exist in the namespace 'Autodesk.Revit.UI' (are you missing an assembly reference?) (CS0234) - C:\Users\jboone\AppData\Local\Temp\{940F3BEE-310D-4BA5-90AE-6B65E73D6E11}\Revit\DocHookups4024\299439616\MRM05\Source\MRM05\ThisDocument.cs:17,25

 

The type or namespace name 'Macros' does not exist in the namespace 'Autodesk.Revit.UI' (are you missing an assembly reference?) (CS0234) - C:\Users\jboone\AppData\Local\Temp\{940F3BEE-310D-4BA5-90AE-6B65E73D6E11}\Revit\DocHookups4024\299439616\MRM05\Source\MRM05\ThisDocument.Designer.cs:11,66

 

I suspect it is because I am not building in 4.5.2 .net framework.  What to do?

Learning as I go
0 Likes
Accepted solutions (2)
2,299 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable

I don't have much experience with the built-in IDE (which is SharpDevelop which hasn't had any contributions in the last 2.5 years)...

 

I would say, try installing/reinstalling .NET 4.5.2 targetting pack and see if that helps:  

https://www.microsoft.com/en-us/download/details.aspx?id=42637

 

Also, what version of Revit are you using? Make sure you have all the updates installed (for Revit and Windows).

 

I would strongly encourage switching to Visual Studio. It's free and the overhead is pretty minor relative to working in built-in IDE. The benefits are huge: such as support, reliability, updates, etc.

 

Mark

UpCodes Engineering - we are hiring Revit & Windows developers!

0 Likes
Message 3 of 11

jaboone
Advocate
Advocate

No sir, good idea but it didn't work.  Look like the interface is not allowing me to go that high.

This is Revit 2017, which I am surprised that it has a build that high with it being so old.

 

Yes i have VS 2017 installed but want to use the macro to get the debugging done before I export it to that platform.

Learning as I go
0 Likes
Message 4 of 11

jaboone
Advocate
Advocate

I will also say that it work just fine up to 3 or 4 months ago when I built it, but for some reason is not when I built it this past week.  Not sure what changed to make it start having those errors.

Learning as I go
0 Likes
Message 5 of 11

Anonymous
Not applicable
Accepted solution

.NET 4.5 and 4.5.2 are the same thing, they are both built on top of the same core CLR (v4) and they are compatible.

 

OK, poking around a bit I think I know the issue. Try the following:

  1. Open your macro project.
  2. Right-click on one of the .cs files and click "Open Containing Folder in Explorer"
  3. Close Revit and SharpDevelop
  4. Go to Explorer, you should see a .csproj file in there, open it in notepad (or some other text editor)
  5. You will see lines like this:

 

    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <TargetFrameworkProfile>
    </TargetFrameworkProfile>

6. Replace them with:

 

 

    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <TargetFrameworkProfile>Client</TargetFrameworkProfile>

7. Save the .csproj

 

Reopen Revit and try opening your project. It should (hopefully) work now

 

Message 6 of 11

stever66
Advisor
Advisor

 Try using project upgrade under the tools menu.

 

0 Likes
Message 7 of 11

zhong_wu
Autodesk Support
Autodesk Support
Accepted solution

I believe changing the project to use "Client" as TargetFrameworkProfile should be the right answer, I also verified on my side just now, it works for me.

 

    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>

    <TargetFrameworkProfile>Client</TargetFrameworkProfile>

 


John Wu
Developer Technical Services
Autodesk Developer Network


0 Likes
Message 8 of 11

jaboone
Advocate
Advocate

Thank you mark for your solution but it was very tricky to get the code to change because that procedure for editing changed directories when there is a build.  I eventually was able to change the Client in that line.

Learning as I go
0 Likes
Message 9 of 11

stever66
Advisor
Advisor

i don't understand why you had to do so much work to get a macro to run.

 

i assume you are using the built in sharp macro editor?  When you start a new module/macro, the references to the revit dll's are already included.   And the .Net version is also set.  You should be able to just type the code and build.

0 Likes
Message 10 of 11

jaboone
Advocate
Advocate

It happened again so I have to set it back to where it was.  I don't like having to do the same solution over and over.

Learning as I go
0 Likes
Message 11 of 11

didier092018
Community Visitor
Community Visitor

For me worked just fine the Mark and Zhong.wu solution👍

0 Likes