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

How can my Addin support each REVIT 2012/2014 on same computer?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
648 Views, 2 Replies

How can my Addin support each REVIT 2012/2014 on same computer?

Hi.

 

some API/Object different REVIT 2012 / 2014. (like get_Element / GetElement)
i can not compile my source when i change REVIT 2014 RevitAPI.DLL & RevitApiUI.DLL.
so i think, make different DLL & different '.addin' file for REVIT 2014 / REVIT others.

 

but i can not know, what REVIT version call my DLL.

when OnStartUp function enroll button & event in my DLL. so i need i will use 2014.DLL or 2012.DLL.

but 

RevitProduct revitProduct1 = RevitProductUtility.GetAllInstalledRevitProducts()[0];

RevitAddInManifest revitAddInManifest = 
     Autodesk.RevitAddIns.AddInManifestUtility.GetRevitAddInManifest(
          revitProduct1.AllUsersAddInFolder + "\\RevitAddInUtilitySample.addin");

 this code only for first installed REVIT info.

sure, i think compare each Products[] between current excute REVIT version.

but i can not use Revit.Application.Application.VersionName because Revit is NULL.

 

how can i support each REVIT 2012/2014 on same computer?

2 REPLIES 2
Message 2 of 3
jeremytammik
in reply to: Anonymous

Dear combachi,

 

Yes, you have to create a different version of your .NET add-in assembly for each version of Revit.

 

They are placed in separate directories for loading, e.g. for Revit 2014 one of these:

 

/ProgramData/Autodesk/Revit/Addins/2014
/Users/All Users/Autodesk/Revit/Addins/2014
/Users/<username>/AppData/Roaming/Autodesk/Revit/Addins/2014

 

When your add-in is loaded, it can query the application object for its version information, e.g. using the the Application VersionBuild, VersionName and VersionNumber properties.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 3
Anonymous
in reply to: Anonymous

I solved like this.

 

first.

make differrent DLL name & .addin name for REVIT2012 / REVIT2014.

 

Next. change code like this

Old Code

Autodesk.RevitAddIns.RevitProduct oRP = Autodesk.RevitAddIns.RevitProductUtility.GetAllInstalledRevitProducts()[0];
Autodesk.RevitAddIns.RevitAddInManifest oManifest = Autodesk.RevitAddIns.AddInManifestUtility.GetRevitAddInManifest(
oRP.AllUsersAddInFolder + @"\MyProgram.AddIn");

New Code

string sExeName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().Location);



foreach (Autodesk.RevitAddIns.RevitProduct oRP in Autodesk.RevitAddIns.RevitProductUtility.GetAllInstalledRevitProducts()) { if (File.Exists(oRP.AllUsersAddInFolder + @"\" + sExeName + @".Addin") == true) { Autodesk.RevitAddIns.RevitAddInManifest oManifest = Autodesk.RevitAddIns.AddInManifestUtility.GetRevitAddInManifest( oRP.AllUsersAddInFolder + @"\" + sExeName + @".Addin"); break; } }

 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community