简体   繁体   English

如何在 C# 宏中从 revit 卸载所有链接(Revit、CAD、Pointcloud、IFC)

[英]How to unload all links ( Revit, CAD, Pointcloud, IFC ) from revit in C# macro

I need to batch unload all linked types from Revit file.我需要从 Revit 文件中批量卸载所有链接类型。 So far, I found the code that takes care of Revit links, thanks to one of the posts by到目前为止,我找到了处理 Revit 链接的代码,这要归功于作者的一篇帖子

https://stackoverflow.com/users/200443/maxence https://stackoverflow.com/users/200443/maxence

// Unload all links
        var loadedExternalFilesRef = new List<RevitLinkType>();
        var collector = new FilteredElementCollector(document);
        foreach (Element element in collector.OfClass(typeof(RevitLinkType)))
        {
            ExternalFileReference extFileRef = element.GetExternalFileReference();
            if (null == extFileRef || extFileRef.GetLinkedFileStatus() != LinkedFileStatus.Loaded) 
                continue;
            var revitLinkType = (RevitLinkType)element;
            loadedExternalFilesRef.Add(revitLinkType);
            revitLinkType.Unload(null);
        }

I also need to take care of all links, including CAD, IFC, Pointcloud Seems that Revit API does not allow same functionality for CADlinktype.我还需要处理所有链接,包括 CAD、IFC、Pointcloud 似乎 Revit API 不允许 CADlinktype 具有相同的功能。

Please, advise and thank you for help!请指教并感谢您的帮助!

I implemented a solution to remove DWF links, CmdRemoveDwfLinks .我实现了一个删除 DWF 链接的解决方案, CmdRemoveDwfLinks It is provided as an external command in The Building Coder samples GitHub repo .它在The Building Coder 示例 GitHub 存储库中作为外部命令提供。 The full documentation of the command is provided on The Building Coder blog in the discussion on removing DWF Links , including lots of background information and research that may well help you handle other link types as well. The Building Coder 博客上关于删除 DWF 链接的讨论中提供了该命令的完整文档,其中包括大量背景信息和研究,这些信息和研究也可以很好地帮助您处理其他链接类型。 Good luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM