大神们求帮助,在revit二次开发中,如何获取三维视图数据

新手求教,在线等,急!!
在revit二次开发,如何获取三维视图数据

2个回答

//遍历元素的普通参数
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
[Journaling(JournalingMode.NoCommandData)]
public class OneParameter : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIApplication app = commandData.Application;
Document doc = app.ActiveUIDocument.Document;
FilteredElementCollector collector = new FilteredElementCollector(doc);

        //遍历选中元素的普通参数
        Selection sel = app.ActiveUIDocument.Selection;
        ElementSet es = sel.Elements;
        Element elemPick = null;
        if (es.Size > 0)
        {
            int count_1 = 0;
            int count_2 = 0;
            StringBuilder sb = new StringBuilder();
            foreach (Element elem in es)
            {
                elemPick = elem;
                foreach (Parameter p in elemPick.Parameters)
                {
                    sb.Append(p.Definition.ParameterGroup + "," + p.Definition.Name + "," + p.AsValueString() + "\n");
                    count_2 += 1;
                }
                count_1 += 1;
            }
            TaskDialog.Show("数据", "模型数量:" + count_1 + ",总数:" + count_2 + "\n" + sb.ToString());

        }
        return Result.Succeeded;
    }
}
#endregion

[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
[Journaling(JournalingMode.NoCommandData)]
public class reivtnums : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIApplication app = commandData.Application;
Document doc = app.ActiveUIDocument.Document;

        ElementClassFilter instanceFitler = new ElementClassFilter(typeof(FamilyInstance));
        ElementClassFilter hostFilter = new ElementClassFilter(typeof(HostObject));

        LogicalOrFilter andFilter = new LogicalOrFilter(instanceFitler, hostFilter);

        FilteredElementCollector collector = new FilteredElementCollector(doc);
        collector.WherePasses(andFilter);

        #region 遍历选中实例对象
        //遍历选中实例对象
        //Selection sel = app.ActiveUIDocument.Selection;
        //ElementSet es = sel.Elements;
        //if (es.Size > 0)
        //{
        //    //StringBuilder sb = new StringBuilder();
        //    //foreach (Element el in es)
        //    //{
        //    //    sb.Append("数据:" + el.Id + "," + el.Name + "\n");
        //    //}
        //    //TaskDialog.Show("数据", sb.ToString()); 
        //}
        #endregion

        #region 遍历所有实例对象
        //所有实例对象
        List<string> list = new List<string>();
        foreach (Element el in collector)
        {
            list.Add("数据:" + el.Id + "," + el.Name + "\n");
        }
        StringBuilder sb = new StringBuilder();
        foreach (string str in list)
        {
            sb.Append(str);
        }
        TaskDialog.Show("数据", sb.ToString());
        #endregion
        ViewType vt = commandData.View.ViewType;

        //collector.ToElementIds().Count.ToString() 所有实例对象数量
        //TaskDialog.Show("numbers", collector.ToElementIds().Count.ToString());
        return Result.Succeeded;
    }
}
#endregion
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐