Dynamic model update - how to AddTrigger for worksets (not elements)

Dynamic model update - how to AddTrigger for worksets (not elements)

boostyourbim
Advocate Advocate
586 Views
4 Replies
Message 1 of 5

Dynamic model update - how to AddTrigger for worksets (not elements)

boostyourbim
Advocate
Advocate

Hi,

 

I'd like to invoke an updater when worksets are created. But all overloads for UpdaterRegistry.AddTrigger require an ElementFilter, not a WorksetFilter. 

Any ideas how this can be done?

 

Thanks

Harry

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

FAIR59
Advisor
Advisor

As you say worksets aren't Elements, so an Updater won't work.  But when the user changes/adds/deletes worksets, Revit records a transaction named "Worksets".  So if you subscribe to the documentchanged event, you can test for the transaction name.

 

        void ControlledApplication_DocumentChanged(object sender, Autodesk.Revit.DB.Events.DocumentChangedEventArgs e)
        {
            if (e.GetTransactionNames().Contains("Worksets"))
            {
                // Check  document.GetWorksetTable() for new worksets
            }
        }

If you expect other Addin's to create worksets, then this will not work. (the transaction will have another name). In that case your only option is to use a timer to check periodically  for new worksets

 

  

0 Likes
Message 3 of 5

boostyourbim
Advocate
Advocate

Thanks, but the document is in a read-only state during DocumentChanged so that doesn't help in this case.

0 Likes
Message 4 of 5

FAIR59
Advisor
Advisor

Instead of doing something in the DocumentChanged method, you can launch an External Event and do your checks there.

0 Likes
Message 5 of 5

matthew_taylor
Advisor
Advisor

Hi @boostyourbim,

If you're trying to enforce something (such as a naming standard), then you may able to use a custom FailureDefinition and a custom failure handler.

Can you say exactly what you're trying to do? It may sprout ideas.

 


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