예제 #1
0
        public void DuplicateViewOntoSheet(
            SheetCopierView view,
            SheetCopierViewHost sheet,
            XYZ sourceViewCentre)
        {
            var destViewId = DuplicateView(view);

            if (Settings.Default.DeleteRevisionClouds)
            {
                DeleteRevisionClouds(destViewId, doc);
            }

            var elem = doc.GetElement(destViewId);

            if (elem == null)
            {
                return;
            }
            var v = elem as View;

            string newName = sheet.GetNewViewName(view.OldView.Id);

            if (newName != null)
            {
                v.Name = newName;
            }
            else
            {
                SCaddinsApp.WindowManager.ShowMessageBox("ERROR", "New view name could not be set to: " + newName);
            }

            TryAssignViewTemplate(v, view.ViewTemplateName, view.OldView.ViewTemplateId);

            PlaceViewPortOnSheet(sheet.DestinationSheet, destViewId, sourceViewCentre);
        }
예제 #2
0
        /// <summary>
        /// Place a newly created view on a sheet.
        /// User this when copying a sheet AND assigning a new associated level.
        /// </summary>
        public void PlaceNewViewOnSheet(
            SheetCopierView view,
            SheetCopierViewHost sheet,
            XYZ sourceViewCentre)
        {
            Level level = null;

            try
            {
                Levels.TryGetValue(view.AssociatedLevelName, out level);
            }
            catch
            {
                SCaddinsApp.WindowManager.ShowErrorMessageBox("Error", "level not found");
                return;
            }

            if (level != null)
            {
                var floorPlanViewFamilyTypeId = GetFloorPlanViewFamilyTypeId(Doc, view.OldView.ViewType);
                if (Autodesk.Revit.DB.ElementId.InvalidElementId == floorPlanViewFamilyTypeId)
                {
                    SCaddinsApp.WindowManager.ShowErrorMessageBox("Error getting viewtype", "Error getting viewtype");
                    return;
                }

                using (ViewPlan vp = ViewPlan.Create(doc, floorPlanViewFamilyTypeId, level.Id))
                {
                    try
                    {
                        vp.CropBox        = view.OldView.CropBox;
                        vp.CropBoxActive  = view.OldView.CropBoxActive;
                        vp.CropBoxVisible = view.OldView.CropBoxVisible;
                        vp.Name           = view.Title;
                        var oldAnno = view.OldView.AreAnnotationCategoriesHidden;
                        vp.AreAnnotationCategoriesHidden = true;
                        TryAssignViewTemplate(vp, view.ViewTemplateName, view.OldView.ViewTemplateId);
                        PlaceViewPortOnSheet(sheet.DestinationSheet, vp.Id, sourceViewCentre);
                        vp.AreAnnotationCategoriesHidden = oldAnno;
                    }
                    catch (Exception ex)
                    {
                        SCaddinsApp.WindowManager.ShowErrorMessageBox("Error in PlaceNewViewOnSheet", ex.Message);
                    }
                }
            }
            else
            {
                SCaddinsApp.WindowManager.ShowErrorMessageBox("Error", "level not found");
            }
        }
예제 #3
0
        public ElementId DuplicateView(SheetCopierView view)
        {
            var d = view.DuplicateWithDetailing ? ViewDuplicateOption.WithDetailing : ViewDuplicateOption.Duplicate;

            ElementId destViewId = ElementId.InvalidElementId;

            if (view.OldView.CanViewBeDuplicated(d))
            {
                try
                {
                    destViewId = view.OldView.Duplicate(d);
                }
                catch (Autodesk.Revit.Exceptions.ArgumentOutOfRangeException arx)
                {
                    SCaddinsApp.WindowManager.ShowMessageBox(arx.Message);
                    return(ElementId.InvalidElementId);
                }
                catch (Autodesk.Revit.Exceptions.InvalidOperationException iox)
                {
                    SCaddinsApp.WindowManager.ShowMessageBox(iox.Message);
                    return(ElementId.InvalidElementId);
                }
            }
            else
            {
                SCaddinsApp.WindowManager.ShowMessageBox("WARNING: CanViewBeDuplicated is returning false for view: " + view.OldView.Name);
                return(ElementId.InvalidElementId);
            }

            if (destViewId == ElementId.InvalidElementId)
            {
                SCaddinsApp.WindowManager.ShowMessageBox("WARNING: could not create copy of view: " + view.OldView.Name);
                //// sometimes view.Duplicate seems to fail if the duplicate option is set to ViewDuplicateOption.WithDetailing
                //// try again with option set to ViewDuplicateOption.Duplicate
                if (d == ViewDuplicateOption.WithDetailing)
                {
                    SCaddinsApp.WindowManager.ShowMessageBox("Attempting to create view without detailing..." + view.OldView.Name);
                    view.DuplicateWithDetailing = false;
                    return(DuplicateView(view));
                }
            }
            return(destViewId);
        }