Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting ActiveView during Idling event

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
kinjal
3589 Views, 10 Replies

Setting ActiveView during Idling event

kinjal
Enthusiast
Enthusiast

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.

 

Kinjal Desai
Fullstack developer @ Dwaravati
Delivering high quality programmatic boosts for your already beautiful Revit


Setting ActiveView during Idling event

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.

 

Kinjal Desai
Fullstack developer @ Dwaravati
Delivering high quality programmatic boosts for your already beautiful Revit


10 REPLIES 10
Message 2 of 11
jeremytammik
in reply to: kinjal

jeremytammik
Autodesk
Autodesk

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



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

0 Likes

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



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

Message 3 of 11

matthew_taylor
Advisor
Advisor

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


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes

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


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 4 of 11
Revitalizer
in reply to: kinjal

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

there is a UIDocument.RequestViewChange method made for the case you described.

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Hi,

 

there is a UIDocument.RequestViewChange method made for the case you described.

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 11
kinjal
in reply to: Revitalizer

kinjal
Enthusiast
Enthusiast

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

 

Kinjal Desai
Fullstack developer @ Dwaravati
Delivering high quality programmatic boosts for your already beautiful Revit


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

 

Kinjal Desai
Fullstack developer @ Dwaravati
Delivering high quality programmatic boosts for your already beautiful Revit


Message 6 of 11
jeremytammik
in reply to: kinjal

jeremytammik
Autodesk
Autodesk

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



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

0 Likes

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



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

Message 7 of 11
kinjal
in reply to: jeremytammik

kinjal
Enthusiast
Enthusiast

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.

Kinjal Desai
Fullstack developer @ Dwaravati
Delivering high quality programmatic boosts for your already beautiful Revit


0 Likes

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.

Kinjal Desai
Fullstack developer @ Dwaravati
Delivering high quality programmatic boosts for your already beautiful Revit


Message 8 of 11
jeremytammik
in reply to: kinjal

jeremytammik
Autodesk
Autodesk

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



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

0 Likes

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



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

Message 9 of 11
kinjal
in reply to: jeremytammik

kinjal
Enthusiast
Enthusiast

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.

Kinjal Desai
Fullstack developer @ Dwaravati
Delivering high quality programmatic boosts for your already beautiful Revit


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.

Kinjal Desai
Fullstack developer @ Dwaravati
Delivering high quality programmatic boosts for your already beautiful Revit


Message 10 of 11
jeremytammik
in reply to: kinjal

jeremytammik
Autodesk
Autodesk

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



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

0 Likes

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



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

Message 11 of 11
onurerMY3Q8
in reply to: kinjal

onurerMY3Q8
Explorer
Explorer

Deleted

0 Likes

Deleted

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report