An Example for using MultiReferenceAnnotation?

An Example for using MultiReferenceAnnotation?

Anonymous
Not applicable
3,419 Views
9 Replies
Message 1 of 10

An Example for using MultiReferenceAnnotation?

Anonymous
Not applicable

Hello
Is it possible to get an example to create a Multi-rebar annotations, I search on the Revit SDK and found I have to use the MultiReferenceAnnotation class.

But I can't build an example with the current information.


For creating A normal Rebar Tag I'm using the Autodesk.Revit.Creation.Document.Create.NewTag method

I notice the independent tag has a property named MultiReferenceAnnotationId.

 

I'm using VS2012 c#, Revit 2014 and Windows 8 64bits


Thanks

0 Likes
Accepted solutions (1)
3,420 Views
9 Replies
Replies (9)
Message 2 of 10

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear miguel.alanis,

 

Please note the MultiReferenceAnnotation.Create method taking a MultiReferenceAnnotationOptions argument.

 

The minimum options are probably the type and ElementsToDimension.

 

Here is an excerpt from an internal test suite I received from the development team:

 

  var view = GetElement<View>(124186);
  var rebarList = GetElements<Element>(RevitDoc, new[] { 280427 }).ToList();
  Assert.IsTrue(rebarList.Count > 0, "There are no rebars in the document!");
  IList<ElementId> elementIds = new List<ElementId>();
  foreach (Element rebar in rebarList)
  {
    elementIds.Add(rebar.Id);
  }
  MultiReferenceAnnotationType type = GetElement<MultiReferenceAnnotationType>(RevitDoc, 260544);
  Assert.IsNotNull(type, "the MultiReferenceAnnotationType does not exist!");
  MultiReferenceAnnotationOptions options = new MultiReferenceAnnotationOptions(type);
  options.TagHeadPosition = new XYZ(0, 100, 0);
  options.DimensionLineOrigin = new XYZ(5, 5, 1);
  options.DimensionLineDirection = new XYZ(0, 1, 0);
  options.DimensionPlaneNormal = view.ViewDirection;
  options.SetElementsToDimension(elementIds);
  using (Transaction tran = new Transaction(RevitDoc, "Create_Rebar_Vertical"))
  {
    tran.Start();
    var mra = MultiReferenceAnnotation.Create(RevitDoc, view.Id, options);
    var dimension = GetElement<Dimension>(RevitDoc, mra.DimensionId);
    tran.Commit();
  }

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 10

Anonymous
Not applicable

Dear Jeremy,

Thanks for the answer

 

Best Regards

Miguel Angel Alanis

0 Likes
Message 4 of 10

jeremytammik
Autodesk
Autodesk

Dear Miguel Angel,

 

Thank you for your response. I put it on The Building Coder as well to ensure it is easily found:

 

http://thebuildingcoder.typepad.com/blog/2013/09/multireferenceannotation-example.html

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 10

Maciej_Darmochwal
Explorer
Explorer

Hi,

I would like to refresh the topic because i cant found any information about option that i could manage orientation (vertical,horizontal) created tags. Is that possible?

0 Likes
Message 6 of 10

lukasz_koc2
Contributor
Contributor

Hi, 

if you haven't found the solution yet you can use this :

annotation = MultiReferenceAnnotation.Create(doc, view.Id, annotation_opt)
tag = doc.GetElement(annotation.TagId)
tag.TagOrientation = TagOrientation.Horizontal
 
I have one question too. Do you know why in the dimension line i have 2 additional references? The bars are bended but in this view they are shown as points( bend in above the section)
 

2020-04-09 10_29_35-Autodesk Revit 2019.2 - [Bellona testowy_lukasz.koc@wsp.com - Section_ Section 1.png

 
 
0 Likes
Message 7 of 10

jeremytammik
Autodesk
Autodesk

Dear Łukasz,

 

Thank you for your answer, and also for the new question, which I already answered (as far as I am able to) in the comment on The Building Coder:

 

https://thebuildingcoder.typepad.com/blog/2013/09/multireferenceannotation-example.html#comment-4867...

 

If you can determine the geometric location of the feature that each reference is associated with, you should be able to use that information to tell the two apart.

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 8 of 10

jamess166
Advocate
Advocate

As it is done to locate the location of the reinforcements to place the dimension.

 

I'm trying to understand how geometry works in views. I imagine it could work like this.

 

Options opp = new Options();
            opp.View = RevitTools.doc.ActiveView;
            GeometryElement geoEl = r.get_Geometry(opp);
            BoundingBoxXYZ box = geoEl.GetBoundingBox();

            //Creo lista de elementos
            List<ElementId> listIds = new List<ElementId>();
            listIds.Add(r.Id);
            
            //Opciones de Multirebar
            MultiReferenceAnnotationOptions opt = 
                new MultiReferenceAnnotationOptions(ViewTools.MultiRebar);

            opt.TagHasLeader = false;

            //Ubicaciones
            opt.TagHeadPosition = ?????;
            opt.DimensionLineOrigin = ?????;
            opt.DimensionLineDirection = ?????;
            opt.DimensionPlaneNormal = RevitTools.doc.ActiveView.ViewDirection;

            opt.SetElementsToDimension(listIds);

            MultiReferenceAnnotation.Create(RevitTools.doc, r.Id, opt);

 

The intention is that it works for any view and any type of presentation.

 

Rebars.JPG

Message 9 of 10

pedro_abril
Participant
Participant

Hello, I have a question with the above code.

How do you get a reference to the individual rebars elements within the rebar?

 

I have reviewed the messages indicated in the links and the API documentation (2022), but I have not found a way.

 

In the example code I need to know how to get the part with question marks:

 

 

 

public void RebarAnnotation(Document doc, View view, Rebar rebar){ 
  //  I already have it
  MultiReferenceAnnotationType type = getAnnoType();
  MultiReferenceAnnotationOptions options = getAnnoOptions(type);

  // I need the part with question marks
  IList<ElementId> elementIds = new List<ElementId>();
  foreach (Element rbr in ???) {
    elementIds.Add(rbr.Id);
  }
  options.SetElementsToDimension(elementIds);

  //  I already have it
  using (Transaction tran = new Transaction(doc)) {
    tran.Start("Rebar Annotation");
    MultiReferenceAnnotation.Create(doc, view.Id, options);
    tran.Commit();
  }
}

 

 

 

 

Thank you.

(I have edited to correct some errors in the code)

0 Likes
Message 10 of 10

pedro_abril
Participant
Participant

Hello,
Thanks to the help of the development team (thanks to Naveen Kumar T) I have solved the previous question.
I leave the solution for future reference in case it helps someone else:

public void RebarAnnotation(Document doc, View view, Rebar rebar){ 
  //  I already have it
  MultiReferenceAnnotationType type = getAnnoType();
  MultiReferenceAnnotationOptions options = getAnnoOptions(type);

  // With the reference to the set of bars it is enough.
  IList<ElementId> elementIds = new List<ElementId>();
  elementIds.Add(rebar.Id);

  options.SetElementsToDimension(elementIds);

  //  I already have it
  using (Transaction tran = new Transaction(doc)) {
    tran.Start("Rebar Annotation");
    MultiReferenceAnnotation.Create(doc, view.Id, options);
    tran.Commit();
  }
}

 

With the reference to the set of bars it is enough, it is not necessary to identify each individual bar.

 

0 Likes