Disable IUpdater in Family Document

Disable IUpdater in Family Document

rvtquestions
Advocate Advocate
452 Views
2 Replies
Message 1 of 3

Disable IUpdater in Family Document

rvtquestions
Advocate
Advocate

While implementing background applications using IUpdater I want to ensure it is only functioning in Project Documents and not Family Documents. I assume they will still load up when opening up a family, for instance. If that is the case, what are some ways to ensure my IUpdater is registered and functioning only when in a Project Document?

 

Can I check during the public Result OnStartUp() level

(How can I get Document doc at this level without ExternalCommandData?)
if(doc.IsFamilyDocument) { } else { UpdaterRegistry.RegisterUpdater(updater); rest of code }

Or do I have to test it at the public void Execute(UpdaterData data) level?:

 

Document doc = data.GetDocument();
if (doc.IsFamilyDocument)
{
}
else
{
continue with rest of code
}

Are these methods viable or is there a better way?

 

0 Likes
453 Views
2 Replies
Replies (2)
Message 2 of 3

FaustoMendezcom
Enthusiast
Enthusiast

Just use the Application Initialized Events

 

like 

public class DocumentOpenedEventArgs : RevitAPIPostDocEventArgs
and or
public class DocumentOpeningEventArgs : RevitAPIPreEventArgs

like

public void application_DocumentOpened(object sender, DocumentOpenedEventArgs args)
{
// get document from event args.
Document doc = args.Document;
}

http://www.revitapidocs.com/2018.1/1c21b33d-1314-d096-0a36-ad59ad80c6e9.htm

Hope it helps 🙂
-------------------------------------------------------------------------------------
www.faustomendez.com
0 Likes
Message 3 of 3

jeremytammik
Autodesk
Autodesk

Look at the description of the DistanceToSurfaces SDK sample:

 

https://thebuildingcoder.typepad.com/blog/2010/04/element-level-events.html#3

 

It says:

 

  • On start-up, register a DocumentOpened event. When a document is opened:
  • Check for the presence of the sphere family.
  • Check for the presence of a 3D view named 'AVF'.
  • Create a GetChangeTypeGeometry trigger that will activate when a wall, mass, or family instance changes.

 

You could use a similar approach, checking whether the current document is a family document or not and not registering any trigger at all in the former case.

 

Cheers,

 

Jeremy

 



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

0 Likes