Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Duplicate View With Detailing Simply Duplicates View - Detailing Not Included

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
stewartcartmell
374 Views, 2 Replies

Duplicate View With Detailing Simply Duplicates View - Detailing Not Included

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

 

Labels (3)
2 REPLIES 2
Message 2 of 3

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

Message 3 of 3

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 😉

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community