Using the PowerSHAPE OLE Server

This page shows what interfaces are available via the PowerSHAPE OLE server.

Back to main index
 
 

Connecting to an existing PowerSHAPE session

Set pshape = Getobject(,"PowerSHAPE.Application")

This method will create the object 'pshape', which is connected to an existing PowerSHAPE session.

With this method, when you quit the VB application, the PowerSHAPE session remains open.
 
 

Displaying the PowerSHAPE window

You can show or hide the PowerSHAPE window, using the server interface:

To show the PowerSHAPE window:

pshape.Visible = True

To hide the PowerSHAPE window:

pshape.Visible = False
 
 

Controlling the PowerSHAPE window

You can minimise/maximise/normalised and bring to foreground the PowerSHAPE window, using the server interface:

To nomalise the PowerSHAPE window:

pshape.windowstate = 1

To maximise the PowerSHAPE window:

pshape.windowstate = 2

To mimimise the PowerSHAPE window:

pshape.windowstate = 4

To bring the PowerSHAPE window to foreground:

pshape.windowstate = 8
 
 

Getting the current PowerSHAPE version

This can be used to check if a connection is made to PowerSHAPE. If the returned version is 0, or an error is generated, then no connection exists.

To extract the version number use the server interface:

Debug.Print pshape.Version
 
 

Sending commands to PowerSHAPE

Similar to a user typing in the command window, or using macro commands, you can send a command to PowerSHAPE with the server interface:

pshape.Execute command_string, error_flag

Where 'command_string' is a string containing the command

And 'error_flag' is a LONG variable, and is an error flag which is only set if there is an internal error within PowerSHAPE. It is required to use the command, but its value can normally be ignored.

e.g.

pshape.Execute "SELECT CLEARLIST", error
 
 

Getting values from PowerSHAPE

Anything you can print the value of in PowerSHAPE, you can extract the value via the OLE server. The server will return a VARIANT variable, which means the result can be either a number, and string, or even a vector (or array of numbers).

To use the print method, the syntax is:

Dim V as Variant

V = pshape.Print (value_string)

When value_string is a string containing the object you require the information on

So for example, to extract the number of selected entities, you could use:

V = pshape.Print ("selection.number")

Checking if PowerSHAPE is busy

The BUSY property of the PowerSHAPE server lets you know if PowerSHAPE is working. You can use this to check if PowerSHAPE is busy before sending certain commands. The BUSY property will be either TRUE or FALSE.

For example, you could do the check:

If pshape.Busy = False then

Pshape.execute…………etc.

End if

Showing/Hiding Forms when Executing Commands

To access certain functions, such as changing a surface's name, you need to raise the Surface Modify form. When using the OLE server however, you normally do not want to see the form, only to access the functions within it. By default, the forms are hidden, but you can control this via the ShowForms property.

So to show forms when sending OLE commands, you can use:

Pshape.ShowForms = True

And to hide forms when sending OLE commands (this is the default), you can use:

Pshape.ShowForms = False

Quiting PowerSHAPE

To quit PowerSHAPE via the interface, use the command:

pshape.exit