ThingWorx Edge SDK Extensions for the C SDK > Advanced Use of Edge Extensions > Applying EdgeThingShapes at Runtime
  
Applying EdgeThingShapes at Runtime
The ability to compose a Thing not only at compile time but dynamically at runtime allows for the future assembly of Things, using external tools such as ThingWorx Composer. Normally, a thing would be constructed at compile time by a developer. However, the ability to create a Thing and then provide it with capabilities at runtime is also supported, both as local C functions and on the platform. On the platform, this dynamic capability is supported by functions in the EdgeGenericThingTemplate, which is the base constructor of all template-based things. These dynamic capabilities include:
Loading shape libraries
Adding shapes to existing things
Returning a list of shapes implemented on this thing
To load a shape library at runtime you would normally call twLoadShapeLibrary(char * shapeLibraryName). That said, any Edge Thing that is created based on EdgeGenericThingTemplate exposes a function called, loadShapeLibrary(shapeLibrary) to the platform. This function can be called on the platform to cause the remote process to load the specified dynamic library if it is found. To apply a registered shape to an existing thing at runtime, use the following command:

void twExt_AddEdgeThingShape(char* entityName,char* shapeName);
This command runs the constructor and configures the requested ThingShape if it has already been loaded. This function is also exposed to the platform and appears as the function twExt_DoesThingImplementShape() to any Edge Thing that is created based on the EdgeGenericThingTemplate.
Lastly, any entity can be queried for the shapes that it currently supports by using the following call:

void twExt_GetEdgeThingShapes(char* entityName);
This function is also exposed to the platform through EdgeGenericThingTemplate as getEdgeThingShapes();.