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: 

Place repeating detail using the API

7 REPLIES 7
Reply
Message 1 of 8
clayton.binkley
1303 Views, 7 Replies

Place repeating detail using the API

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

 

 

7 REPLIES 7
Message 2 of 8
Joe.Ye
in reply to: clayton.binkley

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.

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Tags (1)
Message 3 of 8
Habib455
in reply to: Joe.Ye

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 🙂

Message 4 of 8
pranavamsankar
in reply to: Habib455

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?

Message 5 of 8

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

Message 6 of 8
kinjal
in reply to: pranavamsankar

Dear all,

 

Any updates in the meantime?

 

Best regards,

Kinjal.

Kinjal Desai
Fullstack developer @ Dwaravati
Delivering high quality programmatic boosts for your already beautiful Revit


Message 7 of 8
bixilix
in reply to: clayton.binkley

Are there any news on this topic? It has been five years 😄

Message 8 of 8

idea: Expose Repeated Detail Component to API


Lionel J. Camara
BIM Manager at KAI Hawaii, Inc. - Structural and Forensic Engineers
Autodesk Certified Professional

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community