Change order in List<Rebar> rebars

Change order in List<Rebar> rebars

dawid.deptula
Contributor Contributor
339 Views
1 Reply
Message 1 of 2

Change order in List<Rebar> rebars

dawid.deptula
Contributor
Contributor

Do you know how to order rebars in list by Bar Length parameter. I try sth like this:

 rebars = rebars.OrderBy(rebar => rebar.LookupParameter("Bar Length").AsDouble()) as List<Rebar>;

 

but it doesn't work. I have rebars count = 0.

0 Likes
Accepted solutions (1)
340 Views
1 Reply
Reply (1)
Message 2 of 2

sahin.ikbal
Advocate
Advocate
Accepted solution

Are there rebars in the first place before ordering?
Instead of 

 rebars = rebars.OrderBy(rebar => rebar.LookupParameter("Bar Length").AsDouble()) as List<Rebar>;

try with

rebars = rebars.OrderBy(rebar => rebar.LookupParameter("Bar Length").AsDouble()).ToList();

0 Likes