Update a 2014 solution to 2016...cant solve the error

Update a 2014 solution to 2016...cant solve the error

Johan_Ekstrom
Enthusiast Enthusiast
634 Views
3 Replies
Message 1 of 4

Update a 2014 solution to 2016...cant solve the error

Johan_Ekstrom
Enthusiast
Enthusiast

Hey guys

 

A bit new to Revit API but i've got a working 2014-version which i am tryin to upgrade to 2016.

 

The updated parts are were the old code is changed to comment. Took a while to figure out the SelElementSet part... but when I update the two rows of code which are obsolete, I get a new error regarding the Insert. 

 

If i remove the new code and reset the old (In comment) the Insert part is fine but the SelElementSet is errored. 

 

How do i solve this...?

Any ideas, anythin obvious i am missing?

 

 



------------------------------------
Type x and y with every move in AutoCad and no one bats an eye...but use coordinates in Revit and everybody loses their mind.
0 Likes
Accepted solutions (1)
635 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Accepted solution

Hey! Do you want to Insert the Id of the Selected Element like this ?

 

ICollection<ElementId> selElements = uiDoc.Selection.GetElementIds();

                foreach (Room r in new FilteredElementCollector(_doc, _doc.ActiveView.Id).OfCategory(BuiltInCategory.OST_Rooms))
                {
                    try
                    {
                        if (str != "" && str2 == "" && str3 == "")
                        {
                            if (r.LookupParameter("Number").AsString().ToLower().Contains(str.ToLower()))
                            {
                                
                                    selElements.Add(r.Id);
                                
                            }
Message 3 of 4

Johan_Ekstrom
Enthusiast
Enthusiast

You are a genius!

 

I was picking in the Add-part instead of Insert but i didn't figure out the ID part. 

 

Thank you for your help, very kind of you. Now the application runs fine 🙂

 



------------------------------------
Type x and y with every move in AutoCad and no one bats an eye...but use coordinates in Revit and everybody loses their mind.
0 Likes
Message 4 of 4

rvtquestions
Advocate
Advocate

Hi @Johan_Ekstrom & @Anonymous

 

How would you edit the portion of code to work from:

 

Obtaining Element IDs:

 

 ICollection<ElementId> selElements = uiDoc.Selection.GetElementIds();

 

to prompting the user via rectangle?

uiDoc.Selection.PickElementsByRectangle

 

replacing the line with that results in an error. Any thoughts? Thank you!

 

0 Likes