新建项目

如果没有C++类库模板,先安装生成工具

项目配置
- 添加引用

-
在头文件中添加外部命令接口
#pragma once using namespace System; using namespace Autodesk::Revit::Attributes; using namespace Autodesk::Revit::UI; using namespace Autodesk::Revit::DB; namespace ClassLibrary3 { [Transaction(TransactionMode::Manual)] public ref class Class1 :IExternalCommand { public: virtual Result Execute(ExternalCommandData^ commandData,String^% message, ElementSet^ elements); // TODO: 在此处为此类添加方法。 }; }
-
cpp文件
#include "pch.h" #include "command.h" Result RevitTestCpp::Command::Execute(ExternalCommandData^ commandData, String^% message, ElementSet^ elements) { auto doc = commandData->Application->ActiveUIDocument->Document; TaskDialog::Show("Hello Revit Cpp",doc->PathName); return Result::Succeeded; }
-
修改为x64平台
网友评论