Adding XData

Adding XData

Anonymous
Not applicable
1,472 Views
5 Replies
Message 1 of 6

Adding XData

Anonymous
Not applicable
I am trying to add xdata to objects... however, I keep getting
eRegappIdNotFound.

Could this be because when I am calling
res=acdbRegApp(appname);
That it is in the wrong document's context? I tought I switched to the
correct context via:
AcAxDocLock docLock(pDbNew,AcAxDocLock.DocLockType::kCurDocSwitch);

res from above is RTNORM, but when I call setXData (below), I am getting
eRegappIdNotFound

void appendXData(AcDbEntity* pEnt)
{
AcDbHandle handEnt;
pEnt->getAcDbHandle(handEnt);
char strHandle[17];
Acad::ErrorStatus es;
handEnt.getIntoAsciiBuffer(strHandle);

resbuf* prbX;

prbX=acutBuildList(AcDb::kDxfRegAppName, appname,
AcDb::kDxfXdAsciiString, someString,
RTNONE);

es=pEnt->setXData(prbX);
if(es==Acad::eRegappIdNotFound)
{
acutPrintf("/");
}
else
{
acutPrintf("+");
}
acutRelRb(prbX);
}
0 Likes
1,473 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Nevermind.. I manually added to the RegAppTable.


"Martin Schmid" wrote in message
news:[email protected]...
> I am trying to add xdata to objects... however, I keep getting
> eRegappIdNotFound.
>
> Could this be because when I am calling
> res=acdbRegApp(appname);
> That it is in the wrong document's context? I tought I switched to the
> correct context via:
> AcAxDocLock docLock(pDbNew,AcAxDocLock.DocLockType::kCurDocSwitch);
>
> res from above is RTNORM, but when I call setXData (below), I am getting
> eRegappIdNotFound
>
> void appendXData(AcDbEntity* pEnt)
> {
> AcDbHandle handEnt;
> pEnt->getAcDbHandle(handEnt);
> char strHandle[17];
> Acad::ErrorStatus es;
> handEnt.getIntoAsciiBuffer(strHandle);
>
> resbuf* prbX;
>
> prbX=acutBuildList(AcDb::kDxfRegAppName, appname,
> AcDb::kDxfXdAsciiString, someString,
> RTNONE);
>
> es=pEnt->setXData(prbX);
> if(es==Acad::eRegappIdNotFound)
> {
> acutPrintf("/");
> }
> else
> {
> acutPrintf("+");
> }
> acutRelRb(prbX);
> }
>
>
0 Likes
Message 3 of 6

Anonymous
Not applicable
Hi Schmid,

I ran into the same problem with you, glad to see that you had found the way out. Would you mind telling me what do you mean by "manually added to the RegAppTable" ?

Horace
0 Likes
Message 4 of 6

Anonymous
Not applicable
Hi, Horace! You wrote : H> Would you mind telling me what do you mean by "manually H> added to the RegAppTable" ? void RegisterAppName(void) { resbuf *pArgs = acedGetArgs () ; char *appname = NULL; acedRetNil(); // Return error flag if (pArgs->restype == RTSTR) { appname = pArgs->resval.rstring; AcDbRegAppTable *pRegAppTable = NULL; acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pRegAppTable, AcDb::kForRead); if (pRegAppTable) { if (!pRegAppTable->has(appname)) { AcDbRegAppTableRecord *pRegAppTableRecord = new AcDbRegAppTableRecord(); pRegAppTableRecord->setName(appname); pRegAppTable->upgradeOpen(); pRegAppTable->add(pRegAppTableRecord); pRegAppTableRecord->close(); acedRetStr(appname); // If We add appname } else { acedRetStr(""); // If already exist appname } pRegAppTable->close(); return; } } } Best Regards, Alexander Rivilis.
0 Likes
Message 5 of 6

Anonymous
Not applicable
Hi Alexander,

Interesting code, how do you use it, like this ?

acdbRegApp("testapp");
RegisterAppName();

Horace

PS. it fails when I do so
0 Likes
Message 6 of 6

Anonymous
Not applicable
Hi, Horace! You wrote : H> Hi Alexander, H> H> Interesting code, how do you use it, like this ? H> H> acdbRegApp("testapp"); H> RegisterAppName(); H> H> Horace H> H> PS. it fails when I do so It's a function, that may be called from LISP: RegisterApp("testapp"). You can modify it for calling from C++: int RegisterAppName(char *appname) { int ret = -1; // error code AcDbRegAppTable *pRegAppTable = NULL; acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pRegAppTable, AcDb::kForRead); if (pRegAppTable) { if (!pRegAppTable->has(appname)) { AcDbRegAppTableRecord *pRegAppTableRecord = new AcDbRegAppTableRecord(); pRegAppTableRecord->setName(appname); pRegAppTable->upgradeOpen(); pRegAppTable->add(pRegAppTableRecord); pRegAppTableRecord->close(); ret = 1; // if added } else { ret = 0; // If already exist appname } pRegAppTable->close(); } } retuen ret; } Use RegisterAppName("testapp") instead of acdbRegApp("testapp") Best Regards, Alexander Rivilis.
0 Likes