View cannot be duplicated

View cannot be duplicated

MiguelGT17
Advocate Advocate
286 Views
1 Reply
Message 1 of 2

View cannot be duplicated

MiguelGT17
Advocate
Advocate

Hi folks, as shown in picture, I can not duplicate a floorplan view with the code posted below:

MiguelGT17_0-1690408481938.png

 

            //get unitfloor plan
            ViewPlan unitFloorPlan = new FilteredElementCollector(doc).OfClass(typeof(ViewPlan))
             .Cast<ViewPlan>().FirstOrDefault(x=>x.Name.ToLower().Contains("unit floor plan"));
            
            //1) duplicate the unitFloorPlan
            ElementId duplicateUnFP = unitFloorPlan.Duplicate(ViewDuplicateOption.AsDependent);

            ViewPlan dupFloorPlan = doc.GetElement(duplicateUnFP) as ViewPlan;

            //2) REMOVE THE TEMPLATE VIEW
            dupFloorPlan.ViewTemplateId = ElementId.InvalidElementId;

 

This block of code have been working 100% for all the projects but somehow this is the first time I'm facing this issue: (It doesnt work with all three options: asDependent, etc..)

MiguelGT17_1-1690408571008.png

Any Idea about the subject?

MiguelGT17_2-1690408630973.png

 

Best regards,

Miguel G.

 

0 Likes
Accepted solutions (1)
287 Views
1 Reply
Reply (1)
Message 2 of 2

MiguelGT17
Advocate
Advocate
Accepted solution

Nevermind, some weird thing was going on. I deleted this unitfloorplan listed in the project browser and the plugin still found a view to duplicate. In the end, there were 2 floorplans with same name but not visible at all in the project browser!! crazy, I just collected their Ids and deleted them. This way I managed to run the plugin without inconvenients.

0 Likes