.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

EventHandler for CatalogRegen

4 REPLIES 4
Reply
Message 1 of 5
mhillis
486 Views, 4 Replies

EventHandler for CatalogRegen

Hello all.

 

Simple question, is it possible to bind an eventhandler to Catalog Regeneration?  

 

I have some routines that opens up an MvPart catalog file and stores its entries in memory.  It does this everytime the routine is run.  I'd like to be able to set-up an EventHandler that will do this read of the Catalog upon startup and when the catalog is regenerated.  Start up is easy, but does anyone know what I'd need to tie into for the CatalogRegen?

 

Thanks!

4 REPLIES 4
Message 2 of 5
Alexander.Rivilis
in reply to: mhillis

If I understand correctly your question, then you have to keep track of changes to the file(s) of Catalog. So you can use FileSystemWatcher.Changed Event

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 3 of 5
Keith.Brown
in reply to: mhillis

You can also try monitoring the catalog Regen command. I am not 100 percent sure if the command is ran when the catalogs are regened via the balloon notification however.
Message 4 of 5
mhillis
in reply to: Alexander.Rivilis


@Alexander.Rivilis wrote:

If I understand correctly your question, then you have to keep track of changes to the file(s) of Catalog. So you can use FileSystemWatcher.Changed Event


Alex,

 

Thanks for getting back to me.  FileSystemWatcher might work, but I'm having a little issue. Currently, I've got two catalog files loaded into AutoCAD.  So when I regen the Catalog, both are regenerated.  The issue I'm having is that the Event is being thrown BEFORE the Catalog I'm watching is regenerated and isn't thrown once the regen is finished.  I'm looking for the Event to be thrown after the regen is finished. So I can then read the new file and store info from it accordingly.  Any ideas?

 

' Set up watch on Catalog File.
        Dim fileWatch As New FileSystemWatcher
        fileWatch.Path = "C:\MEPcontent\USI\MvParts\"
        fileWatch.Filter = "*.apc"
        fileWatch.NotifyFilter = NotifyFilters.LastWrite
        fileWatch.EnableRaisingEvents = True
        AddHandler fileWatch.Changed, New FileSystemEventHandler(AddressOf MvPartsRegenerated)

Friend Sub MvPartsRegenerated(ByVal sender As Object, ByVal e As FileSystemEventArgs)
        UpdateCatalogInfo()
    End Sub
Message 5 of 5
Alexander.Rivilis
in reply to: mhillis

I think that the easiest way would be to start in MvPartsRegenerated Timer on 1 second instead of call UpdateCatalogInfo(). And in Timer callback function call UpdateCatalogInfo(). The duration of the timer you can choose individually.

Sorry but I do not work with AutoCAD Civil 3d / MEP, so I can not test this code.

 

By the way, why do not you take advantage MGDDBG or ARXDBG to check whether there is some kind of event with Regen Catalog?

You can download ready to use in AutoCAD 2012...2017 ARXDBG bundle: http://adn-cis.org/assets/gallery/AutoCAD/ArxDbg.bundle.zip and MGDDBG bundle: http://adn-cis.org/assets/gallery/AutoCAD/MgdDbg.zip

 

Maybe Regen Catalog is done as a command (so you can check CommandEnded event)?

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost