前言
日志,还能回放,这功能太逆天了。第一次尝试失败了,搜了大牛 Jeremy Tammik 的博客,发现 Revit 居然还有这样诡异的设置才能回放,也是醉了。
项目地址
路径:Revit 2020.1 SDK\Samples\Journaling\CS\Command.cs
录制与回放
通过 AddinManager 加载生成的 dll,生成一堵墙:
效果:
从你的日志文件里面查找:
Jrn.RibbonEvent "TabActivated:附加模块"
Jrn.RibbonEvent "Execute external command:8c0a9e25-b7c5-421c-a1ab-702f73fa551f:AddInManager.CAddInManager"
Jrn.Data "APIStringStringMapJournalData" _
, 4, "End Point", "(100,0,0)" _
, "Level Id", "311", "Start Point" _
, "(0,0,0)", "Wall Type Name", "Cavity wall_sliders"
这个就是关键,不过我自己尝试重播日志,失败了。
如何才能成功?
下面这段话最重要的就是,把 journal,addin,插件dll放在同一个目录下面。这样就可以正常回放了。
However, several people had problems getting the Journaling sample to run in Revit 2012. This is due to changes in the add-in loading behaviour introduced in the recent releases of Revit in connection with the shift from INI files to the add-in manifest.
Here is the quick summary of the solution, which is utterly simple but
pretty hard to discover on your own:To run this sample, make sure that the journal file, the add-in
manifest (.addin) and the add-in assembly (.dll) are all in the same
folder, otherwise it definitely will not work. This is by design, to
reduce the impact during regression testing: in this way, only the
required add-ins in the journal folder will be registered and loaded
by Revit.This ties in very well with my current tendency to copy all add-in
assemblies into the Revit add-in folder, where the add-in manifests
have to be placed in order for Revit to find them. As I mentioned
discussing the add-in wizard updates, this has the significant
advantage of obviating the need to specify the full assembly path in
the add-in manifest.
代码逻辑
关键点在于:
public void Run()
{
// 根据是否有日志数据来决定用何种方式创建墙
if (m_canReadData) // 如果有日志数据
{
ReadJournalData(); // 读取日志数据
CreateWall(); // 创建墙
}
else // 如果没有日志数据
{
if (!DisplayUI()) // 显示UI
{
return; // 如果用点了取消,直接退出
}
CreateWall(); // 创建墙
WriteJournalData(); // 写入日志
}
}
参考
https://thebuildingcoder.typepad.com/blog/2011/11/loading-an-add-in-with-a-journal-file.html