Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm currently working on an updater that will place walls along model lines upon their creation. However, I only want this to happen after a DWG has been imported and exploded. I've tested the updater itself, and it seems to work, but I'm having issues getting it to register inside an EventHandler. I started off registering inside a FileImportedEvent, and when that didn't work, I tried implementing an IdlingEvent as a workaround. The only information I can get out of the exception is "External Component has thrown an exception". Does anybody have any thoughts?
I don't want to overwhelm anyone with code, so here's the idling event and the register method:
private void RegisterUpdater(object sender, IdlingEventArgs args)
{
_uiConApp.Idling -= RegisterUpdater;
if (dwgWalls == null)
{
try
{
using (Transaction t = new Transaction(doc, "Register"))
{
t.Start();
dwgWalls = new DWGWalls(thisAppId);
dwgWalls.Register(doc); //Need to implement an Idling event to handle the registration
t.Commit();
}
}
catch (Exception ex)
{ }
}
ElementFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_Lines);
UpdaterRegistry.RemoveAllTriggers(dwgWalls.GetUpdaterId());
dwgWalls.AddTrigger(doc, filter);
}
class DWGWalls : IUpdater
{
UpdaterId updaterId = null;
internal DWGWalls(AddInId thisAppId)
{
updaterId = new UpdaterId(thisAppId, new Guid());
}
internal void Register(Document doc)
{
try
{
if (!UpdaterRegistry.IsUpdaterRegistered(updaterId))
{
UpdaterRegistry.RegisterUpdater(this, doc, true);
}
}
catch (Exception ex)
{ }
}
// The rest of the Updater...
}
Solved! Go to Solution.