InvalidOperation Exception

InvalidOperation Exception

Crashnorun
Participant Participant
990 Views
4 Replies
Message 1 of 5

InvalidOperation Exception

Crashnorun
Participant
Participant

Hi All,

 

I have a massing file with the 3D view open and active. The file has adaptive components in the file. I'm running into an error when I run the line of code below:

IList<Reference> Refs = P_UIDoc.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Element, " Select Objects");

 

The error I get is: Invalid Operation Exception. When I rotate the model in the 3D view and run the command again it works fine. I'm running Revit 2016, VS 2013

rvt_Exceptions_01.jpg

0 Likes
991 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

Can you please provide a complete minimal reproducible case for this that I can pass on to the development team to analyse and hopefully resolve?

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 5

arnostlobel
Alumni
Alumni

I believe the exception message explains it rather well: "The active view is non-graphical and does not support capture of the focus for pick operation".

 

What is means is essentially: The currently active view in Revit is not the one from which the selection was taken. It is probably project browser view, or even your dockable dialog if that is where you call the API from. IN order for picking to work, the current active view must be a graphical view, e.g. a floor-plan, section, elevation, etc. You should be able to select a graphical active view before you invoke a picking action using the ActiveView property of the UIDocument class. Or at least you need to check whether the ActiveView is graphical or not, and do not continue with picking if it is not.

Arnošt Löbel
0 Likes
Message 4 of 5

Crashnorun
Participant
Participant

Hi Jeremy,

 

Thanks for getting back to me. I've attached a zip file with the family document in quesiton. the default 3D view is the view I was using. I've also attached a visual studio 2013 project file with the line of code that prodcues the error. 

 

When I run the code in the current view I get the error. When I rotate the 3D view (even just slightly) the code doesn't error. 

 

Best,

0 Likes
Message 5 of 5

jeremytammik
Autodesk
Autodesk

Dear Crashnorun,

 

I compiled and tested your sample code and family.

 

You need to specify your own add-in identifier GUID in the add-in manifest!

 

The one you provided has a conflict with some other one I am using, so I had to change it.

 

I cannot reproduce the problem.

 

I am using

 

  • Microsoft Visual Studio Premium 2012 Version 11.0.61030.00 Update 4
  • Microsoft .NET Framework Version 4.5.50938
  • Revit 16.0.490.0 20150714_1515(x64) Service Pack 2.

 

The selection wiorks just fine for me, just start up Revit in the debugger, pick some of the faces, click finish, and all is well.

 

Maybe a VS 2013 problem?

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes