GiD - The personal pre and post processor

Developing the plug-in

GiD is compiled with the Tcl/Tk libraries (the Tcl version could be seen in Help->About - More...).
Remember that if the developed plugin is targeted for 32 bits, only GiD 32 bits can handle it. If the developed plugin is developed for 64 bits systems, then GiD 64 bits is the proper one to load the plugin.

  • Header inclusion

In the plug-in code, in one of the .cc/.cpp/.cxx source files of the plug-in, following definition must be made and following file should be included:

#define BUILD_GID_PLUGIN
#include "gid_plugin_import.h"


In the other .cc/.cpp/.cxx files which also use the provided functions and types, only the gid_plugin_import.h file should be included, without the macro definition.
The macro is needed to declare the provided functions as pointers so that GiD can find them and link with its internal functions.

  • Functions to be defined by the plug-in

Following functions should be defined and implemented by the plug-in:

extern "C" GID_DLL_EXPORT int GiD_PostImportFile( const char *filename) ) {
	... ;
	return 0;  // 1 - on error
}
extern "C" GID_DLL_EXPORT const char *GiD_PostImportGetLibName( void) {
	return "Wavefront Objects import";
}
extern "C" GID_DLL_EXPORT const char *GiD_PostImportGetFileExtensions( void) {
	return "{{Wavefront Objects} {.obj}} {{All files} {*}}";
}
extern "C" GID_DLL_EXPORT const char *GiD_PostImportGetDescription( void) {
	return "Wavefront OBJ import plugin for GiD";
}
extern "C" GID_DLL_EXPORT const char *GiD_PostImportGetErrorStr( void) {
	return _G_err_str; // if error, returns the error string
}


When GiD is told to load the dynamic library, it will look for, and will call these functions:


GiD_PostImportGetLibName : returns the name of the library and should be unique. This name will appear in the File->Import->Plugin menu and in the right menu.


GiD_PostImportGetFileExtensions : which should return a list of extensions handled by the library and will be used as filter in the Open File dialogue window.


GiD_PostImportGetDescription: : returns the description of the library and will be displayed in the title bar of the Open File dialogue window.


Once the library is registered, when the user selects the menu entry File->Import->Plugin->NewPlugin the Open File dialogue window will appear showing the registered filters and description of the plug-in.



The file selection window showing the plug-in description as title of the window and filtering the file list with the registered extension


When the user selects a file then following functions are called:

GiD_PostImportFile : this function should read the file, transfer the mesh and results information to GiD and return 0 if no problems appeared while the file was read or 1 in case of error.


GiD_PostImportGetErrorStr : this function will be called if the previous one returns 1, to retrieve the error string and show the message to the user.

COPYRIGHT © 2022 · GID · CIMNE