• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Revit API

    Reply
    New Member
    Posts: 1
    Registered: 03-07-2008

    Place repeating detail using the API

    126 Views, 1 Replies
    01-31-2012 04:26 PM

    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

     

     

    Employee
    Posts: 22
    Registered: 03-05-2010

    Re: Place repeating detail using the API

    02-16-2012 12:39 AM 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

    Autodesk Developer Network