Fabrication Configuration Reload Event

Fabrication Configuration Reload Event

TheRealChrisHildebran
Advocate Advocate
1,257 Views
9 Replies
Message 1 of 10

Fabrication Configuration Reload Event

TheRealChrisHildebran
Advocate
Advocate

 Ive looked but cannot see any event that fires on Fabrication Configuration Reload.

 

Need to disable some of our tools while reloading and then enable after.

 

Does anyone have a workaround?

0 Likes
1,258 Views
9 Replies
Replies (9)
Message 2 of 10

jeremytammik
Autodesk
Autodesk

Does this suggestion to detect a command launch help?

 

https://thebuildingcoder.typepad.com/blog/2020/01/torsion-tools-command-event-and-info-in-da4r.html#...

 



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

Message 3 of 10

TheRealChrisHildebran
Advocate
Advocate

Greetings Jeremy, 

 

At first glance it seems this will be helpful monitoring for a transaction. Will experiment to see if Revit will allow me to Disable some IUpdaters.

 

Regardless this would be helpful in many other ways!

 

Thanks for pointing this out to me and our community!

 

Ill report my findings for this specific case. 

 

0 Likes
Message 4 of 10

TheRealChrisHildebran
Advocate
Advocate

So, in my circumstance, Jeremy's suggestion to look for a transaction with a specific name will not work. As Jeremy noted in his blog for Group Edit, Assembly Edit and i assume many others there is a finished event is triggered on "Group Edit Finish", "Assembly Edit finish" and so on. 

 

What im trying to do is disable several DMU's (IUpdater's) prior to reloading the Fabrication Configuration for a project. There are no events to subscribe to for the FabricationConfiguration class (https://www.revitapidocs.com/2020/119c73a2-a113-aa8c-e032-e80d22e31ac8.htm).

 

The reload, of course, does occur inside of a transaction whose name is "Fabrication Settings" and i can trigger an event using it. The event, however, is only fired once after the transaction is "TransactionCommitted, TransactionRolledBack, TransactionGroupRolledBack, TransactionUndone or TransactionRedone".

 

There is no second transaction such as "Fabrication Settings Finished" or "Fabrication Configuration Reload Finish" 

 

As always, thank for the assist Jeremy!

 

 

0 Likes
Message 5 of 10

jeremytammik
Autodesk
Autodesk

Thank you for the appreciation!

 

Check for other (non-Revit) events that may fire. There may be hundreds. For instance, when you say 'configuration reload', I would assume that some file is being touched somewhere... or where are they reloaded from? The Internet? In both cases, the Windows API and others will be firing events left right and centre that you could catch and interpret.

 

Good luck hunting!

 

Cheers,

 

Jeremy

 



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

Message 6 of 10

TheRealChrisHildebran
Advocate
Advocate

Ill dig into your suggestion about looking outside of Revit. During debug i can pick the button in the MEP Fabrication Parts dockable dialog. Can get its name and parent(s).

MonitorUiClick.png

0 Likes
Message 7 of 10

matthew_taylor
Advisor
Advisor

Hi @TheRealChrisHildebran,

What if you redefine/replace the fabrication settings command. Replace it with another command which disables the  iUpdaters, then triggers the builtin command. Then use either an iUpdater or a DocumentChanged event to watch for changes to the fabrication configuration....then re-enable the iUpdaters. (I think DocumentChanged would be better as it would more easily manage the situation where the operator clicked 'cancel'.)

 

MEP Fabrication Settings from the ribbon:

Jrn.Command "Ribbon" , "Fabrication Settings , ID_MEP_FABRICATION_SETTINGS"
'C 09-Jun-2020 08:24:58.216; 1:< Executing AddInJournaling : WpfWindow(SettingsDialog,Fabrication Settings).WpfButton(0,OK).Click()
'E 09-Jun-2020 08:24:58.216; 1:<
Jrn.AddInEvent "AddInJournaling" , "WpfWindow(SettingsDialog,Fabrication Settings).WpfButton(0,OK).Click()"

 

From the MEP Fab browser:

'C 09-Jun-2020 08:28:28.998; 0:< Executing AddInJournaling : ApiDockablePane(MEP Fabrication Parts,FabricationPartBrowser\.FabPartBrowserPage).WpfButton(0,Settings).Click()
'E 09-Jun-2020 08:28:28.998; 0:<
Jrn.AddInEvent "AddInJournaling" , "ApiDockablePane(MEP Fabrication Parts,FabricationPartBrowser\.FabPartBrowserPage).WpfButton(0,Settings).Click()"
'H 09-Jun-2020 08:28:29.008; 0:<
Jrn.Directive "IdleTimeTaskInvocation" _
, "0.ExternalEvent", 1, "{0,4694}"
' 0:< ::437:: Delta VM: Avail +25 -> 134210002 MB, Used +1 -> 1198 MB; RAM: Avail -14 -> 14972 MB, Used +1 -> 889 MB
' 0:< GUI Resource Usage GDI: Avail 8990, Used 1010, User: Used 534
'C 09-Jun-2020 08:29:17.714; 0:< Executing AddInJournaling : WpfWindow(SettingsDialog,Fabrication Settings).WpfButton(0,OK).Click()
'E 09-Jun-2020 08:29:17.714; 0:<
Jrn.AddInEvent "AddInJournaling" , "WpfWindow(SettingsDialog,Fabrication Settings).WpfButton(0,OK).Click()"
'E 09-Jun-2020 08:29:17.948; 0:<
' [Jrn.ExternalEventExecution] Rvt.Attr.AddInId: ee72acb7-2d70-484e-9cdf-0f7006b1183e Rvt.Attr.AddInName: FabPartBrowserApplication Rvt.Attr.AddInVersion: 21.0.0.383 Rvt.Attr.ExternalEventName: FabPartBrowserExternalEventHandler Rvt.Attr.VendorDescription: Autodesk, www.autodesk.com Rvt.Attr.VendorId: ADSK


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
Message 8 of 10

TheRealChrisHildebran
Advocate
Advocate

Whoa! Redefine/replace the command!

 

You can do that?

 

Much rather have an event as you mentioned! 

User can click OK, Cancel, Close Window X, hit escape...

 

Ill report back..

 

Thanks @matthew_taylor !

 

0 Likes
Message 9 of 10

TheRealChrisHildebran
Advocate
Advocate

So, looking up "revit api command redefine" immediately brought up a link to Harry Mattison's Boost your BIM site which suggests the use of AddInCommandBinding.

 

While I don't yet understand the redefine/replace strategy, the strategy below seems like a good one as well. Code below is straight from the site. 

 

private static void Module_Startup(object sender, EventArgs e)
		{
			UIApplication uiapp = new UIApplication(this.Application);

			RevitCommandId commandId = RevitCommandId.LookupCommandId("ID_FILE_IMPORT");
			
			try
			{
				AddInCommandBinding importBinding = uiapp.CreateAddInCommandBinding(commandId);

				importBinding.Executed += new EventHandler<Autodesk.Revit.UI.Events.ExecutedEventArgs>(ImportReplacement);
			}
			catch
			{}
		}

 

private static void ImportReplacement(object sender, Autodesk.Revit.UI.Events.ExecutedEventArgs arg)
		{
			TaskDialog.Show("Stop!", "Do not import!");
		}

 

Message 10 of 10

matthew_taylor
Advisor
Advisor

Harry makes things look like child's-play! Good example.

Now to check whether PostCommand fires the original binding or the new (if it uses the new, I guess you'll put Revit in an infinite loop!), or whether there's a way of re-using the existing CommandBinding.


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?