zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    pyftpdlib 搭建FTP服务器
    numpy 解一道简单数学题
    python 实现词云
    个人的毕业长足---- 暴走北京
    Tensorflow of GPU, hello fish by version 0.8.
    图像识别
    用一个Inception v3 架构模型实现简单的迁移学习(译:../tensorflow/tensorflow/examples/image_retraining/retrain.py)
    19.液晶屏的原理
    18.DMA-6410
    17.DMA-2440
  • 原文地址:https://www.cnblogs.com/greatverve/p/api-Sprinklers.html
Copyright © 2011-2022 走看看