示例#1
0
        public void PlaceNewViewOnSheet(
            SheetCopierViewOnSheet view,
            SheetCopierSheet sheet,
            XYZ sourceViewCentre)
        {
            Level level = null;

            levels.TryGetValue(view.AssociatedLevelName, out level);
            if (level != null)
            {
                using (ViewPlan vp = ViewPlan.Create(doc, floorPlanViewFamilyTypeId, level.Id)) {
                    vp.CropBox        = view.OldView.CropBox;
                    vp.CropBoxActive  = view.OldView.CropBoxActive;
                    vp.CropBoxVisible = view.OldView.CropBoxVisible;
                    TryAssignViewTemplate(vp, view.ViewTemplateName);
                    PlaceViewPortOnSheet(sheet.DestinationSheet, vp.Id, sourceViewCentre);
                }
            }
            level.Dispose();
        }
示例#2
0
        public void DuplicateViewOntoSheet(
            SheetCopierViewOnSheet view,
            SheetCopierSheet sheet,
            XYZ sourceViewCentre)
        {
            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);
                } catch (Autodesk.Revit.Exceptions.InvalidOperationException iox) {
                    SCaddinsApp.WindowManager.ShowMessageBox(iox.Message);
                }
            }
            else
            {
                SCaddinsApp.WindowManager.ShowMessageBox("WARNING: CanViewBeDuplicated is returning false for view: " + view.OldView.Name);
                return;
            }

            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;
                    DuplicateViewOntoSheet(view, sheet, sourceViewCentre);
                }
                return;
            }

            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);

            PlaceViewPortOnSheet(sheet.DestinationSheet, destViewId, sourceViewCentre);
        }