Handling ObjectId
 
 
 

Beginning with AutoCAD 2008 64-bit, object IDs are represented by a 64-bit integer datatype (__int64). Accessing these values in 32-bit VBA will result in a compilation error. As a resolution, a new set of method names suffixed with “32” corresponding to the old methods are used (e.g. ObjectID32(), OwnerID32()). These methods use the LONG datatype, which internally maps to the 64-bit integer datatype.

To be more precise, a 32-bit object ID is created internally for each object ID required in VBA. This ID is mapped to its 64-bit actual ID, so that if the 32-bit ID is passed back to AutoCAD from VBA code, then the 64-bit object ID is returned and used internally for all purposes.

The following sample gives an example of ported 32-bit Object ID code:

Original code:

Dim splineObj As AcadSpline
Dim objectID As Long
objectID = splineObj.objectID
Dim tempObj As AcadObject
Set tempObj = ThisDrawing.ObjectIdToObject(objectID)

Code ported for 64-bit compatibility:

Dim splineObj As AcadSpline
Dim objectID As Long
objectID = splineObj.objectID32
Dim tempObj As AcadObject
Set tempObj = ThisDrawing.ObjectIdToObject32(objectID)

VBA applications can also use an object’s handle instead of its object ID. The following sample shows how to use the handle instead of the object ID:

Original code:

Dim splineObj As AcadSpline
Dim objectID As Long
objectID = splineObj.objectID
Dim tempObj As AcadObject
Set tempObj = ThisDrawing.ObjectIdToObject(objectID)

Code ported for 64-bit compatibility:

Dim splineObj As AcadSpline
Dim objectHandle As String
objectHandle = splineObj.Handle
Dim tempObj As AcadObject
Set tempObj = ThisDrawing.HandleToObject(objectHandle)
Note: Support for VBA will be deprecated in future versions of AutoCAD. VBA developers should prepare to port their VBA code to VB.Net.