Hilight object by elementid

Hilight object by elementid

Anonymous
Not applicable
411 Views
2 Replies
Message 1 of 3

Hilight object by elementid

Anonymous
Not applicable

HI,

I am writing a code for hilight all rebars with rebar number that  coincide with a texbox in  a form.

 

I am thinking to create a ilist and add the rebar with this line:

 

Dim ListSel As IList(Of ElementId) = Nothing

 

when i find a rebar with the correct number i add it to the list:

ListSel.Add(id_Pos)     

 

where id_pos is a variable as elementid

But I receive an exception on this point.

 

When I crete  the ilist, can I hilight all the objects in the list?

0 Likes
Accepted solutions (1)
412 Views
2 Replies
Replies (2)
Message 2 of 3

RPTHOMAS108
Mentor
Mentor
Accepted solution

You can't add items to a null reference.

 

IList is an interface (can only be obtained, not created) use instead List(Of ElementID) i.e. Dim ListSel As New List(Of ElementId)

 

Not sure what is meant by highlight but to select elements in the model (highlighting them) you can use:

 

uidoc.Selection.SetElementIds(ListSel)

 

There is an example of this in the RevitAPI.chm file under 'Selection Class'

0 Likes
Message 3 of 3

Anonymous
Not applicable

thank so much!!!

it was just what I was looking for!!

0 Likes