Now, the Revit .NET Addin Wizard also supports C++.
No extra Visual C++ node will be created in the pane of the Project types of the New Project window. The Revit .NET Addin template can be found under the same node as where the common Visual C++ templates (e.g. MFC Application, Windows Forms Application, CLR Empty Project, Class Library, etc.) can be:
Other steps and UIs are just the same. The resulting VC++ addin project is different from C# or VB.NET. We name a few below:
Many .NET Framework namespaces will be imported in the header file Stdafx.h; many Revit API namespaces will be imported in another header file Namespaces.h; the command images will be added into a resource file Resources.resx.
A sample source file of the external command created by the wizard may look like the following:
#include "stdafx.h"
#include "Namespaces.h"
namespace RevitAddinVCTest
{
[Transaction(TransactionMode::Manual)]
[Regeneration(RegenerationOption::Manual)]
public ref class ExtCmd : IExternalCommand
{
#pragma region Cached Variables
private:
static ExternalCommandData^ _cachedCmdData;
public:
static property UIApplication^ CachedUiApp
{
UIApplication^ get()
{
return _cachedCmdData->Application;
}
}
static property RvtAppSrv::Application^ CachedApp
{
RvtAppSrv::Application^ get()
{
return CachedUiApp->Application;
}
}
static property RvtDB::Document^ CachedDoc
{
RvtDB::Document^ get()
{
return CachedUiApp->ActiveUIDocument->Document;
}
}
#pragma endregion
#pragma region IExternalCommand Members
public:
virtual Result Execute(ExternalCommandData^ cmdData, String^% msg, ElementSet^ elemSet)
{
_cachedCmdData = cmdData;
try
{
//TODO: add your code below.
return Result::Succeeded;
}
catch(System::Exception^ ex)
{
ex->ToString()->Copy(msg);
return Result::Failed;
}
return Result::Succeeded;
}
#pragma endregion
};
}
Links to some related articles:
RevitAddinWizard - A Wizard For Revit Addins
Recent Comments