程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> Revit API判斷直線相交關系移動風管

Revit API判斷直線相交關系移動風管

編輯:C#入門知識

start
[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
  cmdDuctAlign : IExternalCommand
{
     XYZ GetIntersection(Line line1, Line line2)
    {
        IntersectionResultArray results;

        SetComparisonResult result
            = line1.Intersect(line2,  results);
                         (SetComparisonResult.Overlap == result)              InvalidOperationException(
                );
         (SetComparisonResult.Disjoint == result)              InvalidOperationException(
                );
         (SetComparisonResult.Superset == result)              InvalidOperationException(
                );
         (SetComparisonResult.Subset == result)              InvalidOperationException(
                );
         (results ==  || results.Size != )
              InvalidOperationException(
                );

        IntersectionResult iResult
            = results.get_Item();

         iResult.XYZPoint;
    }
     Result Execute(ExternalCommandData commandData,   messages, ElementSet elements)
    {
        UIApplication app = commandData.Application;
        Document doc = app.ActiveUIDocument.Document;
        Selection sel = app.ActiveUIDocument.Selection;

        SplitButtonData splitButtonData =  SplitButtonData(, );
        PushButton pbtn =  PushButton();
        RibbonPanel rpanel =  RibbonPanel();
            

        Transaction ts =  Transaction(doc, );
        ts.Start();

        IList<Reference> refDucts = sel.PickObjects(ObjectType.Element, );
        Duct duct1 = doc.GetElement(refDucts.ElementAt())  Duct;
        Duct duct2 = doc.GetElement(refDucts.ElementAt())  Duct;
        LocationCurve lCurve1 = duct1.Location  LocationCurve;
        LocationCurve lCurve2 = duct1.Location  LocationCurve;
        XYZ xyz11 = lCurve1.Curve.get_EndPoint();
        XYZ xyz12 = lCurve1.Curve.get_EndPoint();
        XYZ xyz21 = lCurve2.Curve.get_EndPoint();
        XYZ xyz22 = lCurve2.Curve.get_EndPoint();
                Line line1 = Line.get_Bound(xyz11, xyz12);
        Line line2 = Line.get_Bound(xyz21, xyz22);
        GetIntersection(line1, line2);

         風管移動

                XYZ xyz1 =  XYZ(xyz11.X, xyz11.Y, );
        XYZ xyz2 =  XYZ(xyz12.X, xyz12.Y, );
        XYZ xyz3 =  XYZ(xyz21.X, xyz21.Y, );
        XYZ xyz4 =  XYZ(xyz22.X, xyz22.Y, );
                XYZ vec1 = xyz2 - xyz1;
        XYZ zVec =  XYZ(, , );
        XYZ nVec = vec1.CrossProduct(zVec).Normalize();        TaskDialog.Show(, nVec.CrossProduct(zVec).Normalize().ToString());
        lCurve2.Move(nVec);

        

        ts.Commit();

         Result.Succeeded;
    }
}url: http://greatverve.cnblogs.com/p/revit-api-line-SetComparisonResult.html
參考:http://revit.haotui.com/thread-171-1-32.htmlhttp://revit.haotui.com/thread-489-1-23.html

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