Macro Declarations

To declare a macro, specify a name, optional parameter list, optional attribute list, and function body.

Details

Details are as follows:

Examples

The following example declares a macro named WriteStringToLogWindow, which writes the predetermined string Hello World! to Simdify's Output window.

macro WriteStringToLogWindow()
[Category = "User Commands", Guid="{F82F102A-C7D2-4C94-AC04-6D3CC218266E}", Image=".\\icons\\generic_script_icon.bmp"]
{
   Application.Log.LogString( "Hello World!" );
}

The following example declares a macro named SetSelectedMaterialColorsToWhite, which sets the ambient and diffuse color values for all the selected materials to pure white. This macro also changes the name of each selected material to WhiteMaterial.

macro SetSelectedMaterialColorsToWhite()
[Category="Material Commands", Guid="{96680225-12BA-410A-97F3-6F84A691B508}", Image=".\\icons\\set_material_white.bmp"]
{
   auto NodeBuffer nodes = LibSelection.GetSelected( Material );
   auto NodeBufferView view = nodes.GetView();

   while( view.First.Position != view.Last.Position )
   {
      Material material = (Material)view.First.Value;
      material = LibEdit.EditMaterial( material ); // So we have undo.
      material.Name = "WhiteMaterial";
      material.AmbientColor.SetRGB( 255, 255, 255 );
      material.DiffuseColor.SetRGB( 255, 255, 255 );
   }
}

Globally Unique Identifiers [GUID]

Every Simdify command, whether implemented in C++ or Simdify Scripting Language needs a globally unique identifier to register itself with the running instance of Simdify.exe in which it is loaded. The identifier must be unique to prevent command registration conflicts. For example, if you register two commands with the same GUID, both commands will be mapped to the first command that was loaded. GUIDs provide a unique slot for each command. Simdify has a built-in command to generate a GUID.

Specifying Images

Simdify commands can use an optional 16x16 bitmap image. A macro can specify an image using a module name and resource identifier pair or a path to the image location on disk.

For example, to specify an image in the module CORE-APP-EDITTOOLS with the identifier IDB_GENERICSCRIPT_COMMAND, use the following string:

// The exclamation point is used to separate the module name from the resource identifier.
Image="CORE-APP-EDITTOOLS!IDB_GENERICSCRIPT_COMMAND"

To specify an image on disk located at C:\ICONS\USERICON.BMP use the following string:

// This script uses an absolute path to its image. This is not best practice.
Image="C:\\ICONS\\USER_ICON.BMP"

To specify an image on disk located at PROGRAM FILES\SCENOMICS\ICONS\USERICON.BMP use the following string:

// This script uses a relative path from SCENOME.EXE to specify its image. This is best practice.
Image=".\\ICONS\\USER_ICON.BMP"