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

C# Revit API - Duplicate door not showing correctly.

Message 1 of 3
860 Views, 2 Replies

C# Revit API - Duplicate door not showing correctly.

Hi all, I'm trying to duplicate a door type and then place the new door type on a wall however, when it is placed, the door shows as if it is not hosted correctly and there is no break in the wall. The original door type shows up correctly.


I am using the .Duplicate() method to create a new type and then creating a new instance.


Does anyone know how I can resolve this? I haven't found anything online on how to resolve the issue yet.


image of what it looks like. Screen Shot 2020-09-16 at 7.44.43 PM.png

here is my code: 


    public class Command : IExternalCommand
        public Result Execute(
          ExternalCommandData commandData,
          ref string message,
          ElementSet elements)
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uidoc.Document;

            FilteredElementCollector colDoors = new FilteredElementCollector(doc)

            FamilySymbol door = colDoors.First() as FamilySymbol;

            // Build a location line for the wall creation
            XYZ start = new XYZ(-10, 0, 0);
            XYZ end = new XYZ(20, 0, 0);
            Line geomLine = Line.CreateBound(start, end);

            XYZ duplicateDoorLocation = new XYZ(-5, 0, 0);
            XYZ doorLocation = new XYZ(5, 0, 0);

            // grab levels in project
            FilteredElementCollector colLevels
                = new FilteredElementCollector(doc)

            Level firstLevel = colLevels.First() as Level;

            // Modify document within a transaction
            using (Transaction tx = new Transaction(doc))
                tx.Start("Transaction Name");

                if (firstLevel.ProjectElevation == 0)
                    // Create a wall using the location line
                    Wall newWall = Wall.Create(doc, geomLine, firstLevel.Id, true);

                    if (!door.IsActive)
                        // Ensure the family symbol is activated.

                    // original door
                    FamilyInstance doorInstance = doc.Create.NewFamilyInstance(doorLocation, door, newWall, StructuralType.NonStructural);
                    FamilySymbol doorFamilySymbol = doorInstance.Symbol;

                    // duplicate door
                    FamilySymbol duplicatedoorFamilySymbol = doorFamilySymbol.Duplicate("duplicated Door") as FamilySymbol;

                    if (!duplicatedoorFamilySymbol.IsActive)
                        // Ensure the family symbol is activated.
                    FamilyInstance duplicateDoorInstance = doc.Create.NewFamilyInstance(duplicateDoorLocation, duplicatedoorFamilySymbol, newWall, firstLevel, StructuralType.NonStructural);


            return Result.Succeeded;



Labels (2)
Message 2 of 3
in reply to: Maltezc

Hi @Maltezc ,

After creating the duplicate door instance,Use doc. Regenerate();

I think this will solve your issue.

Check out this below link 

Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
in reply to: naveen.kumar.t

that did it. thanks! 


I had to add in another filpface and doc.regenerate() for a total of 3. Its a bit odd. but it works.

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

Post to forums  

Autodesk Customer Advisory Groups

Rail Community