Can I create MultiReferenceAnnotation in a viewplane?

Can I create MultiReferenceAnnotation in a viewplane?

Anonymous
Not applicable
812 Views
8 Replies
Message 1 of 9

Can I create MultiReferenceAnnotation in a viewplane?

Anonymous
Not applicable
I tried to create MultiReferenceAnnotation in a viewplane,but I failed. my code is bellow: FilteredElementCollector coll = new FilteredElementCollector(doc); MultiReferenceAnnotationType ty= coll.OfClass(typeof(MultiReferenceAnnotationType)).First() as MultiReferenceAnnotationType; MultiReferenceAnnotationOptions options = new MultiReferenceAnnotationOptions(ty); options.SetElementsToDimension(els); options.TagHeadPosition = new XYZ(0, 100, 0); options.DimensionLineOrigin = new XYZ(5, 5, 1); options.DimensionLineDirection = new XYZ(1, 0, 0); options.DimensionPlaneNormal = new XYZ(0, 0, 1); options.DimensionStyleType = DimensionStyleType.Linear; MultiReferenceAnnotation multi = MultiReferenceAnnotation.Create(doc, doc.ActiveView.Id, options); The error message is in the attacments. I wonder if it is possible to create MultiReferenceAnnotation in a viewplane with MultiReferenceAnnotation.Create().
0 Likes
813 Views
8 Replies
Replies (8)
Message 2 of 9

bhprest
Advocate
Advocate

The error seems to indicate that some of your references may not be perpendicular to the dimension line you are trying to create. There are a couple really simple things I would try:

 

First, the MultiReferenceAnnotation class has a few static methods that can be used to determine whether or not the elements can be annotated in this fashion: 

 

  • MultiReferenceAnnotation.AreElementsValidForMultiReferenceAnnotation();
  • MultiReferenceAnnotation.AreReferencesValidForLinearDimension();
  • MultiReferenceAnnotation.AreReferencesValidForLinearFixedDimension();
  • MultiReferenceAnnotation.IsLinearFixedDimensionDirectionValid();

Using these, you may be able to narrow the issue down further.

 

Second, I would create the simplest use case possible (3 rebar elements to annotate?) and see if the code still fails. If it doesn't, then the code works for simple solutions, and perhaps the elements you are annotating need to be filtered down more fully to take orientation into account. If it still fails, perhaps take a look at this Building Coder article: https://thebuildingcoder.typepad.com/blog/2013/09/multireferenceannotation-example.html

 

Good Luck!

 

0 Likes
Message 3 of 9

Anonymous
Not applicable

I test the same code in a ViewSection ,it can create MultiReferenceAnnotation successfuly. Maybe the API can't be used in viewplane.

0 Likes
Message 4 of 9

bhprest
Advocate
Advocate

I do not know. I suspect that it should be possible. Perhaps someone else here will have more information.

 

If you can provide a reproducible test case , I'd be happy to look at it further.

0 Likes
Message 5 of 9

Anonymous
Not applicable
The reproducible test case is in attachments.Thank you for looking at it further. You can test it in the view named "1526165-钢筋图"
0 Likes
Message 6 of 9

bhprest
Advocate
Advocate

Hi there!

 

It seems to me the issue has to do with the references that are returned from the selection of the rebar elements. However, I don't think it has to do with it being a ViewPlan specifically. I think it has to do with the rebar not being cut by the view (not being in section). However, since the UI supports this annotation regardless of whether the rebar is cut or not, I suspect that we just have to find the correct reference within the geometry of the rebar. 

 

I cannot spend more time on this at the moment, but I will explore this more over the weekend.

 

As a side note, it seems to me that the problem (and thus a solution) may be related to this issue:

https://thebuildingcoder.typepad.com/blog/2018/09/rebar-wall-centreline-core-and-grid-dimensioning.h...

 

Good luck! I'll circle back after I've explored some more.

 

 

0 Likes
Message 7 of 9

Anonymous
Not applicable

Thanks a lot.

I can get the the correct reference within the geometry of the rebar ,but he MultiReferenceAnnotationOptions.SetElementsToDimension Method only SetElementsToDimension( ICollection<ElementId> elementsToDimension ), we cannot pass list<Reference> into it.

 
0 Likes
Message 8 of 9

Anonymous
Not applicable

help!help!I'm waiting a help.

0 Likes
Message 9 of 9

bhprest
Advocate
Advocate

Hi there!

 

I've figured out a few things, but I'm not sure they will be helpful to you. 

 

  1. It seems to me that your original intuition is correct: when in a ViewPlan, a MultiReferenceAnnotation cannot be used on a collection individual rebar elements.  In plan, the annotation can only be used if the rebar is part of a "Rebar Set", and the MultiReferenceAnnotation dimension is an "Aligned" type (not a "Linear" type).
  2. A "Rebar Set" is not a unique class, but rather just an instance of the Rebar class that has a Rebar.LayoutRule property equal to anything besides RebarLayoutRule.Single. (https://www.revitapidocs.com/2020/69eb7a49-7e5a-da45-6579-c91386888a7f.htm)

I very much hope that I am mistaken about item #1 above. It seems very odd to me that individual Rebar are able to be annotated with the MultiReferenceAnnotation in other view types, but not in plan view. However, this is consistent with the functionality of the UI.

 

So, from what I can tell, in order to do what you are trying to do the Rebar must be placed as a "Rebar Set" by the user. Only then can the MultiReferenceAnnotation be added while in plan view. 

 

If you continue to experiment further and find a working solution, please let me know: I am very curious as to how this is possible.

0 Likes