First of all, please post the code as text, not as picture. In the browser you can add code with forum button: </>
With the code i can reproduce the problem.
Next is, i think AcDb::kDxfInt32 will be sb->resval.rlong
Here an example that will work, notice, BeCAD_ItextData is an custom class from my application. It also checks if there is
always an Xrecord on the entity
Sets the Xrecord:
void setItextXrecordData(AcDbText *pText, BeCAD_ItextData *pItextData)
{
AcDbObjectId extDictId = pText->extensionDictionary();
if (extDictId == NULL)
{
pText->createExtensionDictionary();
extDictId = pText->extensionDictionary();
}
AcDbDictionary *pDictionary;
if (acdbOpenObject(pDictionary, extDictId, AcDb::kForWrite) != Acad::eOk)
{
return;
}
AcDbXrecord *pXrecord = NULL;
if (!pDictionary->has(_T("CCNC_Data")))
{
pXrecord = new AcDbXrecord();
AcDbObjectId xRecordId;
pDictionary->setAt(_T("CCNC_Data"), pXrecord, xRecordId);
pDictionary->close();
}
else
{
AcDbObjectId xRecordId;
pDictionary->getAt(_T("CCNC_Data"), xRecordId);
pDictionary->close();
if (acdbOpenObject(pXrecord, xRecordId, AcDb::kForWrite) != Acad::eOk)
{
return;
}
}
if (pXrecord == NULL)
{
return;
}
struct resbuf *prbXtn;
if (pItextData->m_drawSpaceId == AcDbObjectId::kNull)
{
prbXtn = acutBuildList(
AcDb::kDxfInt16, pItextData->m_scale,
AcDb::kDxfInt16, pItextData->m_unit,
AcDb::kDxfReal, pItextData->m_height,
RTNONE);
}
else
{
ads_name ename;
acdbGetAdsName(ename, pItextData->m_drawSpaceId);
prbXtn = acutBuildList(
AcDb::kDxfInt16, pItextData->m_scale,
AcDb::kDxfInt16, pItextData->m_unit,
AcDb::kDxfReal, pItextData->m_height,
AcDb::kDxfSoftPointerId, ename,
RTNONE);
}
pXrecord->setFromRbChain(*prbXtn);
pXrecord->close();
ads_relrb(prbXtn);
}
Reads the Xrecord:
bool getItextXrecordData(AcDbText *pText, BeCAD_ItextData *pItextData)
{
AcDbObjectId extDictId = pText->extensionDictionary();
AcDbDictionary *pDictionary;
if (acdbOpenObject(pDictionary, extDictId, AcDb::kForRead) != Acad::eOk)
{
return false;
}
AcDbObjectId xRecordId;
pDictionary->getAt(_T("CCNC_Data"), xRecordId);
pDictionary->close();
AcDbXrecord *pXrecord;
if (acdbOpenObject(pXrecord, xRecordId, AcDb::kForRead) != Acad::eOk)
{
return false;
}
struct resbuf *prbXtn;
pXrecord->rbChain(&prbXtn);
pXrecord->close();
struct resbuf *pTemp;
pTemp = prbXtn;
pItextData->m_scale = pTemp->resval.rint;
pTemp = pTemp->rbnext;
pItextData->m_unit = pTemp->resval.rint;
pTemp = pTemp->rbnext;
pItextData->m_height = pTemp->resval.rreal;
pTemp = pTemp->rbnext;
if (pTemp != NULL)
{
ads_name ename;
memcpy(ename, pTemp->resval.rlname, sizeof(ads_name));
acdbGetObjectId(pItextData->m_drawSpaceId, ename);
}
else
{
pItextData->m_drawSpaceId = AcDbObjectId::kNull;
}
ads_relrb(prbXtn);
return true;
}