Duplicate View With Detailing Simply Duplicates View - Detailing Not Included

Duplicate View With Detailing Simply Duplicates View - Detailing Not Included

stewartcartmell
Participant Participant
1,227 Views
2 Replies
Message 1 of 3

Duplicate View With Detailing Simply Duplicates View - Detailing Not Included

stewartcartmell
Participant
Participant

Following along with this great sample found at revitapidocs (pasted below), I've changed out the "AsDependent" bits to "WithDetailing", the view Duplicates but does so without detailing. Strangely, line 7 in the code below returns -1 even though a new view is created and appears in the Revit UI. This leaves dependentView = null, so line 9 fails the check.

 

I also noticed the same behavior in pyRevit's Duplicate Selected Views tool and reported the bug on their github page.

 

I've checked this in Revit 2022 & 2023.

 

Here is the sample code. Again, I have changed "AsDependent" to "WithDetailing", otherwise my code is the same as below. The calling function sets up a Transaction. The Transaction succeeds and appears in the UI undo history:

public View CreateDependentCopy(View view)
{
    View dependentView = null;
    ElementId newViewId = ElementId.InvalidElementId;
    if (view.CanViewBeDuplicated(ViewDuplicateOption.AsDependent))
    {
        newViewId = view.Duplicate(ViewDuplicateOption.AsDependent);
        dependentView = view.Document.GetElement(newViewId) as View;
        if (null != dependentView)
        {
            if (dependentView.GetPrimaryViewId() == view.Id)
            {
                TaskDialog.Show("Dependent View", "Dependent view created successfully!");
            }
        }
    }

    return dependentView;
}

 

Accepted solutions (1)
1,228 Views
2 Replies
Replies (2)
Message 2 of 3

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @stewartcartmell ,

 

I tested the sample code at my end and everything is working fine on my end.

 

Could you please provide me the below details to reproduce the issue?

 

1)A simple non-confidential Revit file to reproduce the issue
2)Screenshots of expected result and observed result
3)A simple non-confidential sample code
4)Revit version details.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 3

stewartcartmell
Participant
Participant
Accepted solution

Hi Naveen,

 

So sorry, the strangest thing happened. When I started my PC this morning the duplication script worked without issue. I had restarted Revit, and then later the PC yesterday to see if that would help, and when it didn't I wrote the post. I must have been mistaken. Thanks for taking the time to check this for me, I did not mean to waste your time. In the future I'll give the PC an overnight rest to see if that helps again 😉

0 Likes