KitchenDraw Plugin Events
A certain number of events occur during the use of the KitchenDraw software. They
allow launching the execution of their corresponding functions located in
the plugins. These functions are called plugin
functions, or equally plugin event handlers. For example, OnSceneInformationBefore
plugin function is
executed when user launches the "Scene|Information" command, just before
the corresponding dialog box appears.
Plugin function is executed when the event with the same name is fired in the KitchenDraw application. Because the name of a plugin event and the corresponding function in the plugin are always the same, this documentation uses plugin function, plugin function handler, and plugin event terms interchangeably.
Plugin Function Signature
To be registered and executed, plugin function must have the following signature:
bool OnAppStartAfter(int unused);
where OnAppStartAfter
can be replaced with any valid event name. For .NET and
ActiveX plugins this should be a method of Plugin
class, while for an
ordinary .DLL plugin function is just an exported function.
The function should take one integer parameter, which is not actually used by
now anymore. It should return true
if there were no errors. false
can be
returned otherwise, but please be aware that if you return false then the same
plugin functions in the other registered plugins will not be called, and the
user action will be aborted (for the events where applicable). So, return
false
wisely.
Please be aware that multiple plugins implementing a particular plugin
function can be registered and loaded at the same time. In this case, the
plugins are called one-by-one, until either all the plugins are executed, or
some plugin has returned false
from its corresponding plugin function. In
practice that means, that if your plugin function is not executed in the
KitchenDraw software for some reason, you should firstly ensure that no other
plugin prevents yours from the execution by returning false
.
Available Plugin Events
The list of the plugin functions that can be implemented by KitchenDraw plugin is the following:
OnAppStartBefore
OnAppStartAfter
OnAppReady
OnAppCommandBefore
OnAppCommandAfter
OnAppQuitBefore
OnAppQuitAfter
OnAppSelectedCatalogChangeBefore
OnAppSelectedCatalogChangeAfter
OnAppWebDocumentComplete
OnAppUrlExec
OnUserConnectionBefore
OnUserConnectionAfter
OnPluginLoad
OnPluginUnload
OnFileNewBefore
OnFileNew
OnFileNewAfter
OnFileNewDlgInit
OnFileOpenBefore
OnFileOpen
OnFileOpenAfter
OnFileSaveBefore
OnFileSaveAfter
OnFileSaveAsBefore
OnFileSaveAsAfter
OnFileSaveVersionBefore
OnFileSaveVersionAfter
OnFileCloseBefore
OnFileCloseAfter
OnFilePanoramaAfter
OnFileCardboardAfter
OnFileImportSceneBefore
OnFileImportSceneAfter
OnFilePrintWordDocBefore
OnFilePrintWordDoc
OnFilePrintWordDocGenerated
OnFilePrintWordDocAfter
OnFilePrintWordDocDlgInit
OnFilePrintBefore
OnFilePrintAfter
OnFileGenerateOrdersBefore
OnFileGenerateOrders
OnFileGenerateOrdersAfter
OnFileExecBefore
OnFileExec
OnFileExecAfter
OnEditUndoBefore
OnEditUndoAfter
OnEditRedoBefore
OnEditRedoAfter
OnEditCutBefore
OnEditCutAfter
OnEditCopyBefore
OnEditCopyAfter
OnEditPasteBefore
OnEditPasteAfter
OnSceneInformationBefore
OnSceneInformation
OnSceneInformationAfter
OnSceneInformationDlgInit
OnSceneInformationDlgValidation
OnSceneInformationDlgOk
OnSceneSpaceBefore
OnSceneSpace
OnSceneSpaceAfter
OnSceneGenericFinishesBefore
OnSceneGenericFinishes
OnSceneGenericFinishesAfter
OnScenePartsListBefore
OnScenePartsList
OnScenePartsListAfter
OnSceneUpdatePricesBefore
OnSceneUpdatePrices
OnSceneUpdatePricesAfter
OnSceneVATRatesBefore
OnSceneVATRates
OnSceneVATRatesAfter
OnSceneCommentBefore
OnSceneComment
OnSceneCommentAfter
OnSceneRenumberBefore
OnSceneRenumber
OnSceneRenumberAfter
OnSceneCheckingBefore
OnSceneChecking
OnSceneCheckingAfter
OnSceneLayersBefore
OnSceneLayers
OnSceneLayersAfter
OnSceneLayerSetBefore
OnSceneLayerSetAfter
OnSceneDrawingStyleBefore
OnSceneDrawingStyle
OnSceneDrawingStyleAfter
OnSceneMarkBefore
OnSceneMark
OnSceneMarkAfter
OnSceneGridBefore
OnSceneGrid
OnSceneGridAfter
OnSceneAutomaticLinearArticlesBefore
OnSceneAutomaticLinearArticlesAfter
OnSceneSetNewPublicBillId
OnSelectionChangeAfter
OnSelectionDeleteBefore
OnSelectionDeleteAfter
OnSelectionMoveBefore
OnSelectionMoveAfter
OnSelectionDuplicateBefore
OnSelectionDuplicateAfter
OnSelectionPercussionBefore
OnSelectionPercussionAfter
OnObjectPlaceBefore
OnObjectPlaceAfter
OnObjectDropBefore
OnObjectDropAfter
OnObjectReplaceBefore
OnObjectReplaceAfter
OnObjectAttributsBefore
OnObjectAttributs
OnObjectAttributsAfter
OnObjectAttributsDlgInit
OnObjectAttributsDlgValidation
OnObjectAttributsDlgOk
OnObjectComponentsBefore
OnObjectComponents
OnObjectComponentsAfter
OnObjectComponentsDlgInit
OnObjectComponentsDlgValidation
OnObjectComponentsDlgOk
OnObjectFinishesBefore
OnObjectFinishes
OnObjectFinishesAfter
OnObjectFinishesDlgInit
OnObjectFinishesDlgValidation
OnObjectFinishesDlgOk
OnObjectPricesBefore
OnObjectPrices
OnObjectPricesAfter
OnObjectSpecialTermsBefore
OnObjectSpecialTerms
OnObjectSpecialTermsAfter
OnObjectCommentsBefore
OnObjectComments
OnObjectCommentsAfter
OnObjectWizardBefore
OnObjectWizard
OnObjectWizardAfter
OnObjectCatalogPrices
OnObjectGrossSellingPrice
OnObjectDeleteBefore
OnObjectDeleteAfter
OnObjectEstimateQuantityChangedBefore
OnObjectEstimateQuantityChangedAfter
OnObjectContextualMenuBefore
OnObjectActivate
OnObjectClickMark
OnObjectResizeBefore
OnObjectResizeAfter
OnObjectPreviewGetPrice
OnObjectNonGenericModelText
OnOrderGetEmailSubject
OnOrderGenerateEmailFilesAfter
OnViewEstimateBefore
OnViewEstimateAfter
OnViewChangeBefore
OnViewChangeAfter
OnShowWebCatalog
OnRightStatusBarUpdate
OnCatalogDictionaryUpdateBefore
OnCatalogDictionaryUpdateAfter
You can see that most of the plugin functions exist in 2 or 3 or even 6
versions: a version whose name ends with Before
, another that
ends with After
, one without a special suffix, and some others for the case if the command involves a dialog box.
In fact, when a user runs an application command, two or three events
(depending on the command) are fired consecutively. Let's take a look on events whose names start with OnSceneInformation..
.
The ..Before
event is fired prior to execution of the command. The value returned by the a plugin function can alter the execution flow: true
allows continuing
the command processing whereas false
stops it. This plugin event allows
plugins to prepare the scene before the builtin command is processed, or to prevent the command to be executed at all, e.g. if some conditions are not met.
Next, if any of the registered plugins implements OnSceneInformation
plugin function, this function will be executed - only once, and only for one plugin implementing the function (if several plugins implement the same function, it's implementation dependent what plugin will get fired. You shouldn't rely on this).
If now plugin implements OnSceneInformation
, then the built in command processing will take place. In this case, the corresponding dialog will be shown, and the three additional events (described below) will be fired.
At last, the ..After
event is fired - no matter whether a plugin processed OnSceneInformation
or a built-in dialog was shown. This function is usually dedicated in plugins to applying the changes appeared while the command was executed.
Here is the graph representing the sequence of the various plugin functions associated to a command:
For the OnSceneInformation
, OnObjectComponents
and the OnObjectAttributs
functions, the 3 other versions exist: the first one with the DlgInit
ending,
the second one with the DlgValidation
ending and the third one with the
DlgOk
ending.
The DlgInit
event is fired at the end of the initialisation phase of the
standard dialog box just before being displayed. The corresponding plugin
function could setup some information in the dialog box or even change the
layout of the dialog box adding or removing controls. The handle of the dialog window can be obtained from Appli.CallParamsInfo.WindowHandle
property, and the dialog may be examined and/or altered using Windows API - for example, with GetDlgItemText
function.
The DlgValidation
event is fired when the user has pressed the "Ok" button.
The corresponding plugin function could check the values of the controls in the
dialog box. A False value returned by the function will prevent the dialog box
to be closed.
The DlgOk
event is fired after the DlgValidation
event except if the
DlgValidation
function returns false
. The corresponding plugin function
could store the values contained in the dialog box controls or use them to do
something.
OnAppStartBefore event
Please be aware that most of the SDK2 functionality can't be used when the
onAppStartBefore
event is triggered. This is because of the environment
(which is necessary to their execution) is not set up yet. Thus, the functions
of the Scene class, those of the Dico](xref:KD.SDK2.Dico) class as well as the functions of the Appli class which are used to administrate the users, the
sites, the plugins and the suppliers cannot be called at that moment. These
functions can be called without any restrictions in an OnAppStartAfter
event
and later.
OnOrderGetEmailSubject and OnObjectPreviewGetPrice events
The OnOrderGetEmailSubject
and OnObjectPreviewGetPrice
functions are
expected to return a corresponding result.
The OnObjectPreviewGetPrice
function should return the price of the article
displayed in the preview area of the catalogue window. This function will be
called each time the article selected in the catalogue window changes. In this
particular case, the lCallParamsBlock parameter will refer to a temporary scene
(and not the current scene as it usually does) being a clone of the current
scene but containing only one parent object (plus its possible components)
corresponding to the article which is selected in the catalogue window. It will
be then possible in the OnObjectPreviewGetPrice function to get the information
corresponding to this article using the SceneGetObjectId function (to recover
the Id of the first scene object) and then the ObjectGetInfo function. The
price should be set to the Appli.CallParamsInfo.Buffer property.