在Revit项目文件中,可以使用以下方法区分内建构件和载入构件:

  1. 使用元素的类别(Category)属性:
FilteredElementCollector collector = new FilteredElementCollector(doc);
ICollection<Element> elements = collector.OfClass(typeof(FamilyInstance)).ToElements();

foreach (Element element in elements)
{
    FamilyInstance familyInstance = element as FamilyInstance;
    if (familyInstance != null)
    {
        if (familyInstance.Symbol.Family.IsInPlace)
        {
            // 内建构件
            // ...
        }
        else
        {
            // 载入构件
            // ...
        }
    }
}
  1. 使用元素的族(Family)属性:
FilteredElementCollector collector = new FilteredElementCollector(doc);
ICollection<Element> elements = collector.OfClass(typeof(FamilyInstance)).ToElements();

foreach (Element element in elements)
{
    FamilyInstance familyInstance = element as FamilyInstance;
    if (familyInstance != null)
    {
        if (familyInstance.Symbol.Family.IsInPlace)
        {
            // 内建构件
            // ...
        }
        else
        {
            // 载入构件
            // ...
        }
    }
}
  1. 使用元素的文件路径(FilePath)属性:
FilteredElementCollector collector = new FilteredElementCollector(doc);
ICollection<Element> elements = collector.OfClass(typeof(FamilyInstance)).ToElements();

foreach (Element element in elements)
{
    FamilyInstance familyInstance = element as FamilyInstance;
    if (familyInstance != null)
    {
        string familyFilePath = familyInstance.Symbol.Family.FamilyFilePath;

        if (string.IsNullOrEmpty(familyFilePath) || familyFilePath.StartsWith("<Project Path>"))
        {
            // 内建构件
            // ...
        }
        else
        {
            // 载入构件
            // ...
        }
    }
}

请注意,上述代码中的doc是Revit项目文件的Document对象。

Revit项目文件:如何区分内建构件和载入构件?

原文地址: https://www.cveoy.top/t/topic/p22X 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录