风管的Level值为空,墙对应Level,风管对应ReferenceLevel
//找到标高1上的所有风管
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
//[Journaling(JournalingMode.NoCommandData)]
public class cmdGetLevelDuct : IExternalCommand
{
    
public Result Execute(ExternalCommandData cmdData, ref string message, ElementSet elements)
    {
        UIDocument uiDoc 
= cmdData.Application.ActiveUIDocument;//base.m_uiDoc
        Selection selection = uiDoc.Selection;

        Transaction ts 
= new Transaction(uiDoc.Document, "LevelDuct");
        ts.Start();

        FilteredElementCollector collector 
= new FilteredElementCollector(uiDoc.Document);
        collector.OfClass(
typeof(Duct)).OfCategory(BuiltInCategory.OST_DuctCurves);

        
foreach (Element el in collector)
        {
            Duct duct 
= el as Duct;
            
if (duct.ReferenceLevel.Name == "标高 1")
                TaskDialog.Show(
"title", duct.Id.ToString());
        }

        ts.Commit();

        
return Result.Succeeded;
    }
}
from:http://revit.5d6d.com/thread-1204-1-1.html

相关文章:

  • 2021-10-30
  • 2021-09-11
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案