Dear all,
I need to set ActiveView in Idling event handler. As per API documentation, it isn't an invalid operation to set ActiveView (no open transactions; IsModifiable is ok; IsReadOnly is ok; No pre-action events around).
However, setting ActiveView throws InvalidOperationException (msg: "Setting active view is temporarily disabled").
Closest explanation i could reach to is Jeremy's casual comment ("The system may be busy with something else.") in one of his blog. In a sense that is the case - System is 'busy' because Idling event is being processed at the moment.
However, i wonder, if that is the real reason or a real limitation in this case; - for the system is also busy when IExternalCommand.Execute() is being processed (in which case setting ActiveView functions perfectly).
Looking forward to expert comments on whether Setting ActiveView is indeed invalid in Idling under any circumstances and if there is a way around it.
If I've missed any detail that might be of interest, please let me know.
Best regards,
Kinjal.
Solved! Go to Solution.
Solved by Revitalizer. Go to Solution.
Dear Kinjal,
Thank you for your very valid question.
Can you create a minimal reproducible case for me to pass on to the development team in order to discuss this?
http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b
That will enable them to see exactly how the InvalidOperationException is being triggered.
Otherwise, there is no guarantee that we are talking about the same thing.
Thank you!
Best regards,
Jeremy
As a workaround, would it be possible to select the view (using the API), then use postcommand to set the active view? Then wait for idling again....
Just a throwaway thought!
-Matt
Hi,
there is a UIDocument.RequestViewChange method made for the case you described.
Revitalizer
Hi Revitalizer,
Thank you for bringing this to light. It is async but that's clearly author's intended way; i'd fit my logic around it.
Imho, api reference can be more useful (and can save some hours and brain tissues) if such 'sister' functions can be linked in See Also or something.
@matthew_taylor: Thanks for your suggestion.
@jeremytammik: I was going to make minimal sample today, but looking at @Revitalizer 's answer i think it would be redundant. (Let me know if you think it is still worth escalating the case; i'd be happy to make a tidy sample)
Wish you all great weekend!
Best regards, Kinjal
Dear Kinjal,
Thank you for your update and appreciation.
I fully agree with your assessment. There is a lot of information out there, and sometimes it is really quite hard to find the optimal answer. I appreciate the invaluable support from people like Matt and Revitalizer with this!
That is why I am so busy working on the Revit API question answering system... or, preparing to work on it, I hope:
http://thebuildingcoder.typepad.com/blog/2017/01/family-category-and-two-energy-model-types.html#8
Yes, a tidy minimal sample would be hugely appreciated and might make a very nice blog post.
I am starting to wonder how best to capture the optimal answers for the question answering system, and, so far, I still believe the blog is probably the most reliable place to go for them.
Still, huge numbers of issues have never been mentioned there, and the answers are spread out all over the place in other blog, this discussion forum, the SDK samples, help files, developer guide, etc...
So, yes, please, very much looking forward to seeing your nice and tidy sample.
Thank you!
Best regards,
Jeremy
Dear Jeremy,
My pleasure. Please find attached sample (blank model with two floor plans) project file, containing the code (fairly simple and self explanatory) in document macro. I hope it is useful. Please let me know if anything is unclear.
QnA system: Glad to know. Looking forward to it, would be great in a long run. Let me know if any part of it is crowd-effort. I'd be happy to give a push.
Thanks your efforts and for always being there.
Best regards, Kinjal.
Dear Kinjal,
Thank you for your update, very nice appreciation and perfect sample file.
Yes, QnA looks interesting, seems to be very simple to use. Closed box, though.
I would still prefer something non-proprietary, open source.
Looking at TensorFlow at the moment...
Oh, now I understand. Your sample demonstrates the original issue, attempting to set the active view within the Idling event, and causing an exception to be thrown.
Have you also implemented the workaround suggested by Revitalizer?
Does that fulfil your need?
Maybe it is also simpler?
In any case, I obviously prefer to blog about things that work, solve problems, can be used by people.
Therefore, the workaround would probably make a nicer post.
I would obviously also include this very clean sample on how to reproduce the original problem as well.
Do you have the working, alternative, code?
Would you like to share that as well?
Thank you!
Best regards,
Jeremy
Hi Jeremy,
Yes i've implemented @Revitalizer's suggestion. Async call wasn't ideal for my specific need but i've refactored my code to accomodate it.
I thought you wanted a sample to reproduce the original issue - a misunderstanding. Anyhow i have updated the same sample to also demonstrate permissible/intended way to change active view from Idling. Hope this will do.
Reply:
Have you also implemented the workaround suggested by Revitalizer?
Yes.
Does that fulfil your need?
Yes.
Maybe it is also simpler?
Not in my case; maybe for other use-cases.
Do you have the working, alternative, code?
Now i am using RequestViewChange(). However, in absence of any answers my fallback alternative (far from ideal, but functional nonetheless), was to fire Ctrl+F4 Keystrokes (conditionally) from Idling event. As i said i am not fan of this approach but it would had served for my specific use-case.
RequestViewChange() is definitively the API authors' indented way to do it.
In any case, I obviously prefer to blog about things that work, solve problems, can be used by people.
Yes i totally agree.
TensorFlow
Sounds exciting. Looking forward to see what you come-up with. I am not a Python guy, but definitely a machine learning enthusiast.
Thanks and best regards,
Kinjal.
Dear Kinjal,
Thank you for your update, and addition of the working solution to the sample file.
That is a very nice demo sample indeed. It leaves no questions open.
I summarised our discussion and presented your solution on the blog for improved readability and future reference:
http://thebuildingcoder.typepad.com/blog/2017/02/setting-active-view-during-idling.html
Thank you!
Best regards,
Jeremy
Can't find what you're looking for? Ask the community or share your knowledge.