A Macro is a sequence of actions (menu or icon selections) that is recorded and stored for re-use.
Not all actions in the user interface can be included in a macro.
Before a sequence of actions is captured, the macro system prompts the user for a macro name and a language in which to store it. The choices are VBScript (the default), Python, Javascript, and Geomagic's "V8 Legacy Macro Language". The advantage of a non-Geomagic language is that the code can then be edited to include flow-control or queries. (All macros are stored at the directory named by Tools > Options > General > Directories > Macros.)
Functions on the Tools > Macros Menu
Execute - runs a previously recorded macro
Record - starts the recording
of a set of user actions for future repetition. The user is prompted to
specify a macro name and macro language.
End - terminates the recording
of a set of user actions.
Manage - allows renaming, organization, and
editing of re
corded macros
Play Preset - Executes one of five recorded macros that have been assigned to numeric icons in the toolbar. The icons are “1”, “2”, “3”, “4”, and “5”.
Enable Macro Server
- enables this instance of the application to receive and execute macros
from a remote client. The Macro Server can also be enabled at (and must
have been configured at) Macro
Server Manager.
Pause Macro Server
- delays pending execution of macros by the external macro client. The
Macro Server can also be paused at Macro
Server Manager.
Queries
Some Geomagic commands return a value (integer, float or string). But which ones? Or how to figure it out?
For info on bits of information that can be queried from the Geomagic application, see the "Queries" section of the Geomagic COM Server API document. as The following is a VBScript example of querying the application's "runtime database":
Dim Integer numObjects = geo.query(0, "NumObjects");
Help on Macro Languages
For programming details on each language, Geomagic recommends a web-based reference site, such as:
For JavaScript:
Reference Info: http://www.mozilla.org/js/spidermonkey/
License info:http://developer.mozilla.org/en/docs/Download_Mozilla_Source_Code
For Python:
Reference Info: http://www.python.org/
License info: http://www.python.org/psf/license.html
For VBScript:
Reference Info: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/ht
ml/0a8270d7-7d8f-4368-b2a7-065acb52fc54.asp
Tutorial: http://www.w3schools.com/vbscript/default.asp
Notes About Editing VBScript
When calling a Geomagic command that returns a value, the command's parameters must be surrounded by parantheses.
All parameters passed to Geomagic commands must be of correct type (no variant conversion will be done). FOr example, "5" cannot be passed in for an integer parameter. Therefore VBScript subtype conversion functions might be needed (CInt, CDbl, CBool, CStr, etc.) Example:
Dim DecimateTo
DecimateTo = CDbl(geo.text_input("Please enter a decimation value:"))
geo.Decimate_Polygons 1, DecimateTo, DecimateTo, 0.002, 18599, 0, 0, 3, 0, 3, 2, -1, -1, 0, 0
Example of an Enhanced VBScript Macro
The user records a macro that includes the Polygons > Decimate function. Rendered as VBScript, the function is:
geo.Decimate_Polygons 1, 50.0, 50.0, 0.002, 0, 0, 0, 3, 0, 3, 2, -1, -1, 0, 0
Next, the user adds interactivity to the script:
Dim MyReducePercent
MyReducePercent = CDbl(geo.text_input("Enter a decimation percentage:"))
geo.Decimate_Polygons 1, MyReducePercent, MyReducePercent, 0.002, 0, 0, 0,
3, 0, 3, 2, -1, -1, 0, 0
The CDbl function converts the input to a floating-point number, which is required by the geo.Decimate_Polygons function.
Meta Commands
The non-Geomagic scripting languages offer the following special functions:
msg (string text) - outputs a message to the standard output (mainly for debugging)
msg_box (unicode_string msg, int dlg_type = 2) - (available only when the app is running in debug mode) displays a message box (SimpleDlg)
text_input (unicode_string msg = "", unicode_string text = "") - displays an input dialog and returns the text that was entered
meta_list_commands (bool with_params = true) - returns a list of all the registered commands available from the scripting language
query (string queryName, int objectID) - wrapper function for the old query mechanism
A python code sample:
<pre>
cmdList = geo.meta_list_commands()
print "=== ", len(cmdList), " scriptable commands available: ==="
for cmd in cmdList:
print cmd
</pre>