Beispiel #1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document doc = uidoc.Document;

            DockablePaneProviderData dpData = new DockablePaneProviderData();
            DockPanel browser = new DockPanel();

            dpData.FrameworkElement = browser as System.Windows.FrameworkElement;

            List <RibbonPanel> ribbon = uiapp.GetRibbonPanels();

            foreach (var item in ribbon)
            {
                TaskDialog.Show("ribbon", item.ToString());
            }

            //FilteredElementCollector col
            //  = new FilteredElementCollector(doc)
            //    .WhereElementIsNotElementType()
            //    .OfCategory(BuiltInCategory.INVALID)
            //    .OfClass(typeof(Wall));

            return(Result.Succeeded);
        }
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document doc = uidoc.Document;



            // Access current selection
            UserControl1 userControl = new UserControl1(doc);

            userControl.ShowDialog();

            /* Window win = new Window();
             * win.Content = userControl;
             * win.Show();*/


            //  TaskDialog.Show("Informace o nástroji Tlakové ztráty", "Nástroj počítá tlakové ztráty na kolenech obdélníkového a kruhového průřezu průřezu, které mají parametr rodiny s názvem STŘEDNÍ POLOMĚR (tento parametr mají defaultní rodiny v Revitu).Tyto hodnoty přičítá k hodnotám tlakových ztrát přímých kusů potrubí, které jsou počítány nativně podle nastavení Revitu. Kolena jsou počítána podle tabelárních hodnot v textovém souboru Koeficienty.txt a také podle vztahů zjištěných numericky. Plug-in počítá také tlakové ztráty přechodových kusů, u kterých je nutný parametr VYPOČÍTANÁ DÉLKA, která je také součástí defaultních rodin potrubí v Revitu");
            return(Result.Succeeded);
        }
Beispiel #3
0
 public FrmModify(AddParameterFamily data, a.Document doc, c.Application app)
 {
     _data = data;
     _doc  = doc;
     _app  = app;
     InitializeComponent();
 }
Beispiel #4
0
        public void HandleApplicationInitializedEvent(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e)
        {
            Autodesk.Revit.ApplicationServices.Application app = sender as Autodesk.Revit.ApplicationServices.Application;
            DesignAutomationData data = new DesignAutomationData(app, "C:\\Program Files\\Autodesk\\Revit 2019\\Samples\\WindowFamilyTmp.rft");

            CreateWindowFamily(data);
        }
Beispiel #5
0
        /// <summary>
        /// The command implementation.
        /// </summary>
        /// <param name="commandData"></param>
        /// <param name="message"></param>
        /// <param name="elements"></param>
        /// <returns></returns>
        public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            Autodesk.Revit.ApplicationServices.Application application = commandData.Application.Application;
            Document doc = commandData.Application.ActiveUIDocument.Document;

            // Find target document - it must be the only other open document in session
            Document toDocument = null;
            IEnumerable <Document> documents = application.Documents.Cast <Document>();

            if (documents.Count <Document>() != 2)
            {
                TaskDialog.Show("No target document",
                                "This tool can only be used if there are two documents (a source document and target document).");
                return(Result.Cancelled);
            }
            foreach (Document loadedDoc in documents)
            {
                if (loadedDoc.Title != doc.Title)
                {
                    toDocument = loadedDoc;
                    break;
                }
            }

            // Collect schedules and drafting views
            FilteredElementCollector collector = new FilteredElementCollector(doc);

            List <Type> viewTypes = new List <Type>();

            viewTypes.Add(typeof(ViewSchedule));
            viewTypes.Add(typeof(ViewDrafting));
            ElementMulticlassFilter filter = new ElementMulticlassFilter(viewTypes);

            collector.WherePasses(filter);

            collector.WhereElementIsViewIndependent(); // skip view-specfic schedules (e.g. Revision Schedules);
            // These should not be copied as they are associated to another view that cannot be copied

            // Copy all schedules together so that any dependency elements are copied only once
            IEnumerable <ViewSchedule> schedules = collector.OfType <ViewSchedule>();

            DuplicateViewUtils.DuplicateSchedules(doc, schedules, toDocument);
            int numSchedules = schedules.Count <ViewSchedule>();

            // Copy drafting views together
            IEnumerable <ViewDrafting> draftingViews = collector.OfType <ViewDrafting>();
            int numDraftingElements =
                DuplicateViewUtils.DuplicateDraftingViews(doc, draftingViews, toDocument);
            int numDrafting = draftingViews.Count <ViewDrafting>();

            // Show results
            TaskDialog.Show("Statistics",
                            String.Format("Copied: \n" +
                                          "\t{0} schedules.\n" +
                                          "\t{1} drafting views.\n" +
                                          "\t{2} new drafting elements created.",
                                          numSchedules, numDrafting, numDraftingElements));

            return(Result.Succeeded);
        }
Beispiel #6
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            System.Windows.Forms.Application.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document doc = uidoc.Document;

            string docPath    = doc.PathName;
            string folderPath = docPath.Remove(docPath.IndexOf('.'));

            try { Directory.CreateDirectory(folderPath); } catch { }
            Random r = new Random();

            InputData userData = new InputData(new FileInfo(doc.PathName).DirectoryName);

            userData.ShowDialog();
            if (userData.cancel)
            {
                return(Result.Failed);
            }

            switch (userData.simulationType)
            {
            case "Simplified EnergyPlus Simulation":
                new SimplifiedEP(uidoc, doc, userData, r);
                break;
            }

            return(Result.Succeeded);
        }
 //Конструктор RevitModelClass
 public RevitModelClass(UIApplication uiapp)
 {
     _uiApplication = uiapp;
     _application   = _uiApplication.Application;
     _uiDocument    = _uiApplication.ActiveUIDocument;
     _document      = _uiDocument.Document;
 }
Beispiel #8
0
        public void BeWorkset(string _wsName, ExternalCommandData commandData)
        {
            UIApplication _uiapp = commandData.Application;
            UIDocument    _uidoc = _uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application _app = _uiapp.Application;
            Autodesk.Revit.DB.Document _doc = _uidoc.Document;
            WorksetTable wst  = _doc.GetWorksetTable();
            WorksetId    wsID = FamilyUtils.WhatIsThisWorkSetIDByName(_wsName, _doc);

            if (wsID != null)
            {
                using (Transaction trans = new Transaction(_doc, "WillChangeWorkset")) {
                    trans.Start();
                    wst.SetActiveWorksetId(wsID);
                    trans.Commit();
                }
            }
            else
            {
                System.Windows.MessageBox.Show("Sorry but there is no workset "
                                               + _wsName + " to switch to.", "Smells So Bad It Has A Chain On It",
                                               System.Windows.MessageBoxButton.OK,
                                               System.Windows.MessageBoxImage.Exclamation);
            }
        }
Beispiel #9
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            if (commandData.Application.ActiveUIDocument.Document.IsFamilyDocument)
            {
                MessageBox.Show("Вы открыли семейство", "Ошибка");
                return(Result.Cancelled);
            }

            //Создаем экземпляр модели
            Model model = new Model(uiapp);
            //Создаем экземпляр презентации-модели
            ViewModelItems viewmodel = new ViewModelItems();
            //Создаем экземпляр внешней транзакции и передаем в него созданную модель
            ExternalEventHandler externalEventHandlerButton = new ExternalEventHandler(model);
            //Создаем внешнее событие и добавляем внешнюю транзакцию
            ExternalEvent ExEvent = ExternalEvent.Create(externalEventHandlerButton);

            //Передаем созданную модель во ViewModel
            viewmodel.RevitModel = model;
            //Добавляем во ViewModel внешнее событие
            viewmodel.ApplyEvent = ExEvent;
            //Создаем экземпляр формы
            var mainFilterView = new filterViewForm();

            mainFilterView.DataContext = viewmodel;
            mainFilterView.ShowDialog();
            return(Result.Succeeded);
        }
Beispiel #10
0
        Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document doc = uidoc.Document;

            addParamForm MainForm = new addParamForm(doc);

            MainForm.ShowDialog();

            FamilyManager fm = doc.FamilyManager;


            string messa;

            using (Transaction tr = new Transaction(doc, "pampam"))
            {
                tr.Start();
                for (int i = 1; i <= MainForm.num; i++)
                {
                    fm.AddParameter(MainForm.name + $"__{i}", MainForm.pGroup, MainForm.pType, MainForm.exempl);
                }

                Book t = new Book();
                messa = t.ReadXML();
                tr.Commit();
            }
            TaskDialog msg = new TaskDialog("Info");

            msg.MainInstruction = messa; //output;// FinishTable.Count().ToString();
            msg.Show();


            //List<FinishElements> elt = new List<FinishElements>();
            //FinishingLib FLib = new FinishingLib(elt);
            //FLib.Show();



            //Cube one = new Cube("A", "B");

            //var data = new List<Cube>();
            //data.Add(one);
            //using (Window SheetControl = new Window(data))
            //{
            //    var result = SheetControl.ShowDialog();
            //    if (result==DialogResult.OK)
            //    {
            //        string val = SheetControl.ReturnValue;
            //        TaskDialog msg = new TaskDialog("Info");
            //        msg.MainInstruction = one.Name;
            //        msg.Show();
            //    }
            //}

            return(Result.Succeeded);
        }
Beispiel #11
0
 public WTA_FPSettings(ExternalCommandData commandData)
 {
     InitializeComponent();
     uiapp = commandData.Application;
     uidoc = uiapp.ActiveUIDocument;
     app   = uiapp.Application;
     doc   = uidoc.Document;
 }
Beispiel #12
0
 public ParameterPropertyForm(UIApplication revitUiApp) : this()
 {
     this.m_revitApp      = revitUiApp.Application;
     this.m_revitDoc      = revitUiApp.ActiveUIDocument.Document;
     this.m_categories    = this.m_revitDoc.Settings.Categories;
     this.m_parameterInfo = new ParameterInfo();
     this.InitializeDataSourcesAndControls();
 }
Beispiel #13
0
        GetProfile(Solid solid, double offset, Revit.ApplicationServices.Application app)
        {
            CurveArray curveArray = app.Create.NewCurveArray();
            EdgeArray  edgeArray  = GetEdgesOnPlaneAtOffset(solid.Edges, GeomUtils.kZAxis, offset);

            curveArray = ToCurveArray(edgeArray, curveArray);
            return(curveArray);
        }
Beispiel #14
0
        public Form_Main(Document doc, Autodesk.Revit.ApplicationServices.Application app)
        {
            useTime.Start();

            InitializeComponent();
            m_doc = doc;
            m_app = app;
        }
Beispiel #15
0
        public void HandleApplicationInitializedEvent(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e)
        {
            Autodesk.Revit.ApplicationServices.Application app = sender as Autodesk.Revit.ApplicationServices.Application;
            String filePath           = Directory.GetCurrentDirectory() + "\\WindowFamilyTmp.rft";
            DesignAutomationData data = new DesignAutomationData(app, filePath);

            CreateWindowFamily(data);
        }
        public void HandleApplicationInitializedEvent(object sender,
                                                      Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e)
        {
            Autodesk.Revit.ApplicationServices.Application app = sender as Autodesk.Revit.ApplicationServices.Application;
            // We don't need to provide the file
            DesignAutomationData data = new DesignAutomationData(app, "C:\\tmp\\FindColumns-Basic.rvt");

            FindColumnsIOMain(data.RevitDoc);
        }
Beispiel #17
0
        CollectEvent(object sender, CollectorEventArgs e)
        {
            // cast the sender object to the SnoopCollector we are expecting
            Collector snoopCollector = sender as Collector;

            if (snoopCollector == null)
            {
                Debug.Assert(false); // why did someone else send us the message?
                return;
            }

            // see if it is a type we are responsible for
            Autodesk.Revit.ApplicationServices.Application app = e.ObjToSnoop as Autodesk.Revit.ApplicationServices.Application;
            if (app != null)
            {
                Stream(snoopCollector.Data(), app);
                return;
            }

            // no more app options?
            //Autodesk.Revit.Options.Application appOptions = e.ObjToSnoop as Autodesk.Revit.Options.Application;
            //if (appOptions != null) {
            //    Stream(snoopCollector.Data(), appOptions);
            //    return;
            //}

            ControlledApplication contrApp = e.ObjToSnoop as Autodesk.Revit.ApplicationServices.ControlledApplication;

            if (contrApp != null)
            {
                Stream(snoopCollector.Data(), contrApp);
                return;
            }

            Autodesk.Revit.UI.ExternalCommandData extCmd = e.ObjToSnoop as Autodesk.Revit.UI.ExternalCommandData;
            if (extCmd != null)
            {
                Stream(snoopCollector.Data(), extCmd);
                return;
            }

            RibbonItem ribbonItem = e.ObjToSnoop as RibbonItem;

            if (ribbonItem != null)
            {
                Stream(snoopCollector.Data(), ribbonItem);
                return;
            }

            RibbonPanel ribbonPanel = e.ObjToSnoop as RibbonPanel;

            if (ribbonPanel != null)
            {
                Stream(snoopCollector.Data(), ribbonPanel);
                return;
            }
        }
Beispiel #18
0
        /// <summary>
        /// The one and only method required by the IExternalCommand interface,
        /// the main entry point for every external command.
        /// </summary>
        /// <param name="commandData">Input argument providing access to the Revit application and its documents and their properties.</param>
        /// <param name="message">Return argument to display a message to the user in case of error if Result is not Succeeded.</param>
        /// <param name="elements">Return argument to highlight elements on the graphics screen if Result is not Succeeded.</param>
        /// <returns>Cancelled, Failed or Succeeded Result code.</returns>
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            //TODO: Add your code here
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;;
            Document doc = uidoc.Document;

            Transaction documentTransaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "Document");

            try
            {
                documentTransaction.Start();
                //add shared parameter to file

                LoopAllCategories(doc);


                #region Selection
                //access selection

                Selection sel = uidoc.Selection;

                //iterate


                foreach (ElementId eleId in sel.GetElementIds())
                {
                    //get element by ID
                    Element ele = doc.GetElement(eleId);
                    if (ele.Category.Name == "Walls")
                    {
                        Filter_Wall(doc);
                    }
                    //show it
                    TaskDialog.Show(ele.Category.Name, ele.Name);
                }

                # endregion
                #region Filter


                //let's get all these members
                Filter_Steel(doc);
                Filter_Wall(doc);

                //Must return some code
                documentTransaction.Commit();
                //   documentTransaction.Dispose();
                TaskDialog.Show("ID Update", "Completed");
                return(Result.Succeeded);
            }
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document doc = uidoc.Document;

            bool singleTransaction = true;

            //var ofd = new OpenFileDialog();

            var fsd = new FolderSelectDialog();

            fsd.ShowDialog();
            string familyDir = fsd.FileName;

            var revitFiles = Directory.EnumerateFiles(familyDir, "*.rfa", SearchOption.AllDirectories);


            if (singleTransaction)
            {
                // Modify document within a single transaction
                using (Transaction tx = new Transaction(doc))
                {
                    tx.Start("Transaction Name");
                    foreach (string filepath in revitFiles)
                    {
                        Debug.Print("File: {0}\n", filepath);
                        doc.LoadFamily(filepath);
                    }
                    tx.Commit();
                }
            }
            else
            {
                // Modify document within a multiple transactions
                foreach (string filepath in revitFiles)
                {
                    using (Transaction tx = new Transaction(doc))
                    {
                        tx.Start("Transaction Name");

                        Debug.Print("File: {0}\n", filepath);
                        doc.LoadFamily(filepath);

                        tx.Commit();
                    }
                }
            }

            return(Result.Succeeded);
        }
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document         doc              = uidoc.Document;
            ElementSelector  elementSelector  = new ElementSelector();
            Element          element          = elementSelector.SeclectElement(doc, uidoc);
            ParameterProcess parameterProcess = new ParameterProcess();

            SampleCreateSharedParameter sampleCreateSharedParameter = new SampleCreateSharedParameter(doc, app);

            sampleCreateSharedParameter.LINK = @"C:\Users\OAI-IICM\Desktop\APIRevit-C#\Project\IICM\API_revit_IICM_1020\Define\Structural-Parameters.txt";
            shareParameters.AddRange(sampleCreateSharedParameter.GetListShareParamerter(element));
            int loop = 1;

            do
            {
                foreach (Parameter para in element.Parameters)
                {
                    ParameterModel p = parameterProcess.GetParameterInformation(para, doc, id);

                    if (shareParameters.Contains(p.NAME))
                    {
                        listParamrter.Add(p);
                        id++;
                    }
                }
                if (listParamrter.Count > 0)
                {
                    break;
                }
                sampleCreateSharedParameter.CreateSampleSharedParameters(element);
                ++loop;
            } while (loop < 2);;
            ///show dialog update param
            ///
            using (FormIO formIO = new FormIO(listParamrter))
            {
                DialogResult dr = formIO.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    //do update
                    List <ParameterModel> listNewParam = new List <ParameterModel>();
                    listNewParam = formIO.VALUE;
                    foreach (var new_para in listNewParam)
                    {
                        parameterProcess.setParameterToElent(new_para.PARAMETER, doc, new_para.VALUE);
                    }
                }
            }

            return(Result.Succeeded);
            //throw new NotImplementedException();
        }
        public CreateSheetForm(ExternalCommandData commandData)
        {
            // get access to the top most objects
            UIApplication rvtUIApp = commandData.Application;
            UIDocument    rvtUIDoc = rvtUIApp.ActiveUIDocument;

            m_rvtApp = rvtUIApp.Application;
            m_rvtDoc = rvtUIDoc.Document;
            InitializeComponent();
        }
Beispiel #22
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.
            Application app = uiapp.Application;
            Document    doc = uidoc.Document;

            this.Initialize(doc);
            BaseLevel = null;

            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("AutoModel");
                ///Using input form to read json file into current house object.
                try
                {
                    CmdReadJsonForm InputJsonForm = new CmdReadJsonForm(this);
                    this.ActiveForm = InputJsonForm;
                    ///List levels.
                    AllLevels = new FilteredElementCollector(doc)
                                .WhereElementIsNotElementType()
                                .OfCategory(BuiltInCategory.OST_Levels)
                                .Select(e => e as Level).ToList();
                    foreach (Level l in AllLevels)
                    {
                        InputJsonForm.LevelBox.Items.Add(l.Name);
                    }
                    InputJsonForm.ShowDialog();
                    ///if (InputJsonForm.ShowDialog() != DialogResult.OK)
                    ///    return Result.Failed;
                }
                catch (Exception e)
                {
                    TaskDialog.Show("Error", "Something went wrong," +
                                    "details as follow:\n" + e.Message);
                    return(Result.Failed);
                }

                tx.Commit();
            }


            ///In case the user close the form.
            if (CurrentHouse == null)
            {
                return(Result.Failed);
            }

            return(Result.Succeeded);
        }
Beispiel #23
0
        private double SelectPoint(ExternalCommandData commandData)
        {
            Document    revitDoc = commandData.Application.ActiveUIDocument.Document; //取得文档
            Application revitApp = commandData.Application.Application;               //取得应用程序
            UIDocument  uiDoc    = commandData.Application.ActiveUIDocument;          //取得当前活动文档

            Selection sel        = uiDoc.Selection;
            Reference ref1       = sel.PickObject(ObjectType.Element, "选择一条模型线");
            Element   elem       = revitDoc.GetElement(ref1);
            ModelLine modelLine1 = elem as ModelLine;

            Autodesk.Revit.DB.Curve curve1;
            //做一个判断,判断其是否为ModelNurbSpline
            if (modelLine1 == null)
            {
                ModelNurbSpline modelNurbSpline = elem as ModelNurbSpline;
                curve1 = modelNurbSpline.GeometryCurve;
            }
            else
            {
                curve1 = modelLine1.GeometryCurve;
            }


            Reference ref2 = sel.PickObject(ObjectType.Element, "选择一条模型线");

            elem = revitDoc.GetElement(ref2);
            ModelLine modelLine2 = elem as ModelLine;

            Autodesk.Revit.DB.Curve curve2;
            //做一个判断,判断其是否为ModelNurbSpline
            if (modelLine2 == null)
            {
                ModelNurbSpline modelNurbSpline = elem as ModelNurbSpline;
                curve2 = modelNurbSpline.GeometryCurve;
            }
            else
            {
                curve2 = modelLine2.GeometryCurve;
            }


            //删除第二条选中的线
            uiDoc.Document.Delete(elem.Id);
            //求交点
            curve1.Intersect(curve2, out IntersectionResultArray intersectionResultArray);
            XYZ pointIntersect = intersectionResultArray.get_Item(0).XYZPoint;

            //交点和线都转化为dynamo的点和线
            DG.Point dgP   = pointIntersect.ToPoint(false);
            DG.Curve dgC   = curve1.ToProtoType(false);
            double   ratio = dgC.ParameterAtPoint(dgP);

            return(ratio);
        }
Beispiel #24
0
        //Constructor
        public QREncoder(Document doc, UIDocument uidoc, Application app)
        {
            base.QRCodeEncodeMode   = ENCODE_MODE.BYTE;
            base.QRCodeVersion      = 7;
            base.QRCodeErrorCorrect = ERROR_CORRECTION.M;
            base.QRCodeScale        = 1;

            _doc   = doc;
            _uiDoc = uidoc;
            _app   = app;
        }
Beispiel #25
0
        //Constructor
        public QREncoder(Document doc, UIDocument uidoc, Application app)
        {
            base.QRCodeEncodeMode = ENCODE_MODE.BYTE;
            base.QRCodeVersion = 7;
            base.QRCodeErrorCorrect = ERROR_CORRECTION.M;
            base.QRCodeScale = 1;

            _doc = doc;
            _uiDoc = uidoc;
            _app = app;
        }
Beispiel #26
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Autodesk.Revit.UI.UIApplication uiapp = commandData.Application;
            Autodesk.Revit.UI.UIDocument    uidoc = uiapp.ActiveUIDocument;
            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Autodesk.Revit.DB.Document doc = uidoc.Document;

            // Build a wall profile for the wall creation
            XYZ[] pts = new XYZ[] {
                XYZ.Zero,
                new XYZ(20, 0, 0),
                new XYZ(20, 0, 15),
                new XYZ(10, 0, 30),
                new XYZ(0, 0, 15)
            };

            // Get application creation object
            Autodesk.Revit.Creation.Application appCreation = app.Create;

            // Create wall profile
            CurveArray profile = new CurveArray();
            XYZ        q       = pts[pts.Length - 1];

            foreach (XYZ p in pts)
            {
                profile.Append(appCreation.NewLineBound(q, p));
                q = p;
            }

            XYZ normal = XYZ.BasisY;

            WallType wallType
                = new FilteredElementCollector(doc)
                  .OfClass(typeof(WallType))
                  .First <Element>()
                  as WallType;

            Level level
                = new FilteredElementCollector(doc)
                  .OfClass(typeof(Level))
                  .First <Element>(e
                                   => e.Name.Equals("Level 1"))
                  as Level;

            Transaction trans = new Transaction(doc);

            trans.Start("Test Gable Wall");
            Wall wall = doc.Create.NewWall(profile, wallType, level, true, normal);

            trans.Commit();

            return(Result.Succeeded);
        }
Beispiel #27
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument UIdoc = commandData.Application.ActiveUIDocument;
            Document   doc   = UIdoc.Document;

            this.application = commandData.Application.Application;

            try
            {
                List <KeyValuePair <ViewSection, String> > newNames = new List <KeyValuePair <ViewSection, string> >();
                List <ViewSection> intElevlist = InteriorElevations(doc);

                foreach (ViewSection ie in intElevlist)
                {
                    List <Room> phasedRooms = RoomHelpers.GetPhasedRooms(doc, ie.CreatedPhaseId);

                    Room r = GetElevRoom(ie, phasedRooms, doc);

                    String ieNewName = RenameElevation(doc, ie, r);
                    newNames.Add(new KeyValuePair <ViewSection, String>(ie, ieNewName));
                }

                RenameElevationsDialog ieDialog     = new RenameElevationsDialog(this.application, newNames);
                DialogResult           dialogResult = ieDialog.ShowDialog();

                if (dialogResult == DialogResult.OK)
                {
                    using (Transaction tx = new Transaction(doc))
                    {
                        tx.Start("Rename Elevations");
                        foreach (ViewSection ie in intElevlist)
                        {
                            String ieNewName = newNames.Find(kv => kv.Key.Id == ie.Id).Value;
                            AssignName(ie, ieNewName);
                        }

                        tx.Commit();
                    }
                }

                else
                {
                    return(Result.Cancelled);
                }
            }
            catch (Exception ex)
            {
                message = ex.ToString();
                return(Result.Failed);
            }

            return(Result.Succeeded);
        }
        public Result Execute(ExternalCommandData commandData,
                              ref string message,
                              ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document doc = uidoc.Document;

            // Create local directory
            LocalFiles.CreateLocalDir();

            // Check OpenRFA.org for latest update to online db
            LocalFiles.GetLastUpdateJsonOnline();

            MainWindow appDialog = new MainWindow();

            appDialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;

            // Check if current document is a Revit family
            if (doc.IsFamilyDocument)
            {
                // Only open window if continueCommand is set true
                if (ImportProcess.continueCommand == true)
                {
                    appDialog.ShowDialog();
                }

                // Only executes if the user clicked "OK" button
                if (appDialog.DialogResult.HasValue && appDialog.DialogResult.Value)
                {
                    // Opens configuration window
                    ConfigureImport confDialog = new ConfigureImport();
                    confDialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                    confDialog.ShowDialog();

                    // Complete import process
                    ImportProcess.ProcessImport(doc, app, confDialog.DialogResult.HasValue, confDialog.DialogResult.Value);

                    // Clear all data in case addin is run again in the same session
                    // TODO: Call this method with every method that uses the datatables?
                    ImportProcess.ClearAllData();
                }

                return(Result.Succeeded);
            }
            else
            {
                MessageBox.Show("The current document must be a Revit family to use this tool.");
                return(Result.Failed);
            }
        }
Beispiel #29
0
        /// <summary>
        /// Retrieve the boundary loops of the given slab
        /// top face, which is assumed to be horizontal.
        /// </summary>
        Polygons GetBoundaryLoops(CeilingAndFloor slab)
        {
            int      n;
            Polygons polys = null;
            Document doc   = slab.Document;

            Autodesk.Revit.ApplicationServices.Application app = doc.Application;

            Options opt = app.Create.NewGeometryOptions();

            GeometryElement geo = slab.get_Geometry(opt);

            foreach (GeometryObject obj in geo)
            {
                Solid solid = obj as Solid;
                if (null != solid)
                {
                    foreach (Face face in solid.Faces)
                    {
                        PlanarFace pf = face as PlanarFace;
                        if (null != pf &&
                            pf.FaceNormal.IsAlmostEqualTo(XYZ.BasisZ))
                        {
                            EdgeArrayArray loops = pf.EdgeLoops;

                            n     = loops.Size;
                            polys = new Polygons(n);

                            foreach (EdgeArray loop in loops)
                            {
                                n = loop.Size;
                                Polygon poly = new Polygon(n);

                                foreach (Edge edge in loop)
                                {
                                    IList <XYZ> pts = edge.Tessellate();

                                    n = pts.Count;

                                    foreach (XYZ p in pts)
                                    {
                                        poly.Add(GetIntPoint(p));
                                    }
                                }
                                polys.Add(poly);
                            }
                        }
                    }
                }
            }
            return(polys);
        }
        public Result ExecuteSteerSuite(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            // Determine elements to export

            FilteredElementCollector collector = null;

            // Access current selection


            // If nothing was preselected, export
            // all model elements to OBJ

            collector = new FilteredElementCollector(doc);


            collector.WhereElementIsNotElementType()
            .WhereElementIsViewIndependent();

            if (null == _export_folder_name)
            {
                _export_folder_name = Path.GetTempPath();
            }

            string filename = null;

            if (!FileSelect(_export_folder_name,
                            out filename))
            {
                return(Result.Cancelled);
            }

            _export_folder_name
                = Path.GetDirectoryName(filename);

            ObjExporter exporter = new ObjExporter();

            Options opt = app.Create.NewGeometryOptions();

            ExportElements(exporter, collector, opt);

            //exporter.ExportTo(filename);
            exporter.ExportToSteerSuite();
            return(Result.Succeeded);
        }
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            uiapp = commandData.Application;
            uidoc = uiapp.ActiveUIDocument;
            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document doc = uidoc.Document;

            ObjectPlacement T = new ObjectPlacement();

            T.ShowDialog();

            return(Result.Succeeded);
        }
Beispiel #32
0
        public Result Execute(ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            try
            {
                uiApp = commandData.Application;
                uiDoc = uiApp.ActiveUIDocument;
                app = uiApp.Application;
                doc = uiDoc.Document;

                CropBoxVisibility.setCropBoxVisibility(doc, false);
            }
            catch (Exception e)
            {
                TaskDialog.Show("Revit Quick Tools", e.Message);
                return Result.Failed;
            }

            return Result.Succeeded;
        }
        public Result Execute(
            ExternalCommandData revit,
            ref string message,
            ElementSet elements)
        {
            m_uiApp = revit.Application;
              m_app = m_uiApp.Application;
              m_uiDoc = m_uiApp.ActiveUIDocument;
              m_doc = m_uiDoc.Document;

              TaskDialog.Show( "Test application",
            "Revit version: " + m_app.VersionBuild );

              m_writer = new StreamWriter( @"C:\SRD201483.txt" );

              WriteDimensionReferences( 161908 );
              WriteElementGeometry( 161900 );

              m_writer.Close();

              return Result.Succeeded;
        }
Beispiel #34
0
 public ParameterAssigner(Autodesk.Revit.ApplicationServices.Application app, Document doc)
 {
     m_app = app;
     m_manager = doc.FamilyManager;
 }
 /// <summary>
 /// Get GUID for a given shared param name.
 /// </summary>
 /// <param name="app">Revit application</param>
 /// <param name="defGroup">Definition group name</param>
 /// <param name="defName">Definition name</param>
 /// <returns>GUID</returns>
 public static Guid SharedParamGUID( Application app, string defGroup, string defName )
 {
     Guid guid = Guid.Empty;
       try
       {
     DefinitionFile file = app.OpenSharedParameterFile();
     DefinitionGroup group = file.Groups.get_Item( defGroup );
     Definition definition = group.Definitions.get_Item( defName );
     ExternalDefinition externalDefinition = definition as ExternalDefinition;
     guid = externalDefinition.GUID;
       }
       catch( Exception )
       {
       }
       return guid;
 }
 /// <summary>
 /// Helper to get shared parameters file.
 /// </summary>
 public static DefinitionFile GetSharedParamsFile(
     Application app)
 {
     // Get current shared params file name
       string sharedParamsFileName;
       try
       {
     sharedParamsFileName = app.SharedParametersFilename;
       }
       catch( Exception ex )
       {
     ErrorMsg( "No shared params file set:" + ex.Message );
     return null;
       }
       if( 0 == sharedParamsFileName.Length )
       {
     string path = LabConstants.SharedParamFilePath;
     StreamWriter stream;
     stream = new StreamWriter( path );
     stream.Close();
     app.SharedParametersFilename = path;
     sharedParamsFileName = app.SharedParametersFilename;
       }
       // Get the current file object and return it
       DefinitionFile sharedParametersFile;
       try
       {
     sharedParametersFile = app.OpenSharedParameterFile();
       }
       catch( Exception ex )
       {
     ErrorMsg( "Cannnot open shared params file:" + ex.Message );
     sharedParametersFile = null;
       }
       return sharedParametersFile;
 }