Esempio n. 1
1
        /// <summary>
        /// Finds all the views in the active document.
        /// </summary>
        /// <param name="doc">the active document</param>
        public static ViewSet GetAllViews (Document doc)
        {
            ViewSet allViews = new ViewSet();

            FilteredElementCollector fec = new FilteredElementCollector(doc);
            ElementClassFilter elementsAreWanted = new ElementClassFilter(typeof(FloorType));
            fec.WherePasses(elementsAreWanted);
            List<Element> elements = fec.ToElements() as List<Element>;

            foreach (Element element in elements)
            {
               Autodesk.Revit.DB.View view = element as Autodesk.Revit.DB.View;

               if (null == view)
               {
                  continue;
               }
               else
               {
                  
                  ElementType objType = doc.GetElement(view.GetTypeId()) as ElementType;
                  if (null == objType || objType.Name.Equals("Drawing Sheet"))
                  {
                     continue;
                  }
                  else
                  {
                     allViews.Insert(view);
                  }
               }
            }

            return allViews;
        }
Esempio n. 2
0
        static void Main()
        {
            Workspace workspace = new Workspace("Documentation - arc42", "An empty software architecture document using the arc42 template.");
            Model     model     = workspace.Model;
            ViewSet   views     = workspace.Views;

            Person         user           = model.AddPerson("User", "A user of my software system.");
            SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system.");

            user.Uses(softwareSystem, "Uses");

            SystemContextView contextView = views.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");

            contextView.AddAllSoftwareSystems();
            contextView.AddAllPeople();

            Styles styles = views.Configuration.Styles;

            styles.Add(new ElementStyle(Tags.Person)
            {
                Shape = Shape.Person
            });

            Arc42DocumentationTemplate template = new Arc42DocumentationTemplate(workspace);

            // this is the Markdown version
            DirectoryInfo documentationRoot = new DirectoryInfo("Documentation" + Path.DirectorySeparatorChar + "arc42" + Path.DirectorySeparatorChar + "markdown");

            template.AddIntroductionAndGoalsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "01-introduction-and-goals.md")));
            template.AddConstraintsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "02-architecture-constraints.md")));
            template.AddContextAndScopeSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "03-system-scope-and-context.md")));
            template.AddSolutionStrategySection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "04-solution-strategy.md")));
            template.AddBuildingBlockViewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "05-building-block-view.md")));
            template.AddRuntimeViewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "06-runtime-view.md")));
            template.AddDeploymentViewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "07-deployment-view.md")));
            template.AddCrosscuttingConceptsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "08-crosscutting-concepts.md")));
            template.AddArchitecturalDecisionsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "09-architecture-decisions.md")));
            template.AddRisksAndTechnicalDebtSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "10-quality-requirements.md")));
            template.AddQualityRequirementsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "11-risks-and-technical-debt.md")));
            template.AddGlossarySection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "12-glossary.md")));

            // this is the AsciiDoc version
//            DirectoryInfo documentationRoot = new DirectoryInfo("Documentation" + Path.DirectorySeparatorChar + "arc42" + Path.DirectorySeparatorChar + "asciidoc");
//            template.AddIntroductionAndGoalsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "01-introduction-and-goals.adoc")));
//            template.AddConstraintsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "02-architecture-constraints.adoc")));
//            template.AddContextAndScopeSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "03-system-scope-and-context.adoc")));
//            template.AddSolutionStrategySection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "04-solution-strategy.adoc")));
//            template.AddBuildingBlockViewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "05-building-block-view.adoc")));
//            template.AddRuntimeViewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "06-runtime-view.adoc")));
//            template.AddDeploymentViewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "07-deployment-view.adoc")));
//            template.AddCrosscuttingConceptsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "08-crosscutting-concepts.adoc")));
//            template.AddArchitecturalDecisionsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "09-architecture-decisions.adoc")));
//            template.AddRisksAndTechnicalDebtSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "10-quality-requirements.adoc")));
//            template.AddQualityRequirementsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "11-risks-and-technical-debt.adoc")));
//            template.AddGlossarySection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "12-glossary.adoc")));

            StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret);

            structurizrClient.PutWorkspace(WorkspaceId, workspace);
        }
Esempio n. 3
0
        public async Task <bool> SaveAsync(IProgressEx Progress)
        {
            if ((await ComponentSet.SaveAsync(Progress)) == false)
            {
                return(false);
            }

            if ((await ViewSet.SaveAsync(Progress)) == false)
            {
                return(false);
            }

            try
            {
                XDocument xDoc = new XDocument();

                xDoc.Add(this.Xml);

                xDoc.Save(_projectFilePath);

                _hasChanges = false;
            }
            catch (Exception ex)
            {
                MainLogger.Log(ex);
                return(false);
            }

            return(true);
        }
        static void Main()
        {
            Workspace workspace = new Workspace("Styling Relationships", "This is a model of my software system.");
            Model     model     = workspace.Model;

            Person         user           = model.AddPerson("User", "A user of my software system.");
            SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system.");
            Container      webApplication = softwareSystem.AddContainer("Web Application", "My web application.", "Java and Spring MVC");
            Container      database       = softwareSystem.AddContainer("Database", "My database.", "Relational database schema");

            user.Uses(webApplication, "Uses", "HTTPS");
            webApplication.Uses(database, "Reads from and writes to", "JDBC");

            ViewSet       views         = workspace.Views;
            ContainerView containerView = views.CreateContainerView(softwareSystem, "containers", "An example of a container diagram.");

            containerView.AddAllElements();

            Styles styles = workspace.Views.Configuration.Styles;

            // example 1
//            styles.Add(new RelationshipStyle(Tags.Relationship) { Color = "#ff0000" });

            // example 2
//            model.Relationships.Where(r => "HTTPS".Equals(r.Technology)).ToList().ForEach(r => r.AddTags("HTTPS"));
//            model.Relationships.Where(r => "JDBC".Equals(r.Technology)).ToList().ForEach(r => r.AddTags("JDBC"));
//            styles.Add(new RelationshipStyle("HTTPS") { Color = "#ff0000" });
//            styles.Add(new RelationshipStyle("JDBC") { Color = "#0000ff" });

            StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret);

            structurizrClient.PutWorkspace(WorkspaceId, workspace);
        }
        public MainWindow(UIDocument _uidoc, ViewSchedule _viewSched)
        {
            InitializeComponent();

            uidoc     = _uidoc;
            doc       = uidoc.Document;
            viewSched = _viewSched;

            // Placeholder sheets print as blank pages, we don't want them
            sheetList = new FilteredElementCollector(doc);
            sheetList.OfClass(typeof(ViewSheet))
            .Cast <ViewSheet>()
            .Where <ViewSheet>(i => !i.IsPlaceholder);


            viewSet = new ViewSet();

            // Read the data from the schedule
            TableData        table   = viewSched.GetTableData();
            TableSectionData section = table.GetSectionData(SectionType.Body);

            nRows           = section.NumberOfRows;
            nCols           = section.NumberOfColumns;
            SetNameBox.Text = viewSched.Name;

            // This is to select which column the sheet numbers are
            foreach (int num in Enumerable.Range(1, nCols))
            {
                Cbx.Items.Add(num);
            }
            Cbx.SelectedIndex = 0;
        }
Esempio n. 6
0
        /// <summary>
        /// Finds all the views in the active document.
        /// </summary>
        /// <param name="doc">the active document</param>
        public static ViewSet GetAllViews(Document doc)
        {
            ViewSet allViews = new ViewSet();

            FilteredElementCollector fec = new FilteredElementCollector(doc);
            ElementClassFilter       elementsAreWanted = new ElementClassFilter(typeof(FloorType));

            fec.WherePasses(elementsAreWanted);
            List <Element> elements = fec.ToElements() as List <Element>;

            foreach (Element element in elements)
            {
                Autodesk.Revit.DB.View view = element as Autodesk.Revit.DB.View;

                if (null == view)
                {
                    continue;
                }
                else
                {
                    ElementType objType = doc.GetElement(view.GetTypeId()) as ElementType;
                    if (null == objType || objType.Name.Equals("Drawing Sheet"))
                    {
                        continue;
                    }
                    else
                    {
                        allViews.Insert(view);
                    }
                }
            }

            return(allViews);
        }
Esempio n. 7
0
        public void ExportToDwg()
        {
            // get output dir to save DWGs to
            System.Windows.Forms.FolderBrowserDialog dbox = new System.Windows.Forms.FolderBrowserDialog();
            dbox.Description         = "Folder to save exported DWG files to";
            dbox.ShowNewFolderButton = true;

            if (dbox.ShowDialog() == DialogResult.OK)
            {
                ViewSet          viewsToExport = Utils.View.GetAvailableViewsToExport(m_revitApp.ActiveUIDocument.Document);
                List <ElementId> views         = new List <ElementId>();
                foreach (Autodesk.Revit.DB.View view in viewsToExport)
                {
                    views.Add(view.Id);
                }


                DWGExportOptions opts = new DWGExportOptions();

                // The ACIS option has supposedly been fixed, will have to verify this with the latest code
                // at a later time.
                opts.ExportOfSolids = SolidGeometry.ACIS;
                opts.TargetUnit     = ExportUnit.Millimeter;

                m_revitApp.ActiveUIDocument.Document.Export(dbox.SelectedPath, "", views, opts);
            }
        }
Esempio n. 8
0
 public void SetWorkspace(string workspaceName, string workspaceDescription)
 {
     workspace        = new Workspace(workspaceName, workspaceDescription);
     views            = workspace.Views;
     model            = workspace.Model;
     model.Enterprise = new Enterprise($"{BedrijfsNaam}");
 }
Esempio n. 9
0
        /// <summary>
        /// Export PDF format
        /// </summary>
        /// <returns></returns>
        public override bool Export()
        {
            base.Export();

            bool exported = false;
            // Parameter: The list of view/sheet id to export
            IList <ElementId> views = new List <ElementId>();

            if (m_currentViewOnly)
            {
                views.Add(m_activeDoc.ActiveView.Id);
            }
            else
            {
                ViewSet viewSet = m_selectViewsData.SelectedViews;
                foreach (View v in viewSet)
                {
                    views.Add(v.Id);
                }
            }

            // Parameter: The exporting options, including paper size, orientation, file name or naming rule and etc.
            PDFExportOptions options = new PDFExportOptions();

            options.FileName = m_exportFileName;
            options.Combine  = m_combine; // If not combined, PDFs will be exported with default naming rule "Type-ViewName"
            exported         = m_activeDoc.Export(m_exportFolder, views, options);

            return(exported);
        }
Esempio n. 10
0
        /// <summary>
        /// Collect the parameters and export
        /// </summary>
        /// <returns></returns>
        public override bool Export()
        {
            base.Export();

            bool exported = false;
            //parameter : ViewSet views
            ViewSet views = new ViewSet();

            if (m_currentViewOnly)
            {
                views.Insert(m_activeDoc.ActiveView);
            }
            else
            {
                views = m_selectViewsData.SelectedViews;
            }

            //parameter : DXFExportOptions dxfExportOptions


            SATExportOptions satExportOptions = new SATExportOptions();

            //Export
            exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, satExportOptions);

            return(exported);
        }
Esempio n. 11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _host       = Ektron.Cms.Widget.WidgetHost.GetHost(this);
     _host.Title = "Animation Frame";
     _host.Edit += new EditDelegate(EditButtonClicked);
     ViewSet.SetActiveView(View);
 }
Esempio n. 12
0
        static void Main()
        {
            Workspace workspace = new Workspace("Getting Started", "This is a model of my software system.");
            Model     model     = workspace.Model;

            Person         user           = model.AddPerson("User", "A user of my software system.");
            SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system.");

            user.Uses(softwareSystem, "Uses");

            ViewSet           viewSet     = workspace.Views;
            SystemContextView contextView = viewSet.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");

            contextView.AddAllSoftwareSystems();
            contextView.AddAllPeople();

            Styles styles = viewSet.Configuration.Styles;

            styles.Add(new ElementStyle(Tags.SoftwareSystem)
            {
                Background = "#1168bd", Color = "#ffffff"
            });
            styles.Add(new ElementStyle(Tags.Person)
            {
                Background = "#08427b", Color = "#ffffff", Shape = Shape.Person
            });

            StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret);

            structurizrClient.PutWorkspaceAsync(WorkspaceId, workspace).Wait();
        }
Esempio n. 13
0
        /// <summary>
        /// 获取文档下的所有视图
        /// </summary>
        /// <param name="doc"></param>
        /// <returns></returns>
        public static ViewSet GetAllViews(Document doc)
        {
            ViewSet views = new ViewSet();
            FilteredElementCollector collector = new FilteredElementCollector(doc);
            FilteredElementIterator  it        = collector.OfClass(typeof(View)).GetElementIterator();

            it.Reset();
            while (it.MoveNext())
            {
                View view = it.Current as View3D;
                if (null != view && !view.IsTemplate && view.CanBePrinted)
                {
                    views.Insert(view);
                }
                else if (null == view)
                {
                    View view2D = it.Current as View;
                    if (view2D.ViewType == ViewType.FloorPlan | view2D.ViewType == ViewType.CeilingPlan | view2D.ViewType == ViewType.AreaPlan | view2D.ViewType == ViewType.Elevation | view2D.ViewType == ViewType.Section)
                    {
                        views.Insert(view2D);
                    }
                }
            }
            return(views);
        }
Esempio n. 14
0
        /// <summary>
        /// Collect the parameters and export
        /// </summary>
        /// <returns></returns>
        public override bool Export()
        {
            base.Export();

            bool exported = false;

            //parameter : ViewSet views
            ViewSet views = new ViewSet();

            if (m_currentViewOnly)
            {
                views.Insert(m_activeDoc.ActiveView);
            }
            else
            {
                views = m_selectViewsData.SelectedViews;
            }

            ICollection <ElementId> viewIds = new List <ElementId>();

            foreach (View view in views)
            {
                viewIds.Add(view.Id);
            }

            //parameter : DXFExportOptions dxfExportOptions
            SATExportOptions satExportOptions = new SATExportOptions();

            //Export
            exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, viewIds, satExportOptions);

            return(exported);
        }
Esempio n. 15
0
        static void Main()
        {
            Workspace workspace = new Workspace("Client-side encrypted workspace", "This is a client-side encrypted workspace. The passphrase is 'password'.");
            Model     model     = workspace.Model;

            Person         user           = model.AddPerson("User", "A user of my software system.");
            SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system.");

            user.Uses(softwareSystem, "Uses");

            ViewSet           viewSet     = workspace.Views;
            SystemContextView contextView = viewSet.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");

            contextView.AddAllSoftwareSystems();
            contextView.AddAllPeople();

            Styles styles = viewSet.Configuration.Styles;

            styles.Add(new ElementStyle(Tags.SoftwareSystem)
            {
                Background = "#d34407", Color = "#ffffff"
            });
            styles.Add(new ElementStyle(Tags.Person)
            {
                Background = "#f86628", Color = "#ffffff", Shape = Shape.Person
            });

            StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret);

            structurizrClient.EncryptionStrategy = new AesEncryptionStrategy("password");
            structurizrClient.PutWorkspaceAsync(WorkspaceId, workspace).Wait();
        }
Esempio n. 16
0
        /// <summary>
        /// Collect the parameters and export
        /// </summary>
        /// <returns></returns>
        public override bool Export()
        {
            base.Export();

            bool exported = false;
            //parameter : ViewSet views
            ViewSet views = new ViewSet();

            if (m_currentViewOnly)
            {
                views.Insert(m_activeDoc.ActiveView);
            }
            else
            {
                views = m_selectViewsData.SelectedViews;
            }

            //parameter : DWGExportOptions dwgExportOptions
            DGNExportOptions dgnExportOptions = new DGNExportOptions();

            dgnExportOptions.LayerMapping = m_exportLayerMapping;
            dgnExportOptions.TemplateFile = m_templateFile;

            //Export
            exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, dgnExportOptions);

            return(exported);
        }
Esempio n. 17
0
        static void Main()
        {
            Workspace workspace = new Workspace("Corporate Branding", "This is a model of my software system.");
            Model     model     = workspace.Model;

            Person         user           = model.AddPerson("User", "A user of my software system.");
            SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system.");

            user.Uses(softwareSystem, "Uses");

            ViewSet           views       = workspace.Views;
            SystemContextView contextView = views.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");

            contextView.AddAllSoftwareSystems();
            contextView.AddAllPeople();

            Styles styles = views.Configuration.Styles;

            styles.Add(new ElementStyle(Tags.Person)
            {
                Shape = Shape.Person
            });

            StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace);

            template.AddContextSection(softwareSystem, Format.Markdown, "Here is some context about the software system...\n\n![](embed:SystemContext)");

            Branding branding = views.Configuration.Branding;

            branding.Logo = ImageUtils.GetImageAsDataUri(new FileInfo("structurizr-logo.png"));

            StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret);

            structurizrClient.PutWorkspace(WorkspaceId, workspace);
        }
        private static void ConfigureStyles(ViewSet views)
        {
            var styles = views.Configuration.Styles;

            styles.Add(new ElementStyle(Tags.Person)
            {
                Background = "#08427b", Color = "#ffffff", Shape = Shape.Person
            });
            styles.Add(new ElementStyle(Tags.SoftwareSystem)
            {
                Background = "#1168bd", Color = "#ffffff"
            });
            styles.Add(new ElementStyle(Tags.Container)
            {
                Background = "#438dd5", Color = "#ffffff"
            });
            styles.Add(new ElementStyle(Tags.Component)
            {
                Background = "#85BBF0", Color = "#444444"
            });

            styles.Add(new RelationshipStyle(Tags.Asynchronous)
            {
                Dashed = true
            });
            styles.Add(new RelationshipStyle(Tags.Synchronous)
            {
                Dashed = false
            });

            //styles.Add(new RelationshipStyle(Tags.Relationship) { Routing = Routing.Orthogonal });
        }
Esempio n. 19
0
        ExportTo2dDwf()
        {
            /// get output dir to save DWFs to
            FolderBrowserDialog dbox = new FolderBrowserDialog();

            dbox.Description         = "Folder to save exported DWF files to";
            dbox.ShowNewFolderButton = true;

            try
            {
                if (dbox.ShowDialog() == DialogResult.OK)
                {
                    ViewSet viewsToExport = Utils.View.GetAvailableViewsToExport(m_revitApp.ActiveUIDocument.Document);

                    DWFExportOptions opts = new DWFExportOptions();
                    opts.MergedViews = true;

                    /// export now
                    m_revitApp.ActiveUIDocument.Document.Export(dbox.SelectedPath, "", viewsToExport, opts);

                    /// feedback to user
                    MessageBox.Show("Done exporting to 2d Dwf!!");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Esempio n. 20
0
        static void Main(string[] args)
        {
            Workspace workspace = new Workspace("My model", "This is a model of my software system.");
            Model     model     = workspace.Model;

            Person         user           = model.AddPerson("User", "A user of my software system.");
            SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system.");

            user.Uses(softwareSystem, "Uses");

            ViewSet           viewSet     = workspace.Views;
            SystemContextView contextView = viewSet.CreateSystemContextView(softwareSystem, "context", "A simple example of a System Context diagram.");

            contextView.AddAllSoftwareSystems();
            contextView.AddAllPeople();

            Styles styles = viewSet.Configuration.Styles;

            styles.Add(new ElementStyle(Tags.SoftwareSystem)
            {
                Background = "#1168bd", Color = "#ffffff"
            });
            styles.Add(new ElementStyle(Tags.Person)
            {
                Background = "#08427b", Color = "#ffffff"
            });

            StructurizrClient structurizrClient = new StructurizrClient("key", "secret");

            structurizrClient.PutWorkspace(1234, workspace);
        }
Esempio n. 21
0
        PlaceViews(ViewSet views, ViewSheet sheet)
        {
            double xDistance = 0;
            double yDistance = 0;

            CalculateDistance(sheet.Outline, views.Size, ref xDistance, ref yDistance);

            UV origin = GetOffset(sheet.Outline, xDistance, yDistance);
            UV temp   = new UV(origin.U, origin.V);

            int n = 1;

            foreach (Autodesk.Revit.DB.View v in views)
            {
                UV location = new UV(temp.U, temp.V);
                Autodesk.Revit.DB.View view = v;
                Rescale(view, xDistance, yDistance);
                Viewport.Create(view.Document, sheet.Id, view.Id, new XYZ(location.U, location.V, 0));

                if (0 != n++ % m_rows)
                {
                    temp = new UV(temp.U + xDistance * (1 - TITLEBAR), temp.V);
                }
                else
                {
                    temp = new UV(origin.U, temp.V + yDistance);
                }
            }
        }
Esempio n. 22
0
        GetAvailableViewsToExport(Document doc)
        {
            ViewSet viewSet = new ViewSet();

            // TBD: using a filter iterator will only give you the base class View, not derived classes
            // like View3D or ViewDrafting.

            /*ElementFilterIterator viewIter = m_revitApp.ActiveUIDocument.Document.GetElements(typeof(Autodesk.Revit.DB.View));
             * while (viewIter.MoveNext()) {
             *  Autodesk.Revit.DB.View tmpView = (Autodesk.Revit.DB.View)viewIter.Current;
             *  if (tmpView.CanBePrinted)
             *      viewSet.Insert((Autodesk.Revit.DB.View)viewIter.Current);
             * }*/

            FilteredElementCollector fec = new FilteredElementCollector(doc);
            ElementClassFilter       elementsAreWanted = new ElementClassFilter(typeof(View));

            fec.WherePasses(elementsAreWanted);
            List <Element> elements = fec.ToElements() as List <Element>;

            foreach (Element element in elements)
            {
                Autodesk.Revit.DB.View tmpView = element as Autodesk.Revit.DB.View;

                if ((tmpView != null) && tmpView.CanBePrinted)
                {
                    viewSet.Insert(tmpView);
                }
            }

            return(viewSet);
        }
        static void Main()
        {
            Workspace workspace = new Workspace("Documentation - Structurizr", "An empty software architecture document using the Structurizr template.");
            Model     model     = workspace.Model;
            ViewSet   views     = workspace.Views;

            Person         user           = model.AddPerson("User", "A user of my software system.");
            SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system.");

            user.Uses(softwareSystem, "Uses");

            SystemContextView contextView = views.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");

            contextView.AddAllSoftwareSystems();
            contextView.AddAllPeople();

            Styles styles = views.Configuration.Styles;

            styles.Add(new ElementStyle(Tags.Person)
            {
                Shape = Shape.Person
            });

            StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace);

            // this is the Markdown version
            DirectoryInfo documentationRoot = new DirectoryInfo("Documentation" + Path.DirectorySeparatorChar + "structurizr" + Path.DirectorySeparatorChar + "markdown");

            template.AddContextSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "01-context.md")));
            template.AddFunctionalOverviewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "02-functional-overview.md")));
            template.AddQualityAttributesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "03-quality-attributes.md")));
            template.AddConstraintsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "04-constraints.md")));
            template.AddPrinciplesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "05-principles.md")));
            template.AddSoftwareArchitectureSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "06-software-architecture.md")));
            template.AddDataSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "07-data.md")));
            template.AddInfrastructureArchitectureSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "08-infrastructure-architecture.md")));
            template.AddDeploymentSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "09-deployment.md")));
            template.AddDevelopmentEnvironmentSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "10-development-environment.md")));
            template.AddOperationAndSupportSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "11-operation-and-support.md")));
            template.AddDecisionLogSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "12-decision-log.md")));

            // this is the AsciiDoc version
//            DirectoryInfo documentationRoot = new DirectoryInfo("Documentation" + Path.DirectorySeparatorChar + "structurizr" + Path.DirectorySeparatorChar + "asciidoc");
//            template.AddContextSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "01-context.adoc")));
//            template.AddFunctionalOverviewSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "02-functional-overview.adoc")));
//            template.AddQualityAttributesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "03-quality-attributes.adoc")));
//            template.AddConstraintsSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "04-constraints.adoc")));
//            template.AddPrinciplesSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "05-principles.adoc")));
//            template.AddSoftwareArchitectureSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "06-software-architecture.adoc")));
//            template.AddDataSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "07-data.adoc")));
//            template.AddInfrastructureArchitectureSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "08-infrastructure-architecture.adoc")));
//            template.AddDeploymentSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "09-deployment.adoc")));
//            template.AddDevelopmentEnvironmentSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "10-development-environment.adoc")));
//            template.AddOperationAndSupportSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "11-operation-and-support.adoc")));
//            template.AddDecisionLogSection(softwareSystem, new FileInfo(Path.Combine(documentationRoot.FullName, "12-decision-log.adoc")));

            StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret);

            structurizrClient.PutWorkspaceAsync(WorkspaceId, workspace).Wait();
        }
        // effects: Generates views for the particular cellgroup in this. Returns an
        // error log describing the errors that were encountered (if none
        // were encountered, the ErrorLog.Count is 0). Places the generated
        // views in result
        internal ErrorLog GenerateAllBidirectionalViews(ViewSet views, CqlIdentifiers identifiers)
        {
            // Allow missing attributes for now to make entity splitting run through
            // we cannot do this for query views in general: need to obtain the exact enumerated domain

            if (m_config.IsNormalTracing)
            {
                StringBuilder builder = new StringBuilder();
                Cell.CellsToBuilder(builder, m_cellGroup);
                Helpers.StringTraceLine(builder.ToString());
            }

            m_config.SetTimeForFinishedActivity(PerfType.CellCreation);
            // Check if the cellgroup is consistent and all known S constraints are
            // satisified by the known C constraints
            CellGroupValidator validator = new CellGroupValidator(m_cellGroup, m_config);
            ErrorLog           errorLog  = validator.Validate();

            if (errorLog.Count > 0)
            {
                errorLog.PrintTrace();
                return(errorLog);
            }

            m_config.SetTimeForFinishedActivity(PerfType.KeyConstraint);

            // We generate update views first since they perform the main
            // validation checks
            if (m_config.GenerateUpdateViews)
            {
                errorLog = GenerateDirectionalViews(ViewTarget.UpdateView, identifiers, views);
                if (errorLog.Count > 0)
                {
                    return(errorLog); // If we have discovered errors here, do not generate query views
                }
            }

            // Make sure that the foreign key constraints are not violated
            if (m_config.IsValidationEnabled)
            {
                CheckForeignKeyConstraints(errorLog);
            }
            m_config.SetTimeForFinishedActivity(PerfType.ForeignConstraint);

            if (errorLog.Count > 0)
            {
                errorLog.PrintTrace();
                return(errorLog); // If we have discovered errors here, do not generate query views
            }

            // Query views - do not allow missing attributes
            // For the S-side, we add NOT ... for each scalar constant so
            // that if we have C, P in the mapping but the store has C, P, S,
            // we can handle it in the query views
            m_updateDomainMap.ExpandDomainsToIncludeAllPossibleValues();

            errorLog = GenerateDirectionalViews(ViewTarget.QueryView, identifiers, views);

            return(errorLog);
        }
Esempio n. 25
0
        Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            //Reference r;

            //ElementInLinkSelectionFilter<View> filter = new ElementInLinkSelectionFilter<View>(doc);

            //r = uidoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.PointOnElement);

            //Element e = doc.GetElement(r);

            ICollection <ElementId> elt = uidoc.Selection.GetElementIds();
            ViewSheet a, b;

            //ViewSet b=new ViewSet();

            /*
             * foreach (ElementId i in elt)
             * {
             *  b.Insert(doc.GetElement(i) as ViewSheet);
             * }
             * DWFXExportOptions options = new DWFXExportOptions();
             * options.MergedViews = true;
             * String dir = doc.PathName.Substring(0, doc.PathName.Length - doc.Title.Length - 4);
             */
            using (Transaction tr = new Transaction(doc, "SheetNumberChanging"))
            {
                tr.Start();

                StringBuilder info   = new StringBuilder();
                ViewSet       sheets = new ViewSet();
                foreach (ElementId t in elt)
                {
                    ViewSheet sheet = doc.GetElement(t) as ViewSheet;
                    sheets.Insert(sheet);
                }
                List <ViewSheet> mySheets       = elt.Select(x => doc.GetElement(x) as ViewSheet).ToList();
                List <ViewSheet> sortedElements = mySheets.OrderBy(x => x.SheetNumber).ToList();
                a = sortedElements.ElementAt(0);
                b = sortedElements.ElementAt(1);

                string firstSheet  = a.get_Parameter(BuiltInParameter.SHEET_NUMBER).AsString();
                string secondSheet = b.get_Parameter(BuiltInParameter.SHEET_NUMBER).AsString();
                a.get_Parameter(BuiltInParameter.SHEET_NUMBER).Set("-99");
                b.get_Parameter(BuiltInParameter.SHEET_NUMBER).Set(firstSheet);
                a.get_Parameter(BuiltInParameter.SHEET_NUMBER).Set(secondSheet);
                //doc.Export(dir, "MyExportBitch"+b.Size.ToString(), b, options);

                tr.Commit();
            }



            return(Result.Succeeded);
        }
Esempio n. 26
0
        /// <summary>
        /// Constructor of views object.
        /// </summary>
        /// <param name="doc">the active document</param>
        public ViewsMgr(Document doc, ViewSet createdViewList)
        {
            //capture the created views and set it to the var to make visible to class
            receivedCreatedViews = createdViewList;

            GetAllViews(doc);
            GetTitleBlocks(doc);
        }
Esempio n. 27
0
 protected void EditButtonClicked(string settings)
 {
     titleTextBox.Text      = Title;
     calendarIDtextBox.Text = CalendarID.ToString();
     taxonomyTextBox.Text   = TaxonomyPath;
     numEventsTextBox.Text  = NumEvents.ToString();
     ViewSet.SetActiveView(Edit);
 }
Esempio n. 28
0
 protected void SaveButton_Click(object sender, EventArgs e)
 {
     VideoID  = URLtextBox.Text;
     Title    = titleTextBox.Text;
     Subtitle = subtitleTextBox.Text;
     _host.SaveWidgetDataMembers();
     ViewSet.SetActiveView(View);
 }
Esempio n. 29
0
 public SelectViewsData(ExternalCommandData commandData)
 {
     this.m_commandData     = commandData;
     this.m_printableViews  = new ViewSet();
     this.m_printableSheets = new ViewSet();
     this.m_selectedViews   = new ViewSet();
     this.GetAllPrintableViews();
 }
Esempio n. 30
0
 /// <summary>
 /// 事务
 /// </summary>
 /// <param name="database">数据库执行</param>
 /// <param name="tableName">表名称</param>
 public ViewContext(DbExecutor database, string tableName = null) : base(database, tableName)
 {
     if (string.IsNullOrWhiteSpace(tableName))
     {
         Name = TableMapCache.GetMap <TEntity>().ClassInfo.Name;
     }
     ViewSet = new ViewSet <TEntity>(this);
     Query   = DbFactory.CreateQueryView(this);
 }
Esempio n. 31
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="commandData"></param>
        public SelectViewsData(ExternalCommandData commandData)
        {
            m_commandData = commandData;
            m_printableViews = new ViewSet();
            m_printableSheets = new ViewSet();
            m_selectedViews = new ViewSet();

            GetAllPrintableViews();
        }
Esempio n. 32
0
 /// <summary>
 /// Boilerplate widget code
 /// </summary>
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     base.Host.Edit     += new EditDelegate(EditEvent);
     base.Host.Maximize += new MaximizeDelegate(delegate() { Visible = true; });
     base.Host.Minimize += new MinimizeDelegate(delegate() { Visible = false; });
     base.Host.Create   += new CreateDelegate(delegate() { EditEvent(""); });
     ViewSet.SetActiveView(View);
 }
Esempio n. 33
0
        /// <summary>
        /// Export FBX format
        /// </summary>
        /// <returns></returns>
        public override bool Export()
        {
            base.Export();

            bool exported = false;
            //parameter : ViewSet views
            ViewSet views = new ViewSet();
            views.Insert(m_activeDoc.ActiveView);

            FBXExportOptions options = new FBXExportOptions();
            exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, options);

            return exported;
        }
Esempio n. 34
0
        public IExternalCommand.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Document curDoc = commandData.Application.ActiveDocument;
            DWF2DExportOptions options = new DWF2DExportOptions();
            ViewSet viewSet = new ViewSet();

            viewSet.Insert(curDoc.ActiveView);
            if (curDoc.Export("C:\\", "abc.dwf", viewSet, options) == false)
            {
                message = "Export current view to DWF file failed.";
                return IExternalCommand.Result.Failed;
            }

            return IExternalCommand.Result.Succeeded;
        }
Esempio n. 35
0
 /// <summary>
 /// Implement this method as an external command for Revit.
 /// </summary>
 /// <param name="commandData">An object that is passed to the external application
 /// which contains data related to the command,
 /// such as the application object and active view.</param>
 /// <param name="message">A message that can be set by the external application
 /// which will be displayed if a failure or cancellation is returned by
 /// the external command.</param>
 /// <param name="elements">A set of elements to which the external application
 /// can add elements that are to be highlighted in case of failure or cancellation.</param>
 /// <returns>Return the status of the external command.
 /// A result of Succeeded means that the API external method functioned as expected.
 /// Cancelled can be used to signify that the user cancelled the external operation 
 /// at some point. Failure should be returned if the application is unable to proceed with
 /// the operation.</returns>
 public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, 
     ref string message, Autodesk.Revit.DB.ElementSet elements)
 {
     // Filter all printable views in current document and print them,
     // the print will raise events registered in controlled application.
     // After run this external command please refer to log files under folder of this assembly.
     Document document = commandData.Application.ActiveUIDocument.Document;
     try
     {
         List<Autodesk.Revit.DB.Element> viewElems = new List<Autodesk.Revit.DB.Element>();
         FilteredElementCollector collector = new FilteredElementCollector(document);
         viewElems.AddRange(collector.OfClass(typeof(View)).ToElements());
         //
         // Filter all printable views
         ViewSet printableViews = new ViewSet();
         foreach (View view in viewElems)
         {
             // skip view templates because they're invalid for print
             if (!view.IsTemplate && view.CanBePrinted)
             {
                 printableViews.Insert(view);
             }
         }
         //
         // Print to file to folder of assembly
         String assemblyPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
         PrintManager pm = document.PrintManager;
         pm.PrintToFile = true;
         pm.PrintToFileName = assemblyPath + "\\PrintOut.prn";
         pm.Apply();
         //
         // Print views now to raise events:
         document.Print(printableViews);
     }
     catch(Exception ex)
     {
         message = ex.Message;
         return Autodesk.Revit.UI.Result.Failed;
     }
     //
     // return succeed by default
     return Autodesk.Revit.UI.Result.Succeeded;
 }
Esempio n. 36
0
        PlaceViews(ViewSet views, ViewSheet sheet)
        {
            double xDistance = 0;
            double yDistance = 0;
            CalculateDistance(sheet.Outline, views.Size, ref xDistance, ref yDistance);

            UV origin = GetOffset(sheet.Outline, xDistance, yDistance);
            UV temp = new UV(origin.U, origin.V);

            int n = 1;
            foreach (Autodesk.Revit.DB.View v in views) {
                UV location = new UV(temp.U, temp.V);
                Autodesk.Revit.DB.View view = v;
                Rescale(view, xDistance, yDistance);
                Viewport.Create(view.Document, sheet.Id, view.Id, new XYZ(location.U, location.V, 0));

                if (0 != n++ % m_rows) {
                    temp = new UV( temp.U + xDistance * (1 - TITLEBAR), temp.V );                    
                }
                else {
                    temp = new UV( origin.U,temp.V + yDistance);
                }
            }
        }
Esempio n. 37
0
        /// <summary>
        /// Place all selected views on this sheet's appropriate location.
        /// </summary>
        /// <param name="views">all selected views</param>
        /// <param name="sheet">all views located sheet</param>
        private void PlaceViews(ViewSet views, ViewSheet sheet)
        {
            double xDistance = 0;
            double yDistance = 0;
            CalculateDistance(sheet.Outline, views.Size, ref xDistance, ref yDistance);

            Autodesk.Revit.DB.UV origin = GetOffSet(sheet.Outline, xDistance, yDistance);
            //Autodesk.Revit.DB.UV temp = new Autodesk.Revit.DB.UV (origin.U, origin.V);
            double tempU = origin.U;
            double tempV = origin.V;
            int n = 1;
            foreach (Autodesk.Revit.DB.View v in views)
            {
                Autodesk.Revit.DB.UV location = new Autodesk.Revit.DB.UV (tempU, tempV);
                Autodesk.Revit.DB.View view = v;
                Rescale(view, xDistance, yDistance);
                try
                {
                    sheet.AddView(view, location);
                }
                catch (ArgumentException /*ae*/)
                {
                    throw new InvalidOperationException("The view '" + view.Name +
                        "' can't be added, it may have already been placed in another sheet.");
                }

                if (0 != n++ % m_rows)
                {
                    tempU = tempU + xDistance * (1 - TITLEBAR);
                }
                else
                {
                    tempU = origin.U;
                    tempV = tempV + yDistance;
                }
            }
        }
        /// <summary>
        /// Collect the parameters and export
        /// </summary>
        /// <returns></returns>
        public override bool Export()
        {
            Transaction transaction = new Transaction(m_activeDoc, "Export_To_DWF");
            transaction.Start();
            bool exported = false;
            base.Export();

            //parameter : ViewSet views
            ViewSet views = new ViewSet();
            if (m_currentViewOnly)
            {
                views.Insert(m_activeDoc.ActiveView);
            }
            else
            {
                views = m_selectViewsData.SelectedViews;
            }

            // Export DWFx
            if (m_exportFormat == ExportFormat.DWFx)
            {
                DWFXExportOptions options = new DWFXExportOptions();
                options.ExportObjectData = m_exportObjectData;
                options.ExportingAreas = m_exportAreas;
                options.MergedViews = m_exportMergeFiles;
                options.ImageFormat = m_dwfImageFormat;
                options.ImageQuality = m_dwfImageQuality;
                exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, options);
            }
            // Export DWF
            else
            {
                DWFExportOptions options = new DWFExportOptions();
                options.ExportObjectData = m_exportObjectData;
                options.ExportingAreas = m_exportAreas;
                options.MergedViews = m_exportMergeFiles;
                options.ImageFormat = m_dwfImageFormat;
                options.ImageQuality = m_dwfImageQuality;
                exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, options);
            }
            transaction.Commit();

            return exported;
        }
Esempio n. 39
0
        private ErrorLog GenerateQueryViewForExtentAndType(StorageEntityContainerMapping entityContainerMapping, CqlIdentifiers identifiers, ViewSet views, EntitySetBase entity, EntityTypeBase type, ViewGenMode mode)
        {
            Debug.Assert(mode != ViewGenMode.GenerateAllViews);

            // Keep track of the mapping exceptions that we have generated
            ErrorLog errorLog = new ErrorLog();

            if (m_config.IsViewTracing)
            {
                Helpers.StringTraceLine(String.Empty);
                Helpers.StringTraceLine(String.Empty);
                Helpers.FormatTraceLine("================= Generating {0} Query View for: {1} ===========================",
                                    (mode == ViewGenMode.OfTypeViews) ? "OfType" : "OfTypeOnly",
                                    entity.Name);
                Helpers.StringTraceLine(String.Empty);
                Helpers.StringTraceLine(String.Empty);
            }

            try
            {
                // (1) view generation (checks that extents are fully mapped)
                ViewgenContext context = CreateViewgenContext(entity, ViewTarget.QueryView, identifiers);
                QueryRewriter queryRewriter = GenerateViewsForExtentAndType(type, context, identifiers, views, mode);
            }
            catch (InternalMappingException exception)
            {
                // All exceptions have mapping errors in them
                Debug.Assert(exception.ErrorLog.Count > 0, "Incorrectly created mapping exception");
                errorLog.Merge(exception.ErrorLog);
            }

            return errorLog;
        }
Esempio n. 40
0
        /// <summary>
        /// Get all the views to be displayed
        /// </summary>
        private void GetViews()
        {
            FilteredElementCollector collector = new FilteredElementCollector(m_activeDoc);
            FilteredElementIterator itor = collector.OfClass(typeof(View)).GetElementIterator();
            itor.Reset();
            ViewSet views = new ViewSet();
            ViewSet floorPlans = new ViewSet();
            ViewSet ceilingPlans = new ViewSet();
            ViewSet engineeringPlans = new ViewSet();
            while (itor.MoveNext())
            {
                View view = itor.Current as View;
                // skip view templates because they're invalid for import/export
                if (view == null || view.IsTemplate)
                {
                    continue;
                }
                else if (view.ViewType == Autodesk.Revit.DB.ViewType.FloorPlan)
                {
                    floorPlans.Insert(view);
                }
                else if (view.ViewType == Autodesk.Revit.DB.ViewType.CeilingPlan)
                {
                    ceilingPlans.Insert(view);
                }
                else if (view.ViewType == Autodesk.Revit.DB.ViewType.EngineeringPlan)
                {
                    engineeringPlans.Insert(view);
                }
            }

            foreach (View floorPlan in floorPlans)
            {
                foreach (View ceilingPlan in ceilingPlans)
                {
                    if (floorPlan.ViewName == ceilingPlan.ViewName)
                    {
                        views.Insert(floorPlan);
                    }
                }
            }

            foreach (View engineeringPlan in engineeringPlans)
            {
                if (engineeringPlan.ViewName == engineeringPlan.GenLevel.Name)
                {
                    views.Insert(engineeringPlan);
                }
            }

            View activeView = m_activeDoc.ActiveView;
            Autodesk.Revit.DB.ViewType viewType = activeView.ViewType;
            if (viewType == Autodesk.Revit.DB.ViewType.FloorPlan ||
                viewType == Autodesk.Revit.DB.ViewType.CeilingPlan)
            {
                m_views.Insert(activeView);
                foreach (View view in views)
                {
                    if (view.GenLevel.Elevation < activeView.GenLevel.Elevation)
                    {
                        m_views.Insert(view);
                    }
                }
            }
            else if (viewType == Autodesk.Revit.DB.ViewType.EngineeringPlan)
            {
                if (views.Contains(activeView))
                {
                    m_views.Insert(activeView);
                }
                foreach (View view in views)
                {
                    if (view.GenLevel.Elevation < activeView.GenLevel.Elevation)
                    {
                        m_views.Insert(view);
                    }
                }
            }
            else//Get view of the lowest elevation
            {
                int i = 0;
                double elevation = 0;
                View viewLowestElevation = null;
                foreach (View view in views)
                {
                    if (i == 0)
                    {
                        elevation = view.GenLevel.Elevation;
                        viewLowestElevation = view;
                    }
                    else
                    {
                        if (view.GenLevel.Elevation <= elevation)
                        {
                            elevation = view.GenLevel.Elevation;
                            viewLowestElevation = view;
                        }
                    }

                    i++;
                }
                m_views.Insert(viewLowestElevation);
            }
        }
Esempio n. 41
0
        public void ChangeCurrentViewSheetSet(List<string> names)
        {
            ViewSet selectedViews = new ViewSet();

            if (null != names && 0 < names.Count)
            {
                foreach (Autodesk.Revit.DB.View view in m_viewSheetSetting.AvailableViews)
                {
                    if (names.Contains(view.ViewType.ToString() + ": " + view.ViewName))
                    {
                        selectedViews.Insert(view);
                    }
                }
            }

            IViewSheetSet viewSheetSet = m_viewSheetSetting.CurrentViewSheetSet;
            viewSheetSet.Views = selectedViews;
            Save();
        }
Esempio n. 42
0
        // effects: Generates a view for an extent "extent" that belongs to
        // schema "schema". extentCells are the cells for this extent.
        // Adds the view corrsponding to the extent to "views"
        private QueryRewriter GenerateDirectionalViewsForExtent(ViewTarget viewTarget, EntitySetBase extent, CqlIdentifiers identifiers, ViewSet views)
        {

            // First normalize the cells in terms of multiconstants, etc
            // and then generate the view for the extent
            ViewgenContext context = CreateViewgenContext(extent, viewTarget, identifiers);
            QueryRewriter queryRewriter = null;

            if (m_config.GenerateViewsForEachType)
            {
                // generate views for each OFTYPE(Extent, Type) combination
                foreach (EdmType type in MetadataHelper.GetTypeAndSubtypesOf(extent.ElementType, m_entityContainerMapping.StorageMappingItemCollection.EdmItemCollection, false /*includeAbstractTypes*/))
                {
                    if (m_config.IsViewTracing && false == type.Equals(extent.ElementType))
                    {
                        Helpers.FormatTraceLine("CQL View for {0} and type {1}", extent.Name, type.Name);
                    }
                    queryRewriter = GenerateViewsForExtentAndType(type, context, identifiers, views, ViewGenMode.OfTypeViews);
                }
            }
            else
            {
                // generate the view for Extent only
                queryRewriter = GenerateViewsForExtentAndType(extent.ElementType, context, identifiers, views, ViewGenMode.OfTypeViews);
            }
            if (viewTarget == ViewTarget.QueryView)
            {
                m_config.SetTimeForFinishedActivity(PerfType.QueryViews);
            }
            else
            {
                m_config.SetTimeForFinishedActivity(PerfType.UpdateViews);
            }

            // cache this rewriter (and context inside it) for future use in FK checking
            m_queryRewriterCache[extent] = queryRewriter;
            return queryRewriter;
        }
Esempio n. 43
0
        /// <summary>
        /// Add the Level 1 (type = Floor Plan) view to a newly created sheet.
        /// </summary>
        public void ViewToNewSheetHardwired()
        {
            Revit.Document doc = m_revitApp.ActiveUIDocument.Document;

              // Collect all available views
              ViewSet allViews = Utils.View.GetAllViews( doc );

              // Collection of views that have been added to existing sheets.
              ViewSet usedViews = new ViewSet();

              // Collect all the existing sheets. It would be nice to have some API to do this.
              Revit.ElementSet allSheets = Utils.View.GetAllSheets( doc );

              // Create a new sheet
              ViewSheet sheet = ViewSheet.Create( doc, new FilteredElementCollector( doc ).OfClass( typeof( FamilySymbol ) ).OfCategory( BuiltInCategory.OST_TitleBlocks ).Cast<FamilySymbol>().LastOrDefault().Id );

              Random rnd = new Random();
              String name = "RevitLookup_Sheet" + rnd.Next().ToString();
              sheet.Name = name;

              foreach( ViewSheet viewSheet in allSheets )
              {
            // jeremy migrated from Revit 2014 to 2015:
            // 'Autodesk.Revit.DB.ViewSheet.Views' is obsolete: 'This property is obsolete in Revit 2015.  Use GetAllPlacedViews() instead.'
            //foreach( Autodesk.Revit.DB.View usedView in viewSheet.Views )

            foreach( ElementId id in viewSheet.GetAllPlacedViews() )
            {
              Autodesk.Revit.DB.View usedView = doc.GetElement( id )
            as Autodesk.Revit.DB.View;

              usedViews.Insert( usedView );
            }
              }

              // Note: The application does not allow the addition of a view to a new sheet if that view has already been added to
              // an existing sheet. I realized this when a programmatic attempt to do so resulted in an exception being thrown.
              // So running this hardwired test a second time would result in an exception (As "Level 1 (FloorPlan) would have already been added)".
              // The workaround that has been used here is that first all the available sheets and their added views are gathered.
              // Before adding a view it is compared with the used views. arj - 1/17/07
              //
              foreach( Autodesk.Revit.DB.View view in allViews )
              {
            // Has been hardwired for the following view.
            if( ( view.ViewName == "Level 1" ) && ( view.ViewType == ViewType.FloorPlan ) )
            {
              UV point = view.Outline.Max;

              // Display notification message if view is already being used.
              foreach( Autodesk.Revit.DB.View usedView in usedViews )
              {
            if( ( usedView.ViewName == view.ViewName ) && ( usedView.ViewType == view.ViewType ) )
            {
              MessageBox.Show( "View already added to an existing sheet", "RevitLookup Test", MessageBoxButtons.OK, MessageBoxIcon.Information );
              return;
            }
              }
              Viewport.Create( view.Document, sheet.Id, view.Id, new XYZ( point.U, point.V, 0 ) );
            }
              }
        }
Esempio n. 44
0
        GetAvailableViewsToExport (Document doc)
        {
            ViewSet viewSet = new ViewSet();

            // TBD: using a filter iterator will only give you the base class View, not derived classes
            // like View3D or ViewDrafting.
            /*ElementFilterIterator viewIter = m_revitApp.ActiveUIDocument.Document.GetElements(typeof(Autodesk.Revit.DB.View));
            while (viewIter.MoveNext()) {
                Autodesk.Revit.DB.View tmpView = (Autodesk.Revit.DB.View)viewIter.Current;
                if (tmpView.CanBePrinted)
                    viewSet.Insert((Autodesk.Revit.DB.View)viewIter.Current);
            }*/

            FilteredElementCollector fec = new FilteredElementCollector(doc);
            ElementClassFilter elementsAreWanted = new ElementClassFilter(typeof(View));
            fec.WherePasses(elementsAreWanted);
            List<Element> elements = fec.ToElements() as List<Element>;

            foreach (Element element in elements)
            {
               Autodesk.Revit.DB.View tmpView = element as Autodesk.Revit.DB.View;

               if ((tmpView != null) && tmpView.CanBePrinted)
               {
                  viewSet.Insert(tmpView);
               }
            }

            return viewSet;
        }
Esempio n. 45
0
        /// <summary>
        /// Collect the parameters and export
        /// </summary>
        /// <returns></returns>
        public override bool Export()
        {
            base.Export();

            bool exported = false;
            //parameter : ViewSet views
            ViewSet views = new ViewSet();
            if (m_currentViewOnly)
            {
                views.Insert(m_activeDoc.ActiveView);
            }
            else
            {
                views = m_selectViewsData.SelectedViews;
            }

            //parameter : DWGExportOptions dwgExportOptions
            DGNExportOptions dgnExportOptions = new DGNExportOptions();
            dgnExportOptions.LayerMapping = m_exportLayerMapping;
            dgnExportOptions.TemplateFile = m_templateFile;

            //Export
            exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, dgnExportOptions);

            return exported;
        }
Esempio n. 46
0
        public void ExportTo3dDwf()
        {
            // get output dir to save DWFs to
             System.Windows.Forms.FolderBrowserDialog dbox = new System.Windows.Forms.FolderBrowserDialog();
             dbox.Description = "Folder to save exported DWF files to";
             dbox.ShowNewFolderButton = true;

             try
             {
            if (dbox.ShowDialog() == DialogResult.OK)
            {

               ViewSet viewsToExport = Utils.View.GetAvailableViewsToExport(m_revitApp.ActiveUIDocument.Document);

               /// filter out only 3d views
               ViewSet views3dToExport = new ViewSet();
               foreach (Autodesk.Revit.DB.View view in viewsToExport)
               {
                  if (view.ViewType == ViewType.ThreeD)
                  {
                     views3dToExport.Insert(view);
                  }
               }

               if (views3dToExport.Size == 0)
                  throw new Exception("No files exported. Make sure you have atleast one 3d view.");

               DWFExportOptions opts = new DWFExportOptions();
               /// export now
               m_revitApp.ActiveUIDocument.Document.Export(dbox.SelectedPath, "", views3dToExport, opts);

               /// feedback to user
               MessageBox.Show("Done exporting to 3d Dwf!!");
            }
             }
             catch (Exception e)
             {
            MessageBox.Show(e.Message);
             }
        }
Esempio n. 47
0
        /// <summary>
        /// Загрузить настройки представлений из файла
        /// </summary>
        public bool LoadFromFile(string fileName, out string errMsg)
        {
            // установка значений по умолчанию
            ViewSetList = new List<ViewSet>();

            try
            {
                if (!File.Exists(fileName))
                    throw new FileNotFoundException(string.Format(CommonPhrases.NamedFileNotFound, fileName));

                // загрузка настроек
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(fileName);

                XmlNodeList viewSetNodeList = xmlDoc.DocumentElement.SelectNodes("ViewSet");

                foreach (XmlElement viewSetElement in viewSetNodeList)
                {
                    ViewSet viewSet = new ViewSet(viewSetElement.GetAttribute("name"),
                        ScadaUtils.NormalDir(viewSetElement.GetAttribute("directory")));
                    ViewSetList.Add(viewSet);

                    XmlNodeList viewNodeList = viewSetElement.SelectNodes("View");

                    foreach (XmlElement viewElement in viewNodeList)
                    {
                        ViewInfo viewInfo = new ViewInfo(viewElement.InnerText,
                            viewElement.GetAttribute("type"), viewElement.GetAttribute("fileName"));
                        viewSet.Items.Add(viewInfo);
                    }
                }

                errMsg = "";
                return true;
            }
            catch (Exception ex)
            {
                errMsg = WebPhrases.LoadViewSettingsError + ": " + ex.Message;
                return false;
            }
        }
Esempio n. 48
0
 /// <summary>
 /// Initialize the variables
 /// </summary>
 private void Initialize()
 {
     //Views to export
     m_exportViews = new ViewSet();
 }
Esempio n. 49
0
        private QueryRewriter GenerateViewsForExtentAndType(EdmType generatedType, ViewgenContext context, CqlIdentifiers identifiers, ViewSet views, ViewGenMode mode)
        {

            Debug.Assert(mode != ViewGenMode.GenerateAllViews, "By definition this method can not handle generating views for all extents");

            QueryRewriter queryRewriter = new QueryRewriter(generatedType, context, mode);
            queryRewriter.GenerateViewComponents();

            // Get the basic view
            CellTreeNode basicView = queryRewriter.BasicView;

            if (m_config.IsNormalTracing)
            {
                Helpers.StringTrace("Basic View: ");
                Helpers.StringTraceLine(basicView.ToString());
            }

            CellTreeNode simplifiedView = GenerateSimplifiedView(basicView, queryRewriter.UsedCells);

            if (m_config.IsNormalTracing)
            {
                Helpers.StringTraceLine(String.Empty);
                Helpers.StringTrace("Simplified View: ");
                Helpers.StringTraceLine(simplifiedView.ToString());
            }

            CqlGenerator cqlGen = new CqlGenerator(simplifiedView,
                                                   queryRewriter.CaseStatements, 
                                                   identifiers,
                                                   context.MemberMaps.ProjectedSlotMap,
                                                   queryRewriter.UsedCells.Count, 
                                                   queryRewriter.TopLevelWhereClause,
                                                   m_entityContainerMapping.StorageMappingItemCollection);

            string eSQLView ;
            DbQueryCommandTree commandTree;
            if (m_config.GenerateEsql)
            {
                eSQLView = cqlGen.GenerateEsql();
                commandTree = null;
            }
            else
            {
                eSQLView = null;
                commandTree = cqlGen.GenerateCqt();
            }

            GeneratedView generatedView = GeneratedView.CreateGeneratedView(context.Extent, generatedType, commandTree, eSQLView, m_entityContainerMapping.StorageMappingItemCollection, m_config);
            views.Add(context.Extent, generatedView);

            return queryRewriter;
        }
Esempio n. 50
0
 Views(Document doc)
 {
     m_allViews = Utils.View.GetAllViews(doc);            
     GetTitleBlocks(doc);
 }
Esempio n. 51
0
        internal ErrorLog GenerateQueryViewForSingleExtent(ViewSet views, CqlIdentifiers identifiers, EntitySetBase entity, EntityTypeBase type, ViewGenMode mode)
        {
            Debug.Assert(mode != ViewGenMode.GenerateAllViews);

            if (m_config.IsNormalTracing)
            {
                StringBuilder builder = new StringBuilder();
                Cell.CellsToBuilder(builder, m_cellGroup);
                Helpers.StringTraceLine(builder.ToString());
            }

            // Check if the cellgroup is consistent and all known S constraints are
            // satisified by the known C constraints
            CellGroupValidator validator = new CellGroupValidator(m_cellGroup, m_config);
            ErrorLog errorLog = validator.Validate();
            if (errorLog.Count > 0)
            {
                errorLog.PrintTrace();
                return errorLog;
            }

            // Make sure that the foreign key constraints are not violated
            if (m_config.IsValidationEnabled)
            {
                CheckForeignKeyConstraints(errorLog);
            }

            if (errorLog.Count > 0)
            {
                errorLog.PrintTrace();
                return errorLog; // If we have discovered errors here, do not generate query views
            }

            // For the S-side, we add NOT ... for each scalar constant so
            // that if we have C, P in the mapping but the store has C, P, S,
            // we can handle it in the query views
            m_updateDomainMap.ExpandDomainsToIncludeAllPossibleValues();
            
            foreach (Cell cell in m_cellGroup)
            {
                cell.SQuery.WhereClause.FixDomainMap(m_updateDomainMap);
            }

            errorLog = GenerateQueryViewForExtentAndType(m_entityContainerMapping, identifiers, views, entity, type, mode);

            return errorLog;
        }
Esempio n. 52
0
        private string ExportToFbx()
        {
            try
            {
                double building_width = 0;
                double building_length = 0;

                ElementCategoryFilter eleFilter;//the class varies from Autodesk.Revit.DB? y
                FilteredElementCollector collector;//the class varies from Autodesk.Revit.DB? y
                IList<Element> filteredObject;// the interface of System.Collections.Generic? y where did it state it is the interface? in .net lib
                string semanticInfo = "";//store all semantic information
                string commentParameter = "";//store the comment parameter in left column revit

                //get ground objects
				//read semantic information from revit file
				
				//for floor
                eleFilter = new ElementCategoryFilter(BuiltInCategory.OST_Floors);// get all floor objects in revit project
                collector = new FilteredElementCollector(uidoc.Document);//the same way to get objects in revit
                filteredObject = collector.WherePasses(eleFilter).WhereElementIsNotElementType().ToElements();// the same way to get objects in revit
                //we create filter instance and all objects instance. then we pass filter into all objects to get filteredbojects.
                foreach (Element e in filteredObject)//go throught each item/objects in revit model
                {
                    commentParameter = GetParameterInformation(e.Parameters, uidoc.Document, "Comments");
                    string level = GetParameterInformation(e.Parameters, uidoc.Document, "Level");

                    if (level.ToLower() == "level 0")
                    {
                        CalculateArea(e.Parameters, uidoc.Document, ref building_width, ref building_length);
                        if (building_width > 100 || building_length > 100)
                        {
                            TaskDialog.Show("Error", "W: " + building_width + ", L: " + building_length + ". Size is too big for our application.");
                            return "Size Error.";
                        }
                    }

                    if (commentParameter == "emergency")
                        semanticInfo += e.Id + "-emergency,"+level+"\n";// explain this please. put id and emergency into the whole semantic information list with different line.
                    else
                        semanticInfo += e.Id + "-ground," + level + "\n";
                }

				//for stairs
                eleFilter = new ElementCategoryFilter(BuiltInCategory.OST_Stairs);
                collector = new FilteredElementCollector(uidoc.Document);
                filteredObject = collector.WherePasses(eleFilter).WhereElementIsNotElementType().ToElements();
                foreach (Element e in filteredObject)
                {
                    semanticInfo += e.Id + "-stair\n";
                }

                //get obstacle objects///for walls
                eleFilter = new ElementCategoryFilter(BuiltInCategory.OST_Walls);//I get all walls
                collector = new FilteredElementCollector(uidoc.Document);
                filteredObject = collector.WherePasses(eleFilter).WhereElementIsNotElementType().ToElements();
                foreach (Element e in filteredObject)//I loop each wall. I want to check the COMMENT property of each wall
                {
                    /*//this block is used to get Comment property in revit
                    commentParameter = "";//this parameter store Comment property value
                    foreach (Parameter para in e.Parameters)//loop each property
                    {
                        try
                        {
                            commentParameter = GetParameterInformation(para, uidoc.Document).ToLower();
                            if (commentParameter == "wood")
                                break;
                        }
                        catch (Exception ex)
                        {
                            //cannot get info, we know it and we don't need to write it
                      
                        }
                    }

                    //if it is wood, we set wood to the semantic file, otherwise it is obstable (brick)
                    if (commentParameter == "wood")
                        semanticInfo += e.Id + "-wood\n";
                    //else if (status == "somethingelse")
                    //content += e.Id + "-somethingelse\n";
                    else*/
                        
                    semanticInfo += e.Id + "-obstacle\n";
                }
			
				//for doors
                eleFilter = new ElementCategoryFilter(BuiltInCategory.OST_Doors);
                collector = new FilteredElementCollector(uidoc.Document);
                filteredObject = collector.WherePasses(eleFilter).WhereElementIsNotElementType().ToElements();
                foreach (Element e in filteredObject)
                {
                    commentParameter = GetParameterInformation(e.Parameters, uidoc.Document, "Comments");

                    if (commentParameter == "closed")
                        semanticInfo += e.Id + "-obstacle\n";
                    else if (commentParameter == "opened")
                        semanticInfo += e.Id + "-openeddoor\n";
                    else
                        semanticInfo += e.Id + "-openeddoor\n"; // else mean the default status??? yes
                    SetParameter(e.Parameters, "Comments", "test");
                }



                string path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);


                CreateTempFolder(path + "\\revitfbx\\");
                //output
                //System.IO.Directory.CreateDirectory("revitfbx");
                System.IO.File.Delete(path + "\\revitfbx\\building.fbx");
                System.IO.File.Delete(path + "\\revitfbx\\semantic.txt");
				
				//we write new fbx
				////////////////////////////
                ViewSet views = new ViewSet();
                views.Insert(uidoc.ActiveView);
                FBXExportOptions exportoption = new FBXExportOptions();
                //here, revit forces us to use a folder. I forgot that. so we have to use a folder.
                uidoc.Document.Export(path + "\\revitfbx", "building.fbx", views, exportoption);//generate fbx file
				/////////////////////////////
				
				//we write new semantic
                Utility.WriteFile(path + "\\revitfbx\\semantic.txt", semanticInfo, false);

				
				//send semantic and 3d fbx model to PHP server
                
                NameValueCollection paras = new NameValueCollection();
                paras.Add("sid", selectedSid);
                paras.Add("act", "ClientSendModelFile");
                string web = client.UploadFileEx(path + "\\revitfbx\\building.fbx", AppConst.SERVER_DOMAIN + AppConst.SERVER_PATH, "building", null, paras);

                if (web.Trim() != "")
                    return "Unknown error";

                paras = new NameValueCollection();
                paras.Add("sid", selectedSid);
                paras.Add("act", "ClientSendSemanticFile");
                client.UploadFileEx(path + "\\revitfbx\\semantic.txt", AppConst.SERVER_DOMAIN + AppConst.SERVER_PATH, "semantic", null, paras);

                return "done";
            }
			///////////////////////////
            catch (Exception ex)
            {
                TaskDialog.Show("Error", ex.Message);
                return ex.Message;
            }
        }
Esempio n. 53
0
        /// <summary>
        /// Initialize the variables
        /// </summary>
        private void Initialize()
        {
            //ColorMode
            m_colorMode = new List<String>();
            m_enumColorMode = new List<Autodesk.Revit.DB.ImportColorMode>();
            m_colorMode.Add("Black and white");
            m_enumColorMode.Add(Autodesk.Revit.DB.ImportColorMode.BlackAndWhite);
            m_colorMode.Add("Preserve colors");
            m_enumColorMode.Add(Autodesk.Revit.DB.ImportColorMode.Preserved);
            m_colorMode.Add("Invert colors");
            m_enumColorMode.Add(Autodesk.Revit.DB.ImportColorMode.Inverted);

            //Placement
            m_placement = new List<String>();
            m_enumPlacement = new List<Autodesk.Revit.DB.ImportPlacement>();
            m_placement.Add("Center-to-center");
            m_enumPlacement.Add(Autodesk.Revit.DB.ImportPlacement.Centered);
            m_placement.Add("Origin-to-origin");
            m_enumPlacement.Add(Autodesk.Revit.DB.ImportPlacement.Origin);

            //Unit
            m_unit = new List<String>();
            m_enumUnit = new List<Autodesk.Revit.DB.ImportUnit>();
            m_unit.Add("Auto-Detect");
            m_enumUnit.Add(Autodesk.Revit.DB.ImportUnit.Default);
            m_unit.Add(Autodesk.Revit.DB.ImportUnit.Foot.ToString());
            m_enumUnit.Add(Autodesk.Revit.DB.ImportUnit.Foot);
            m_unit.Add(Autodesk.Revit.DB.ImportUnit.Inch.ToString());
            m_enumUnit.Add(Autodesk.Revit.DB.ImportUnit.Inch);
            m_unit.Add(Autodesk.Revit.DB.ImportUnit.Meter.ToString());
            m_enumUnit.Add(Autodesk.Revit.DB.ImportUnit.Meter);
            m_unit.Add(Autodesk.Revit.DB.ImportUnit.Decimeter.ToString());
            m_enumUnit.Add(Autodesk.Revit.DB.ImportUnit.Decimeter);
            m_unit.Add(Autodesk.Revit.DB.ImportUnit.Centimeter.ToString());
            m_enumUnit.Add(Autodesk.Revit.DB.ImportUnit.Centimeter);
            m_unit.Add(Autodesk.Revit.DB.ImportUnit.Millimeter.ToString());
            m_enumUnit.Add(Autodesk.Revit.DB.ImportUnit.Millimeter);
            m_unit.Add("Custom");
            m_enumUnit.Add(Autodesk.Revit.DB.ImportUnit.Default);

            //VisibleLayersOnly
            m_visibleLayersOnly = new List<String>();
            m_enumVisibleLayersOnly = new List<bool>();
            m_visibleLayersOnly.Add("All");
            m_enumVisibleLayersOnly.Add(false);
            m_visibleLayersOnly.Add("Visible");
            m_enumVisibleLayersOnly.Add(true);

            //Whether active view is 3D
            m_is3DView = false;
            if (m_activeDoc.ActiveView.ViewType == Autodesk.Revit.DB.ViewType.ThreeD)
            {
                m_is3DView = true;
            }

            //Views
            m_views = new ViewSet();
            GetViews();

            m_importCustomScale = 0.0;
            m_importOrientToView = true;
            m_importUnit = Autodesk.Revit.DB.ImportUnit.Default;
            m_importThisViewOnly = false;
            m_importView = m_activeDoc.ActiveView;
            m_importColorMode = Autodesk.Revit.DB.ImportColorMode.Inverted;
            m_importPlacement = Autodesk.Revit.DB.ImportPlacement.Centered;
            m_importVisibleLayersOnly = false;

            m_filter = "DWG Files (*.dwg)|*.dwg";
            m_title = "Import DWG";
        }
Esempio n. 54
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;

            ElementId eId = new ElementId(-2003100);

            //Collect Schedules from active document
            foreach (ViewSchedule vSched in new FilteredElementCollector(doc)
                .OfClass(typeof(ViewSchedule))
                .Cast<ViewSchedule>()
                .Where(q => !q.IsTitleblockRevisionSchedule && !q.IsInternalKeynoteSchedule))
            {
                if (vSched.Definition.CategoryId == eId)
                {
                    nameSchedule.Add(vSched.Name);
                }

            }

            //Instantiate Form
            MainWindow mWindow = new MainWindow();
            mWindow.ShowDialog();
            //Error handling
            if(dialogResult == false)
            {
                GarbageCollect();
                return Result.Failed;
            }
            if(MainWindow.selectedName == null)
            {
                TaskDialog.Show("Error", "No schedule was selected!");
                GarbageCollect();
                return Result.Failed;
            }

            //get ElementId of selected schedule
            var viewId = doc.ActiveView.Id;
            foreach (ViewSchedule vSched2 in new FilteredElementCollector(doc)
                .OfClass(typeof(ViewSchedule))
                .Cast<ViewSchedule>()
                .Where(q => !q.IsTitleblockRevisionSchedule && !q.IsInternalKeynoteSchedule))
            {
                if (vSched2.Name == MainWindow.selectedName)
                {
                    viewId = vSched2.Id;
                }
            }

            //Get sheets from selected schedule, catch error for invalid schedules
            ViewSet vs = new ViewSet();
            try
            {
                foreach (ViewSheet vSh in new FilteredElementCollector(doc, viewId))
                {
                    //Ignore dummy sheets
                    if(vSh.CanBePrinted == true)
                    {
                        vs.Insert(vSh);
                    }

                }
            }
            catch (System.InvalidCastException)
            {
                TaskDialog.Show("Error","Cannot use '" + MainWindow.selectedName + "'" + Environment.NewLine + "'" + MainWindow.selectedName + "' is not a sheet index.");
                GarbageCollect();
                return Result.Failed;
            }

            // Save ViewSet with sheets from selected schedule using provided name
            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("SaveSet");

                PrintManager printManager = doc.PrintManager;
                printManager.PrintRange = PrintRange.Select;
                ViewSheetSetting viewSheetSetting = printManager.ViewSheetSetting;
                viewSheetSetting.CurrentViewSheetSet.Views = vs;

                try
                {
                    viewSheetSetting.SaveAs(MainWindow.setName);
                }
                catch (Autodesk.Revit.Exceptions.InvalidOperationException)
                {
                    TaskDialog.Show("Error", "The name '" + MainWindow.setName + "' is already in use!" + Environment.NewLine + "Pick a different name.");
                    GarbageCollect();
                    return Result.Failed;
                }

                tx.Commit();
            }
            TaskDialog.Show("View Set", vs.Size + " sheets added to '" + MainWindow.setName + "'");
            GarbageCollect();
            return Result.Succeeded;
        }
Esempio n. 55
0
        // requires: schema refers to C-side or S-side schema for the cells
        // inside this. if schema.IsQueryView is true, the left side of cells refers
        // to the C side (and vice-versa for the right side)
        // effects: Generates the relevant views for the schema side and
        // returns them. If allowMissingAttributes is true and attributes
        // are missing on the schema side, substitutes them with NULL
        // Modifies views to contain the generated views for different
        // extents specified by cells and the the schemaContext
        private ErrorLog GenerateDirectionalViews(ViewTarget viewTarget, CqlIdentifiers identifiers, ViewSet views)
        {
            bool isQueryView = viewTarget == ViewTarget.QueryView;

            // Partition cells by extent.
            KeyToListMap<EntitySetBase, Cell> extentCellMap = GroupCellsByExtent(m_cellGroup, viewTarget);

            // Keep track of the mapping exceptions that we have generated
            ErrorLog errorLog = new ErrorLog();

            // Generate views for each extent
            foreach (EntitySetBase extent in extentCellMap.Keys)
            {
                if (m_config.IsViewTracing)
                {
                    Helpers.StringTraceLine(String.Empty);
                    Helpers.StringTraceLine(String.Empty);
                    Helpers.FormatTraceLine("================= Generating {0} View for: {1} ===========================",
                                     isQueryView ? "Query" : "Update", extent.Name);
                    Helpers.StringTraceLine(String.Empty);
                    Helpers.StringTraceLine(String.Empty);
                }
                try
                {
                    // (1) view generation (checks that extents are fully mapped)
                    QueryRewriter queryRewriter = GenerateDirectionalViewsForExtent(viewTarget, extent, identifiers, views);

                    // (2) validation for update views
                    if (viewTarget == ViewTarget.UpdateView &&
                        m_config.IsValidationEnabled)
                    {
                        if (m_config.IsViewTracing)
                        {
                            Helpers.StringTraceLine(String.Empty);
                            Helpers.StringTraceLine(String.Empty);
                            Helpers.FormatTraceLine("----------------- Validation for generated update view for: {0} -----------------",
                                             extent.Name);
                            Helpers.StringTraceLine(String.Empty);
                            Helpers.StringTraceLine(String.Empty);
                        }

                        RewritingValidator validator = new RewritingValidator(queryRewriter.ViewgenContext, queryRewriter.BasicView);
                        validator.Validate();
                    }

                }
                catch (InternalMappingException exception)
                {
                    // All exceptions have mapping errors in them
                    Debug.Assert(exception.ErrorLog.Count > 0,
                                 "Incorrectly created mapping exception");
                    errorLog.Merge(exception.ErrorLog);
                }
            }
            return errorLog;
        }
        /// <summary>
        /// Collect the parameters and export
        /// </summary>
        /// <returns></returns>
        public override bool Export()
        {
            base.Export();

             bool exported = false;

             //parameter : ViewSet views
             ViewSet views = new ViewSet();
             if (m_currentViewOnly)
             {
            views.Insert(m_activeDoc.ActiveView);
             }
             else
             {
            views = m_selectViewsData.SelectedViews;
             }

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

             //parameter : DXFExportOptions dxfExportOptions
             SATExportOptions satExportOptions = new SATExportOptions();

             //Export
             exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, viewIds, satExportOptions);

             return exported;
        }
Esempio n. 57
0
        // effects: Generates views for the particular cellgroup in this. Returns an
        // error log describing the errors that were encountered (if none
        // were encountered, the ErrorLog.Count is 0). Places the generated
        // views in result
        internal ErrorLog GenerateAllBidirectionalViews(ViewSet views, CqlIdentifiers identifiers)
        {

            // Allow missing attributes for now to make entity splitting run through
            // we cannot do this for query views in general: need to obtain the exact enumerated domain

            if (m_config.IsNormalTracing)
            {
                StringBuilder builder = new StringBuilder();
                Cell.CellsToBuilder(builder, m_cellGroup);
                Helpers.StringTraceLine(builder.ToString());
            }

            m_config.SetTimeForFinishedActivity(PerfType.CellCreation);
            // Check if the cellgroup is consistent and all known S constraints are
            // satisified by the known C constraints
            CellGroupValidator validator = new CellGroupValidator(m_cellGroup, m_config);
            ErrorLog errorLog = validator.Validate();

            if (errorLog.Count > 0)
            {
                errorLog.PrintTrace();
                return errorLog;
            }

            m_config.SetTimeForFinishedActivity(PerfType.KeyConstraint);

            // We generate update views first since they perform the main
            // validation checks
            if (m_config.GenerateUpdateViews)
            {
                errorLog = GenerateDirectionalViews(ViewTarget.UpdateView, identifiers, views);
                if (errorLog.Count > 0)
                {
                    return errorLog; // If we have discovered errors here, do not generate query views
                }
            }

            // Make sure that the foreign key constraints are not violated
            if (m_config.IsValidationEnabled)
            {
                CheckForeignKeyConstraints(errorLog);
            }
            m_config.SetTimeForFinishedActivity(PerfType.ForeignConstraint);

            if (errorLog.Count > 0)
            {
                errorLog.PrintTrace();
                return errorLog; // If we have discovered errors here, do not generate query views
            }
            
            // Query views - do not allow missing attributes
            // For the S-side, we add NOT ... for each scalar constant so
            // that if we have C, P in the mapping but the store has C, P, S,
            // we can handle it in the query views
            m_updateDomainMap.ExpandDomainsToIncludeAllPossibleValues();

            errorLog = GenerateDirectionalViews(ViewTarget.QueryView, identifiers, views);

            return errorLog;
        }
Esempio n. 58
0
        /// <summary>
        /// Collect the parameters and export
        /// </summary>
        /// <returns></returns>
        public override bool Export()
        {
            base.Export();

            bool exported = false;
            //parameter : ViewSet views
            ViewSet views = new ViewSet();
            if (m_currentViewOnly)
            {
                views.Insert(m_activeDoc.ActiveView);
            }
            else
            {
                views = m_selectViewsData.SelectedViews;
            }

            //parameter : DXFExportOptions dxfExportOptions

            SATExportOptions satExportOptions = new SATExportOptions();

            //Export
            exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, satExportOptions);

            return exported;
        }
Esempio n. 59
0
 /// <summary>
 /// Создать копию набора представлений
 /// </summary>
 public ViewSet Clone()
 {
     ViewSet viewSet = new ViewSet(Name, Directory);
     foreach (ViewInfo viewInfo in Items)
         viewSet.Items.Add(viewInfo.Clone());
     return viewSet;
 }