Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
here is my code:
[Transaction(TransactionMode.Manual)]
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)
.OfCategory(BuiltInCategory.OST_Doors);
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)
.WhereElementIsNotElementType()
.OfCategory(BuiltInCategory.INVALID)
.OfClass(typeof(Level));
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.
door.Activate();
doc.Regenerate();
}
// original door
FamilyInstance doorInstance = doc.Create.NewFamilyInstance(doorLocation, door, newWall, StructuralType.NonStructural);
FamilySymbol doorFamilySymbol = doorInstance.Symbol;
doorFamilySymbol.get_Parameter(BuiltInParameter.DOOR_WIDTH).Set(3.3);
// duplicate door
FamilySymbol duplicatedoorFamilySymbol = doorFamilySymbol.Duplicate("duplicated Door") as FamilySymbol;
if (!duplicatedoorFamilySymbol.IsActive)
{
// Ensure the family symbol is activated.
door.Activate();
doc.Regenerate();
}
FamilyInstance duplicateDoorInstance = doc.Create.NewFamilyInstance(duplicateDoorLocation, duplicatedoorFamilySymbol, newWall, firstLevel, StructuralType.NonStructural);
}
tx.Commit();
}
return Result.Succeeded;
}
}
Solved! Go to Solution.