1. 程式人生 > >Revit二次開發基礎知識

Revit二次開發基礎知識

獲取應用、文件及當前檢視資訊

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {           
            
            UIApplication uiapp = commandData.Application;
            Application app = uiapp.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document doc = uidoc.Document;
            View view = commandData.View;
            LanguageType lt = app.Language;
            ProductType pt = app.Product;
            string s = "Application = " + app.VersionName
              + "\r\nLanguage = " + lt.ToString()
              + "\r\nProduct = " + pt.ToString()
              + "\r\nVersion = " + app.VersionNumber
              + "\r\nDocument path = " + doc.PathName // empty if not yet saved
              + "\r\nDocument title = " + doc.Title
              + "\r\nView name = " + view.Name;
            TaskDialog.Show("In",s);
            return Result.Succeeded;
        }

根據點集合連線 

                List<XYZ> corners = new List<XYZ>(4);
                corners.Add(XYZ.Zero);
                corners.Add(new XYZ(5, 0, 0));
                corners.Add(new XYZ(5, 10, 0));
                corners.Add(new XYZ(0, 10, 0));
                for (int i = 0; i < 4; ++i)
                {
                    Line line = Line.CreateBound(corners[i], corners[3 == i ? 0 : i + 1]);
                }