Macros



Your Ad Here

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

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

  1. When calling a Geomagic command that returns a value, the command's parameters must be surrounded by parantheses.

  2. 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:

A python code sample:

<pre>

cmdList = geo.meta_list_commands()

print "=== ", len(cmdList), " scriptable commands available: ==="

for cmd in cmdList:

print cmd

</pre>

Return to Geomagic Index


Your Ad Here