• Revit API遍历系统族布置喷头


    系统族可以通过内参遍历,遍历出来是个FamilySymbol
    喷头属于系统族,但不能通过NewDuct();类似这样的方法布置。
    必须使用
    NewFamilyInstance()
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    using WinForm = System.Windows.Forms;

    using Autodesk.Revit.UI;
    using Autodesk.Revit.DB;
    using Autodesk.Revit.Attributes;

    using Autodesk.Revit.DB.Mechanical;
    using Autodesk.Revit.UI.Selection;
    using Autodesk.Revit.ApplicationServices;

    using Autodesk.Revit.DB.Structure;
    using Autodesk.Revit.DB.ExtensibleStorage;
    using Autodesk.Revit.DB.Plumbing;
    using Autodesk.Revit.DB.Architecture;

    using System.Xml;

    namespace RevitCodes
    {

        [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
        
    public class cmdSprinklers : IExternalCommand
        {
            
    public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
            {
                UIApplication uiApp 
    = commandData.Application;
                Document doc 
    = uiApp.ActiveUIDocument.Document;
                Selection sel 
    = uiApp.ActiveUIDocument.Selection;

                Transaction ts 
    = new Transaction(doc, "http://revit.5d6d.com");
                ts.Start();

                
    //从系统族中过滤出喷头,是作为一个FamilySymbol存在的
                FilteredElementCollector collector = new FilteredElementCollector(doc);
                
    //此法可以只过滤系统类型
                
    //collector.OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_Sprinklers);
                collector.OfCategory(BuiltInCategory.OST_Sprinklers);
                FamilyInstance fi 
    = null;//如果已经布置了,就是族实例
                int iFi = 0;
                FamilySymbol symbol 
    = null;//系统族是族符号
                int iFs = 0;
                
    foreach (Element el in collector.ToElements())
                {
                    fi 
    = el as FamilyInstance;
                    
    if (fi != null)
                        iFi 
    += 1;
                    symbol 
    = el as FamilySymbol;
                    
    if (symbol != null)
                        iFs 
    += 1;
                }
                TaskDialog.Show(
    "count", iFi + "," + iFs);
                
    if (fi != null)
                    doc.Create.NewFamilyInstance(
    new XYZ(101010), fi.Symbol, StructuralType.Beam);
                
    if (symbol != null)
                    doc.Create.NewFamilyInstance(
    new XYZ(101010), symbol, StructuralType.Beam);

                ts.Commit();

                
    return Result.Succeeded;
            }
            XYZ PointOnFace(PlanarFace face)
            {
                XYZ p 
    = new XYZ(000);
                Mesh mesh 
    = face.Triangulate();

                
    for (int i = 0; i < mesh.NumTriangles; ++i)
                {
                    MeshTriangle triangle 
    = mesh.get_Triangle(i);
                    p 
    += triangle.get_Vertex(0);
                    p 
    += triangle.get_Vertex(1);
                    p 
    += triangle.get_Vertex(2);
                    p 
    *= 0.3333333333333333;
                    
    break;
                }
                
    return p;
            }
        }
    }
    url:http://greatverve.cnblogs.com/p/api-Sprinklers.html
  • 相关阅读:
    Solr6 Suggest(智能提示)
    Oracle12c:安装后新建用户及其默认表空间,并创建表测试
    Django:使用PyCharm创建django项目并发布到apache2.4
    后台收集
    Hadoop+Spark:集群环境搭建
    Hadoop:搭建hadoop集群
    Linux:SSH错误"WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! "
    Linux:Ubuntu14.04离线安装scala(在线安装)
    Linux:Ubuntu 14.04 Server 离线安装Jjava8(及在线安装)
    Linux:实现Hadoop集群Master无密码登录(SSH)各个子节点
  • 原文地址:https://www.cnblogs.com/greatverve/p/api-Sprinklers.html
Copyright © 2020-2023  润新知