Sending Messages from an Embedded Custom Interface

 
 
 

The HTML syntax for creating hyperlinks (the href tag) can be used to send Showcase messages. Instead of using the "http:" protocol, messages are sent using the custom "autodesk:" protocol. For example:

  <a href="autodesk:MESSAGE_NAME:MESSAGE_DATA">Send Message</a>

MESSAGE_DATA is first evaluated as a Python expression. If it fails, then the MESSAGE_DATA is parsed as three parameters separated by commas: msg_param1,msg_param2,msg_param3. Lists and tuples can be stated using brackets.

Quotation marks in message data result in a string being double quoted as all data elements are converted using the Python Utilities.ConvertData function. So:

"data1,(data2,data3)" is parsed as 'data1',('data2','data3')

"'data1',('data2','data3')" is also parsed as 'data1',('data2','data3') because it is correct Python syntax.

Only one message can be sent using the href syntax shown above. To send multiple messages you can use the onClick event as follows:

<a href="#" onClick=
   "document.location = 'autodesk:MESSAGE1:param1,param2';
    document.location = 'autodesk:MESSAGE2:param1,param2';
    document.location = 'autodesk:MESSAGE3:param1,param2';">
        Click me to send three messages.
</a>

This demonstrates how JavaScript can be used to send messages.

To nest tuples in the message data use the following syntax:

  MESSAGE_NAME:(data1,(data11,data12,data13),data2),data,data

To send an empty parameter as the last paramater, include a comma:

  <a href="autodesk:MESSAGE_NAME:,">Empty</a>

Example 1: Switching to Wireframe Mode

The following message switches the draw mode to Wireframe when the user clicks the "Wireframe" link.

  <a href="autodesk:SET_DRAW_MODE:WIREFRAME">Wireframe</a>

Example 2: Saving a Screenshot

The following message saves a screenshot as C:\Showcase.rgb with an anti-aliasing value of 3 when the user clicks the Save link.

 <a href="autodesk:SAVE_SCREENSHOT:C:\Showcase.rgb,3,False">Save Screenshot</a>

Example 3: Set to Wireframe and Show Normals

The following message switches the draw mode to wireframe and shows normals.

<a href="#" onClick=
   "document.location = 'autodesk:SET_DRAW_MODE:WIREFRAME';
    document.location = 'autodesk:GEOMETRY_SHOW_NORMALS:true';">
        Set to wireframe and show normals
</a>

Example 4: Display a Dialog

Displays a dialog with the default title (product name), the specified message, and the default button (OK) when the user clicks the "Confirm" link.

  <a href="autodesk:UI_CONFIRM_DIALOG:,This is a dialog. Click OK to continue.,,">Confirm</a>