Hi!,
I’m migrating the tools I coded some time ago to connect SAP2000 V16 with GH to V17 version. CSi has changed the way the API is used and I cannot figure out how to make it work.
In the help file (with a VB example) the say:
The first step in using the CSi API from an external application is to reference SAP2000v17.DLL or SAP2000v17.TLB from your application. If using Excel VBA, reference SAP2000v17.TLB by opening the VBA editor, clicking the Tools menu > References command and selecting SAP2000v17.TLB from the program installation folder.
Next, within your application, you will create a variable of interface type cOAPI, and an instance of the Sap2000 object which implements cOAPI. In VBA this could be accomplished as:
Dim mySapObject As Sap2000v17.cOAPI
Set mySapObject = CreateObject(“CSI.SAP2000.API.SapObject”)
The first line creates the interface variable and the second line creates the instance of the Sap2000 object which implements the interface. Now that an instance of the Sap2000 object has been created in your application, start SAP2000 using the following VBA command:
SapObject.ApplicationStart
My translation to Python:
import clr
clr.AddReference(‘SAP2000v17.dll’)
import SAP2000v17 as sap
sapObj = sap.cOAPI()
SapObj.ApplicationStart(6)
Python says:
Runtime error (TypeErrorException): Cannot create instances of cOAPI because it is abstract
Traceback:
line 7, in script
This error refers to line 7: “sapObj = sap.cOAPI()”
Anyone knows where is my mistake? I’m noticing that I’m making something wrong creating the variable interface and the sap2000 object instance.
I’ve tried with:
sapObj = sap.cOAPI
setattr(sapObj,‘SetAsActiveObject’,True)
but I get:
Runtime error (MissingMemberException): attribute ‘SetAsActiveObject’ of ‘cOAPI’ object is read-only
It seams that I cannot create a proper instance of the Sap2000 object.
Thanks in advance.