Here's the code I'm using if someone wants to have a play.
void test()
{
AcDbObjectIdArray ids;
char handle[80];
AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
FILE* fp = fopen("C:\\test\\handles.txt","r");
while(fgets(handle,80,fp))
{
ACHAR uStr[80]; // storage for our unicode converted string
size_t origsize = strlen(handle) + 1;
const size_t newsize = 100;
size_t convertedChars = 0;
wchar_t wchandle[newsize];
mbstowcs_s(&convertedChars, wchandle, origsize, handle, _TRUNCATE);
acutPrintf(_T("%s"), wchandle); // <---------works fine.
// get the object id from the name entity:
AcDbObjectId id;
AcDbHandle h = wchandle;
pDb->getAcDbObjectId(id, false, h);
acutPrintf(_T("id: %ld\n"), (long)(AcDbStub*)id);
}
fclose(fp);
}
and I write the handles out to a text file in vba using this -
Public Sub testhandles()
Dim SS1 As AcadSelectionSet
Dim Ent As AcadEntity
Dim i As Integer
Dim FilterType1(0 To 0) As Integer
Dim FilterData1(0 To 0) As Variant
FilterType1(0) = 0
FilterData1(0) = "3DSOLID"
Set SS1 = vbdPowerSet("SS1") 'let me know if you need this.
SS1.SelectOnScreen FilterType1, FilterData1
Dim file As String
Dim fileno As Integer
fileno = FreeFile
Open "C:\test\handles.txt" For Output As #fileno
If SS1.Count <> 0 Then
For Each Ent In SS1
Print #fileno, Ent.Handle
Debug.Print Ent.ObjectID
Next
End If
End Sub
just create the directory or change the paths to suit as required.
thanks.