Create dimension between rebars in set

Create dimension between rebars in set

atir5UTNF
Advocate Advocate
1,075 Views
5 Replies
Message 1 of 6

Create dimension between rebars in set

atir5UTNF
Advocate
Advocate

I have rebars set and I need to create between all/selected of them.

The result I need:

atir5UTNF_0-1704009245610.png

 

What I have tried:

 

Method A - Use Reference to SubElements

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

List<Reference> rebarsInSetRef = rebar.GetSubelements().Where(s => s.Element is Rebar).Select(s =>s.GetReference()).Cast<Reference>().ToList();

 

but when I tried to use those references to create the dimension it throws an Exception:

"Invalid number of references".

 

 

Method B - Compute References for Geometry

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

Options options = new Options();
options.ComputeReferences = true;
options.IncludeNonVisibleObjects = true;
options.View= curView;
GeometryElement geometryElement = rebar.get_Geometry(options);

 

but geometryElement has only single line element.

 

 

Method C - Create reference to rebars

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

ReferenceArray referenceArray = new ReferenceArray();
List<Rebar> rebars = rebar.GetSubelements().Where(s => s.Element is Rebar).Select(s => s.Element as Rebar).ToList();
referenceArray.Append(new Reference(rebars[0]));
referenceArray.Append(new Reference(rebars[1]));

 

but when I tried to use those references to create the dimension it throws an Exception:

"The references are not geometric references".

0 Likes
1,076 Views
5 Replies
Replies (5)
Message 2 of 6

ctm_mka
Collaborator
Collaborator

@atir5UTNFSeems like Method A would be your best bet. First what is the count of references in rebarInSetRef? Are you getting 10 as your image shows? Last, please post your code for dimensioning in Method A.

0 Likes
Message 3 of 6

atir5UTNF
Advocate
Advocate

Hi,

 

rebarsInSetRef count is equal to rebar.Quantity...

I took 2 of those references, and still get the "Invalid number of references".

 

Method B seems to be the right way. I've been trying to use this for DAYS, but only got a single line. Suddenly yesterday, it worked out and I got a lot of curves. I don't know if Revit has automatic updates or something(I am using 2024.2.0) , or just a memory leak bug in Revit, But I noticed that all the recent projects on the Revit home screen were gone, so something happened.

I saw here in the forum other users who complained that they only get one line.

0 Likes
Message 4 of 6

ctm_mka
Collaborator
Collaborator

Interesting. Its very possible that patching up to 2024.2 fixed whatever was happening, pre that version 2024 has issues...so much we refused to use it, and are still very wary of it even after that patch. Glad to hear its working, please mark your solution as the solution for others to find.

0 Likes
Message 5 of 6

atir5UTNF
Advocate
Advocate

I'm still waiting for an official answer from an Autodesk employee.

I want to know how they do it when user create dimension in the UI.
Is it normal that I can't use sub-elements references? What are they used for?

 

0 Likes
Message 6 of 6

duytan59nuce
Observer
Observer

Tôi cũng đang gặp vấn đề tương tự, hy vọng khi có kết quả bạn có thể chia sẻ để mọi người cùng biết! 
Trân trọng cảm ơn

 

0 Likes