Hi, I am trying to figure out how to place a repeating detail in a model using the API.
I have the Repeating Detail component defined already in my document, so I assume that it is just a matter of finding the right Family Symbol for my repeating component and treating as a line detail component using something like doc.Create.NewFamilyInstance(Line,Family Symbol,View)
but I can't quite figure out how to get it to work.
Any advice would be much apprecieated.
Thanks,
Clayton
Hi Clayton,
If you know the family symbol, it is just as you said, call NewFamilyInstance to generate the family instance.
The code should like: (Note, I didn't add the code to find the target family symbol)
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
public class CreateRepeatDetail : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
try
{
UIApplication app = commandData.Application;
Document doc = app.ActiveUIDocument.Document;
Transaction trans = new Transaction(doc);
trans.Start();
//find the symbol.
FamilySymbol symbol = null;
// fine the family symbol here.
// create the line
Line line = app.Application.Create.NewLineBound(new XYZ(0, 0, 0), new XYZ(20, 0, 0));
//Create the instance.
FamilyInstance instance = doc.Create.NewFamilyInstance(line, symbol, doc.ActiveView);
trans.Commit();
return Result.Succeeded;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return Result.Failed;
}
}
}
Note: For simplicity, I use doc.ActiveView to get a view. This requires your active view is not a 3D view.
Hope this helps.
If this still cannot make you through, please upload your family, i will finish the command.
Hi Joe,
The Method NewFamilyInstance(line, symbol, doc.ActiveView) create a new family instance. The repeating detail is a system family (DetailLine). Therefore this code does not help by Place repeating detail.
I don't know but I think we have to use something like NewDetailCurve (_doc.ActiveView, line) and after that we have to find ElementTyp than ParameterMap than we have to change the Value of parameter and give it the symbol.
Unfortunately I can't do that with the code. Please help me if you can 🙂
Hi I am also stuck with the same issue, i am not able to find a suitable method to place repeating detail.
Has anybody found a solution for this?
It seems that there is no easy way to place an element using the api. But we can easily copy the repeating detail using CopyElements from one view to the next.
My suggestion: Create a repeating detail element manually and keep it some where in document. Use that to create new ones.
Use the following api or overloaded versions of it
ElementTransformUtils.CopyElements(refLegendView, list, newView, null, null);
idea: Expose Repeated Detail Component to API