Using the CopyCAD OLE ServerThis page shows what interfaces are available via the CopyCAD OLE server.
Creating a new CopyCAD object
This will create a new CopyCAD session, linked to the object 'copycad'. Set copycad = Createobject ("Copycad.Document")
When you quit the VB application, although the object is destroyed, CopyCAD is not closed down.
Connecting to an existing CopyCAD session
This method will connect the object 'copycad' to an existing CopyCAD session. Set copycad = Getobject(,"Copycad.Document")
With this method, when you quit the VB application, the CopyCAD session remains open.
Displaying the CopyCAD window
You can show or hide the CopyCAD window, using the server interface:
To show the CopyCAD window:
To hide the CopyCAD window: copycad.Visible = True
copycad.Visible = False
Controlling the CopyCAD window
You can minimise/maximise/normalised and bring to foreground the CopyCAD window, using the server interface:
To nomalise the CopyCAD window:
copycad.windowstate = 1
To maximise the CopyCAD window:
copycad..windowstate = 2
To mimimise the CopyCAD window:
copycad.windowstate = 4
To bring the CopyCAD window to foreground:
copycad.windowstate = 8
Getting the current CopyCAD version
This can be used to check if a connection is made to CopyCAD. 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 copycad.Version
Sending commands to CopyCAD
Similar to a user typing in the command window, you can send a command to CopyCAD with the server interface:
Where 'command' is a string containing the command copycad.Execute command_string, error_flag
And 'error_flag' is a LONG variable, and is an error flag which is only set if there is an internal error within CopyCAD. It is required to use the command, but its value can normally be ignored.
copycad.Execute "DRAW ALL", error e.g.
You can also send commands to CopyCAD, and extract the resulting message from the command window, using the interface:
copycad.ExecuteEx command_string, error_flag, messages_string
Where 'command' and 'error_flag' are similar to using the 'Execute' method,
And 'messages_string' is a string variable, in which the command window output will be placed.
e.g.
copycad.ExecuteEx "SIZE COMPONENTS",error, size
The string variable 'size' will contain the command window message.
Quiting CopyCAD
To quit CopyCAD via the interface, use the command:
copycad.exit