Esempio n. 1
0
        public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
        {
            // Run the application logic.
            Process(e.DesignAutomationData);

            e.Succeeded = true;
        }
        private void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
        {
            LogTrace("Design Automation Ready event triggered...");
            e.Succeeded = true;

            extract_mep_data(e.DesignAutomationData.RevitDoc);
        }
Esempio n. 3
0
        private void OnDesignAutomationReadyEvent(
            object sender,
            DesignAutomationReadyEventArgs e)
        {
            // `sender` is an Application instance:

            Application app = sender as Application;

            ExportLinkedInIfcDocs(app);
        }
Esempio n. 4
0
        public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
        {
            // get the application
            Application app = sender as Application;

            // get the data
            string path = e.DesignAutomationData.FilePath;
            DesignAutomationData data = new DesignAutomationData(app, path);

            DeleteViewsNotOnSheets(data.RevitDoc);
            e.Succeeded = true;
        }
        private void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
        {
            LogTrace("Design Automation Ready event triggered...");
            e.Succeeded = true;
            //EditWindowParametersMethod(e.DesignAutomationData.RevitDoc);
            DoJob(e.DesignAutomationData);
            ModelPath     ProjectModelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(OUTPUT_FILE);
            SaveAsOptions SAO = new SaveAsOptions();

            SAO.OverwriteExistingFile = true;

            //Save the project file with updated window's parameters
            LogTrace("Saving file...");
            e.DesignAutomationData.RevitDoc.SaveAs(ProjectModelPath, SAO);
        }
Esempio n. 6
0
        public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
        {
            e.Succeeded = true;

            if (e.DesignAutomationData == null)
            {
                throw new ArgumentNullException(nameof(e.DesignAutomationData));
            }

            _rvtApp = e.DesignAutomationData.RevitApp;
            if (_rvtApp == null)
            {
                throw new InvalidDataException(nameof(_rvtApp));
            }

            //Converts SAT file to family file(rfa file)
            ConvertSAT2RFA();
        }
        public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
        {
            e.Succeeded = true;
            Document doc = e.DesignAutomationData.RevitDoc;

            if (doc.IsFamilyDocument)
            {
                FamilyManager fm = doc.FamilyManager;
                //Save the updated file by overwriting the existing file
                ModelPath     ProjectModelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(doc.PathName);
                SaveAsOptions SAO = new SaveAsOptions();
                SAO.OverwriteExistingFile = true;

                //Save the project file with updated window's parameters
                LogTrace("Saving file...");
                doc.SaveAs(ProjectModelPath, SAO);
            }
        }
Esempio n. 8
0
        public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
        {
            e.Succeeded = true;

            if (e.DesignAutomationData == null)
            {
                throw new ArgumentNullException(nameof(e.DesignAutomationData));
            }

            _rvtApp = e.DesignAutomationData.RevitApp;
            if (_rvtApp == null)
            {
                throw new InvalidDataException(nameof(_rvtApp));
            }

            //Converts SAT file to family file(rfa file)
            ConvertSAT2RFA();

            //Updates the project by replacing the family file with updated family file
            UpdateRFAinProject(e.DesignAutomationData.RevitDoc);
        }
Esempio n. 9
0
        private void OnApplicationReady(object sender, DesignAutomationReadyEventArgs e)
        {
            try
            {
                var appData = e.DesignAutomationData;
                var doc     = appData.RevitApp.NewProjectDocument(UnitSystem.Metric) ?? throw new Exception("Could not create project");
                e.Succeeded = true;

                // Create container and resolve necessary classes
                using (var container = ContainerLifeCycle.Create())
                {
                    var revitGridService = container.Resolve <IRevitGridService>();

                    // Get gridInfo list
                    var json           = File.ReadAllText("gridCollection.json");
                    var gridCollection = JsonConvert.DeserializeObject <GridCollection>(json);

                    using (var t = new Transaction(doc, "Create grids"))
                    {
                        t.Start();

                        revitGridService.CreateRevitGrids(doc, gridCollection.GridInfoList);

                        t.Commit();
                    }

                    doc.SaveAs("result.rvt");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("---ERROR---");
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
        }
 public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     GenerateRevitFile(e.DesignAutomationData);
     e.Succeeded = true;
 }
Esempio n. 11
0
        private void OnAppReady(object sender, DesignAutomationReadyEventArgs e)
        {
            var      appData = e.DesignAutomationData;
            var      app     = appData.RevitApp;
            Document doc     = null;
            var      path    = Directory.GetCurrentDirectory();

            Console.WriteLine("**************************************************");
            Console.WriteLine($"**************** Directory Files ****************");

            var files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);

            foreach (var file in files)
            {
                if (file.Contains(@"\nunit\") || file.Contains(@"\workitemBundle\"))
                {
                    var fileName = Path.GetFileName(file);
                    var rootFile = Path.Combine(path, fileName);
                    File.Copy(file, rootFile);
                    Console.WriteLine($"File: {rootFile}");
                }
                else
                {
                    Console.WriteLine($"File: {file}");
                }
            }

            Console.WriteLine("**************************************************");

            var       testSuitesPath = "testSuite.json";
            TestSuite testSuite      = null;

            if (!File.Exists(testSuitesPath))
            {
                Console.WriteLine($"***** Test Suite file not found: {testSuitesPath}");
            }
            else
            {
                testSuite = JsonHelper.FromFile <TestSuite>(testSuitesPath);
            }

            if (testSuite == null)
            {
                Console.WriteLine($"***** Test Suite json parsing error: {testSuitesPath}");
                e.Succeeded = false;
            }
            else
            {
                var workitemId   = Path.GetFileName(path);
                var assemblyPath = Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories).FirstOrDefault(f => f.EndsWith(testSuite.Assembly));

                if (string.IsNullOrWhiteSpace(assemblyPath))
                {
                    Console.WriteLine($"***** Test Suite failed, the assembly {testSuite.Assembly} was not found.");
                    e.Succeeded = false;
                    return;
                }

                if (!string.IsNullOrWhiteSpace(testSuite.RvtFile))
                {
                    var normalizedRvtFile = testSuite.RvtFile.ToLower();
                    if (
                        !normalizedRvtFile.EndsWith(".rte") &&
                        !normalizedRvtFile.EndsWith(".rvt") &&
                        !normalizedRvtFile.EndsWith(".rfa") &&
                        !normalizedRvtFile.EndsWith(".rtf")
                        )
                    {
                        Console.WriteLine($"***** Test Suite failed, the file {testSuite.RvtFile} is not a valid revit file.");
                        e.Succeeded = false;
                        return;
                    }

                    var filePath = files.FirstOrDefault(f => f.EndsWith(testSuite.RvtFile));
                    if (string.IsNullOrWhiteSpace(filePath))
                    {
                        Console.WriteLine($"***** Test Suite failed, the file {testSuite.RvtFile} is was not found.");
                        e.Succeeded = false;
                        return;
                    }

                    doc = app.OpenDocumentFile(filePath);
                }

                var testCorePath = Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories).FirstOrDefault(f => f.EndsWith("Revit.TestRunner.TestCore.dll"));
                var coreAssembly = Assembly.LoadFrom(testCorePath);
                var attType      = coreAssembly.GetTypes().FirstOrDefault(t => t.Name == "InjectDocumentAttribute");

                if (attType == null)
                {
                    Console.WriteLine($"***** Test Suite failed, the attribute not found on {coreAssembly.FullName}");
                    foreach (var tt in coreAssembly.GetTypes())
                    {
                        Console.WriteLine($"****** {tt.FullName}");
                    }
                    return;
                }

                var prop = attType.GetProperty("Document", BindingFlags.Public | BindingFlags.Static);
                prop.SetValue(null, doc);

                ITestRunner testRunner     = null;
                var         flattenService = new NUnitCaseFlattenService();
                var         runnerService  = new NUnitRunnerService(flattenService);
                try
                {
                    testRunner = runnerService.CreateTestRunner(assemblyPath);
                    var result = testRunner.Run(null, TestFilter.Empty);

                    result.AddAttribute("workitemId", workitemId);
                    if (!string.IsNullOrWhiteSpace(testSuite.Id))
                    {
                        result.AddAttribute("testSuiteId", testSuite.Id);
                    }

                    XmlSerializer serializer = new XmlSerializer(typeof(XmlNode));
                    TextWriter    writer     = new StreamWriter("results.xml");
                    serializer.Serialize(writer, result);
                    writer.Close();

                    Console.WriteLine("**********          Results             **********");
                    Console.WriteLine(File.ReadAllText("results.xml"));
                }
                finally
                {
                    testRunner?.Unload();
                }
            }

            e.Succeeded = true;

            Console.WriteLine($"********** Design automation completed ***********");
            Console.WriteLine("**************************************************");
        }
 public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     e.Succeeded = true;
     FindColumnsIOMain(e.DesignAutomationData.RevitDoc);
 }
Esempio n. 13
0
 private void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     e.Succeeded = true;
     EditWindowParametersMethod(e.DesignAutomationData.RevitDoc);
 }
Esempio n. 14
0
        private void DesignAutomationBridge_DesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
        {
            LogTrace("Design Automation Ready event triggered...");
            e.Succeeded = true;
            DesignAutomationData data   = e.DesignAutomationData;
            Application          rvtApp = data.RevitApp;
            string   modelPath          = data.FilePath;
            Document doc = data.RevitDoc;

            using (Transaction t = new Transaction(doc))
            {
                // Start the transaction
                t.Start("Export Sheets DWG");
                try
                {
                    var viewSheets = new FilteredElementCollector(doc).OfClass(typeof(ViewSheet)).Cast <ViewSheet>().Where(vw =>
                                                                                                                           vw.ViewType == ViewType.DrawingSheet && !vw.IsTemplate);

                    // create DWG export options
                    DWGExportOptions dwgOptions = new DWGExportOptions();
                    dwgOptions.MergedViews  = true;
                    dwgOptions.SharedCoords = true;
                    dwgOptions.FileVersion  = ACADVersion.R2018;

                    List <ElementId> views = new List <ElementId>();

                    foreach (var sheet in viewSheets)
                    {
                        if (!sheet.IsPlaceholder)
                        {
                            views.Add(sheet.Id);
                        }
                    }

                    // For Web Deployment
                    //doc.Export(@"D:\sheetExporterLocation", "TEST", views, dwgOptions);
                    // For Local
                    doc.Export(Directory.GetCurrentDirectory() + "//exportedDwgs", "rvt", views, dwgOptions);
                }
                catch (Exception ex)
                {
                }
                // Commit the transaction
                t.Commit();
            }
        }
Esempio n. 15
0
 private void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     LogTrace("Design Automation Ready event triggered...");
     e.Succeeded = true;
     EditWindowParametersMethod(e.DesignAutomationData.RevitDoc);
 }
Esempio n. 16
0
 public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     e.Succeeded = CountElementsInModel(e.DesignAutomationData.RevitApp, e.DesignAutomationData.FilePath, e.DesignAutomationData.RevitDoc);
 }
Esempio n. 17
0
        private void DesignAutomationBridge_DesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
        {
            LogTrace("Design Automation Ready event triggered...");
            e.Succeeded = true;
            DesignAutomationData data = e.DesignAutomationData;

            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            Application rvtApp = data.RevitApp;

            if (rvtApp == null)
            {
                throw new InvalidDataException(nameof(rvtApp));
            }

            string modelPath = data.FilePath;

            if (String.IsNullOrWhiteSpace(modelPath))
            {
                throw new InvalidDataException(nameof(modelPath));
            }

            Document doc = data.RevitDoc;

            if (doc == null)
            {
                throw new InvalidOperationException("Could not open document.");
            }

            using (Autodesk.Revit.DB.Transaction trans = new Transaction(doc, "ExportToDwgs"))
            {
                try
                {
                    trans.Start();

                    List <View> views = new FilteredElementCollector(doc)
                                        .OfClass(typeof(View))
                                        .Cast <View>()
                                        .Where(vw =>
                                               vw.ViewType == ViewType.DrawingSheet && !vw.IsTemplate
                                               ).ToList();

                    List <ElementId> viewIds = new List <ElementId>();
                    foreach (View view in views)
                    {
                        ViewSheet viewSheet = view as ViewSheet;
                        viewIds.Add(viewSheet.Id);
                    }

                    DWGExportOptions dwgOptions = new DWGExportOptions();
                    dwgOptions.MergedViews = true;



                    Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\exportedDwgs");
                    if (Directory.Exists(Directory.GetCurrentDirectory() + "\\exportedDwgs"))
                    {
                        LogTrace("ExportedDwgs directory exists");
                    }
                    doc.Export(Directory.GetCurrentDirectory() + "\\exportedDwgs", "result.dwg", viewIds, dwgOptions);
                    LogTrace("Export Process Completedd");
                    trans.Commit();
                }
                catch (Exception ee)
                {
                    System.Diagnostics.Debug.WriteLine(ee.Message);
                    System.Diagnostics.Debug.WriteLine(ee.StackTrace);
                    return;
                }
                finally
                {
                    if (trans.HasStarted())
                    {
                        trans.RollBack();
                    }
                }
            }
        }
Esempio n. 18
0
 public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     e.Succeeded = true;
     GridObjectPlacement(e.DesignAutomationData);
 }
Esempio n. 19
0
 private void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     LogTrace("Design Automation Ready event triggered...");
     e.Succeeded = true;
     ScheduleWalls(e.DesignAutomationData);
 }
Esempio n. 20
0
 public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     CreateHyparModel(e.DesignAutomationData);
     e.Succeeded = true;
 }
Esempio n. 21
0
 private void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     e.Succeeded = true;
     compoundStructureLayeToJson(e.DesignAutomationData);
 }
Esempio n. 22
0
 public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     e.Succeeded = true;
     ExportToIFC(e.DesignAutomationData);
 }
Esempio n. 23
0
 public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     e.Succeeded = true;
     DesignAutoFunction(e.DesignAutomationData);
 }
 public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     e.Succeeded = ProcessParameters(e.DesignAutomationData);
 }
Esempio n. 25
0
 private void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     LogTrace("Design Automation Ready event triggered...");
     e.Succeeded = true;
     e.Succeeded = this.ExportFBX(e.DesignAutomationData);
 }
Esempio n. 26
0
 public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     e.Succeeded = true;
     DeleteAllElements(e.DesignAutomationData);
 }
Esempio n. 27
0
 public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     e.Succeeded = true;
     UpgradeFile(e.DesignAutomationData);
 }
Esempio n. 28
0
 public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
 {
     e.Succeeded = true;
     e.Succeeded = CreateWindowFamily(e.DesignAutomationData);
 }