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: 

DialogBoxShowing event not firing when model is opened.

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
david_rock
1166 Views, 10 Replies

DialogBoxShowing event not firing when model is opened.

Hello,

 

I'm reciving about 50 messages that I have to press Close to each message when I open a Revit model. This is coming from linked dwg files in a linked model. It takes forever to open a model because of this.

Some numerical data.png

Note: I am able to supress this message when the dwg is linked or reloaded into the host dwg model and if the model containing the dwgs is linked.

However the issue still remains when the model with the link is opened.

Note: That the dwg files are close to the base point and they display OK. It is only that some weird blocks in the dwg have origins far away that is causing the issue. I can't easily fix this, I can't explode the dwgs, I need to know how to supress this message when the Revit Model is opened.

 

Following is what I am using to supress the message:

Public Function OnStartup(ByVal objUIControlledApplication As Autodesk.Revit.UI.UIControlledApplication) As Autodesk.Revit.UI.Result Implements Autodesk.Revit.UI.IExternalApplication.OnStartup
    AddHandler objUIControlledApplication.DialogBoxShowing, AddressOf clsEventsApplication.SupressRevitMessage
End Function

Public Shared Sub SupressRevitMessage(ByVal sender As Object, ByVal e As Autodesk.Revit.UI.Events.DialogBoxShowingEventArgs)
    Dim e2 As Autodesk.Revit.UI.Events.TaskDialogShowingEventArgs = TryCast(e, Autodesk.Revit.UI.Events.TaskDialogShowingEventArgs)
    e2.Message.ToUpper.Contains("Some numerical data".ToUpper) Then
    If e2.OverrideResult(CInt(DialogResult.Cancel)) Then
        Exit Sub
    End If
End Sub

 Any help very much appretiated.

 

Kind Regards

David

 

 

 

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

Dear David,

 

Your first port of call could be here:

 

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

 

Cheers,

 

Jeremy



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

Message 3 of 11
david_rock
in reply to: jeremytammik

Hi Jeremy,

 

Thank you for the link,

 

I have checked the blog, the event I have is all fine and as I said it works OK after the document is opened. I have checked the event is registered when the app is loaded at Revit startup so I belive it is just that Revit does not fire this event when models are opened. I hope this changes in future versions or they consolodate these messages into one message rather than one for each link.

 

The good news is that I have found the problem with the dwgs. It turns out there are many block elements within the dwg which contain 0 items inside the block. So even though AutoCAD zoomed extents ignoring these blocks, Revit was reading them as far away items and thus displaying this message.

 

I have written a lisp command to delete any blocks which contain nothing from the dwg database.

 

Kind Regards

David 

Message 4 of 11
jeremytammik
in reply to: david_rock

Dear David,

 

Thank you for the appreciation and good news.

 

Sorry the blog did not help.

 

Congratulations on solving this!

 

It is always better to attack the root cause, of course.

 

Sorry the Revit API does not give access to that specific message.

 

In a pinch, you could probably handle it using the Windows API.

 

Cheers,

 

Jeremy



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

Message 5 of 11
arnostlobel
in reply to: jeremytammik

David,

 

could you please upload a simple DWG file that contains at least one such "invalid" block? I'd like to test it locally. I cannot promise I'll find a solution, but at least I want to see what is going on. I presume you used R2015, correct?

 

Thank you

 

Arnošt Löbel
Message 6 of 11
david_rock
in reply to: arnostlobel

Hi Arnošt,

 

Thank you, please find attached a sample dwg.

 

One other problem with the dialog message is that it gives no usable feedback as to which link has the issue. So if there are many links and only one of them has a element outside the usable coordinates, then its difficult to examine which link has the problem.

 

Kind regards

David

 

 

Message 7 of 11
arnostlobel
in reply to: david_rock

Thank you, David.

 

I've been testing today with the file you provided and I will have some results to post later.

 

Until then, ....

Arnošt Löbel
Message 8 of 11
arnostlobel
in reply to: arnostlobel

Hello David:

 

I have a partial success, but I do not know if it covers it all, for I strugle to reproduce the steps you mentioned.

I am using the following code (C#) as the handler of the Doalog:

 

public void MyDialogBoxShowingEventHandler (object sender, DialogBoxShowingEventArgs args)
{
   TaskDialogShowingEventArgs taskDlgArgs = args as TaskDialogShowingEventArgs;

   if ((taskDlgArgs != null) && (!string.IsNullOrEmpty(taskDlgArgs.Message)))
   {
string msg = " Some numerical data within the imported file was out of range.";
if (taskDlgArgs.Message.StartsWith(msg)) { args.OverrideResult((int)TaskDialogCommonButtons.Cancel); } } }

 

That works when I attempt to link the DWG file into a Revit Document, as well as when I attempt to re-load the DWG link in that document.

However, if I link the Revit document (which contains the DWG link) into another Revit (host) document, I do not get the warning at all and there is nothing to dismiss. Granted, I am using a newer version of Revit, but I doubt there have been changes made regarding this particular warning.

If I open the linked model from the host Revit document, and there I attempt to reload the DWG drawing, my event handler captures that and dismisses it. So it seems like it works as expected, at least in the scenarios I've tried so far.

 

As per your other comment, I do agree it would be useful to have information about the actual file that has this (or other) problems when being open (as a link). There is not workaround for that as far as I know, though. I’ll initiate a discussion about it with other developers to find out what (and whether) we can do something about it in the future.

 

Thank you

Arnošt Löbel
Message 9 of 11
david_rock
in reply to: arnostlobel

Hi Arnošt,

 

Thank you so much for your help,

 

What happened when you opened the either the host model or the linked model?

 

I found I was able to surpress the messagede when I reload or link, but not during open.

 

Kind Regards

David

Message 10 of 11
arnostlobel
in reply to: david_rock

David,

When I opened the host document (hosting a Revit link which itself was a host of a DWG link), I did not get any message at all. It had just opened. However, my host document did not have any other elements in it besides the one link.

When I opened the Revit link document, either directly or from within the host, I got the warning message and the event for it, which I was able to dismiss using the handler I showed above.

This does not mean that you did something wrong, of course. Scenarios are not always reproducible simply; it is what makes it so fun (I mean, so hard.) Also, like I said, I was using my current, local build, which is some R2016++, so technically it may matter, although I do not think it does. Sometimes, the only way to reproduce a user's case is to have the very same project file the customer uses.

I was looking into this as a sort of a puzzle; mostly I wanted to find out what kind of a dialog it was and why wouldn't there be a public event for it. If you still want to find out what is possibly going on, we may do a second round. This time, you could give me an actual Revit host with a Revit link in it which would contain the DWG link. Hopefully you would be able to simplify the files as much as possible. Then, if you can reproduce getting the dialog by just opening the host, I should be able to reproduce it on my side too. I do have some version R2015 on my PC too, thus could eventually try that as well.

Cheers
Arnošt Löbel
Message 11 of 11
Anonymous
in reply to: arnostlobel

I n

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

Post to forums  

Forma Design Contest


Rail Community