What are Hooks?
The WERK24 API is designed to be asynchronous, allowing you to display a Page Thumbnail (typically available within 300-500 milliseconds) while simultaneously extracting all Measures from the Technical Drawing (which can take up to 50 seconds for complex files).
To simplify your integration, we use the Hook concept, which links an Ask to a function that is automatically executed when the requested information becomes available.
Example: Using Hooks in Python
Suppose you want to (i) save a page thumbnail and (ii) print the extracted measures to the terminal. You can define the following hooks:
from werk24 import Hook, W24AskPageThumbnail, W24AskVariantMeasures
hooks = [
Hook(ask=W24AskPageThumbnail(), function=save_file),
Hook(ask=W24AskVariantMeasures(), function=print)
]
This setup ensures that as soon as the requested data is available, the respective function is triggered, keeping your code clean and efficient.