OLE Automation capability is provided in MAXScript that allows 3ds Max to act as an OLE Automation server for applications such as Visual Basic, Excel, Paradox, etc. With it, you can publish MAXScript functions that can then be called from OLE Automation clients like VB and Excel to generate models or animations or return data from the current scene, etc. There is an example supplied in the script samples that defines a set of simple business graphing MAXScript functions and an Excel spreadsheet with some Excel VB-scripted menus that will pass a selection of cells across to these MAXScript functions to generate an animated bar chart.
This facility has the following features and limitations:
It exposes a single server object to which you can attach a list of MAXScript functions that then appear as the methods of that object to an OLE Automation client. Future releases will allow you to construct any number of OLE Automation objects and give them any number of interfaces.
It is registered as a separate process, local server supporting multiple use of its exposed object.
It does not support in-place activation or object linking and embedding and provides no containers for other OLE objects. In future versions, you will be able to pass rendered images and animations to OLE clients for direct linking and embedding.
It supports only the IDispatch form of interface with no accessible type information -- clients need to declare their reference to the 3ds Max server object as an untyped generic object.
It supports the following method argument and result data types:
empty (an empty spreadsheet cell, for example)
the equivalent MAXScript value for empty is undefined
OLE Objects (interfaces)
You need to have 3ds Max running and MAXScript activated before OLE Clients can access 3ds Max. MAXScript is activated (and the startup.ms script run) when you first access its Utility panel rollout. Alternatively, you can use launch script facilities described in Running Scripts from the Command Line to establish an OLE server interface as soon as 3ds Max runs.
You need to have registered 3ds Max with Windows as an OLE server using the registration script supplied with this release. See the instructions in Setting Up MAXScript OLE Automation for details.
With the MAXScript OLE Automation Client system, you can use MAXScript to create OLE Automation (now called Active-X) objects within 3ds Max and control the associated OLE Automation Servers servers with MAXScript, such as making an Excel spreadsheet and inserting 3ds Max object information directly into cells there.
is used for establishing a connection to OLE Auto Servers. The return value of createOLEObject() is an instance of the OLEObject class.
xl = createOLEObject "Excel.Sheet"
opens a connection to Excel and creates a sheet object and puts it in the variable xl. The single argument to this function is an OLE progID string. You can then access properties and call methods on the new OLE object.
xl.application.visible = true
will make Excel visible on the desktop. You get properties on OLE objects with the dot '.' notation, just as you do in MAXScript. You also refer to OLE object methods as properties of the OLE object. For example, the Sheet has a method 'cells' which takes a cell coordinate and returns a Cell OLE object.
xlc = xl.application.cells 1 1
puts the top-left-hand cell into xlc. Set its value like this:
xlc.value = 123.45
The server application that was attached with createOLEObject() is released and terminated when the created MAXScript OLE object is eventually garbage-collected. You can explicitly disconnect from an OLE server application with the releaseOLEObject() function.
The form is:
The OLE object becomes disabled once releaseOLEObject() has been called on it and further attempts to use it results in a descriptive error message.
You can explicitly disconnect from all active OLE server applications with the releaseAllOLEObjects() function.
Its form is:
After calling this function, all existing OLE objects become disabled and any attempt to use them further will generate a runtime error.