程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> 應用revit api畫垂直於風管的風管示例

應用revit api畫垂直於風管的風管示例

編輯:C#入門知識

應用revit api畫垂直於風管的風管示例。本站提示廣大學習愛好者:(應用revit api畫垂直於風管的風管示例)文章只能為提供參考,不一定能成為您想要的結果。以下是應用revit api畫垂直於風管的風管示例正文



/// <summary>
/// 選擇風管與風管外一點,畫與風管垂直的風管。
/// </summary>
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmd : IExternalCommand
{
    public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
    {
        UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
        UIApplication uiApp = cmdData.Application;
        Document doc = uiDoc.Document;
        Selection selection = uiDoc.Selection;

        Transaction ts = new Transaction(doc, "http://www.jb51.net");
        ts.Start();
        //獲得一種風管類型
        DuctType ductType = null;
        FilteredElementCollector collector = new FilteredElementCollector(doc);
        collector.OfClass(typeof(DuctType));
        foreach (Element el in collector.ToElements())
        {
            ductType = el as DuctType;
            break;
        }
        //
        Reference refDuct = selection.PickObject(ObjectType.Element, "選擇一根風管:");
        Duct duct = doc.GetElement(refDuct) as Duct;
        XYZ xyz = selection.PickPoint();//選擇一點
        LocationCurve lCurve = duct.Location as LocationCurve;
        IntersectionResult interResult = lCurve.Curve.Project(xyz);//點在直線上的投影
        if (interResult != null)
        {
            doc.Create.NewDuct(xyz, interResult.XYZPoint, ductType);
        }
        ts.Commit();
        return Result.Succeeded;
    }
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved