本文整理汇总了C++中AcDbObject::upgradeOpen方法的典型用法代码示例。如果您正苦于以下问题:C++ AcDbObject::upgradeOpen方法的具体用法?C++ AcDbObject::upgradeOpen怎么用?C++ AcDbObject::upgradeOpen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AcDbObject
的用法示例。
在下文中一共展示了AcDbObject::upgradeOpen方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addXData
void addXData()
{
// Get an Entity.
ads_name mnEnt;
ads_point ptSel;
int nRet = acedEntSel(_T("\nSelect an Entity: "), mnEnt, ptSel);
if (nRet != RTNORM)
return;
AcDbObjectId oid;
Acad::ErrorStatus retStat;
retStat = acdbGetObjectId(oid, mnEnt);
if (retStat != Acad::eOk)
return;
AcDbObject* pObj = NULL;
if ((retStat = acdbOpenObject(pObj, oid, AcDb::kForRead)) != Acad::eOk)
{
return;
}
// Get new XData.
TCHAR appName[132] = {0};
TCHAR resString[200] = {0};
acedGetString(NULL, _T("\nEnter application name: "), appName);
acedGetString(NULL, _T("\nEnter string to be added: "), resString);
// XData
resbuf *pRb = NULL;
resbuf *pTemp = NULL;
pRb = pObj->xData(appName);
if (pRb != NULL)
{
for (pTemp = pRb; pTemp->rbnext != NULL; pTemp = pTemp->rbnext);
}
else
{
acdbRegApp(appName);
pRb = acutNewRb(AcDb::kDxfRegAppName);
pTemp = pRb;
pTemp->resval.rstring = (TCHAR*)malloc((_tcslen(appName) + 1) * sizeof(TCHAR));
_tcscpy(pTemp->resval.rstring, appName);
}
pTemp->rbnext = acutNewRb(AcDb::kDxfXdAsciiString);
pTemp = pTemp->rbnext;
pTemp->resval.rstring = (TCHAR*)malloc((_tcslen(resString) + 1) * sizeof(TCHAR));
_tcscpy(pTemp->resval.rstring, resString);
// Set XData.
pObj->upgradeOpen();
pObj->setXData(pRb);
pObj->close();
acutRelRb(pRb);
}
示例2: selectObject
void
addXdata()
{
AcDbObject* pObj = selectObject(AcDb::kForRead);
if (!pObj) {
acutPrintf(_T("Error selecting object\n"));
return;
}
// Get the application name and string to be added to
// xdata.
//
TCHAR appName[132], resString[200];
appName[0] = resString[0] = _T('\0');
acedGetString(NULL, _T("Enter application name: "),
appName);
acedGetString(NULL, _T("Enter string to be added: "),
resString);
struct resbuf *pRb, *pTemp;
pRb = pObj->xData(appName);
if (pRb != NULL) {
// If xdata is present, then walk to the
// end of the list.
//
for (pTemp = pRb; pTemp->rbnext != NULL;
pTemp = pTemp->rbnext)
{ ; }
} else {
// If xdata is not present, register the application
// and add appName to the first resbuf in the list.
// Notice that there is no -3 group as there is in
// AutoLISP. This is ONLY the xdata so
// the -3 xdata-start marker isn't needed.
//
acdbRegApp(appName);
pRb = acutNewRb(AcDb::kDxfRegAppName);
pTemp = pRb;
const size_t nSize = _tcslen(appName) + 1;
pTemp->resval.rstring
= (TCHAR*) malloc(nSize * sizeof(TCHAR));
errno_t err = _tcscpy_s(pTemp->resval.rstring, nSize, appName);
assert(err == 0);
}
// Add user-specified string to the xdata.
//
pTemp->rbnext = acutNewRb(AcDb::kDxfXdAsciiString);
pTemp = pTemp->rbnext;
const size_t nSize = _tcslen(resString) + 1;
pTemp->resval.rstring
= (TCHAR*) malloc(nSize * sizeof(TCHAR));
errno_t err = _tcscpy_s(pTemp->resval.rstring, nSize, resString);
assert(err == 0);
// The following code shows the use of upgradeOpen()
// to change the entity from read to write.
//
pObj->upgradeOpen();
pObj->setXData(pRb);
pObj->close();
acutRelRb(pRb);
}
示例3: addXData
bool addXData()
{
Acad::ErrorStatus es, esTmp;
CLogger::Print(_T("*Call: addXData()"));
//------------
// Require to select an entity.
AcDbObject* pObj = selectObject(AcDb::kForRead);
if (!pObj) {
CLogger::Print(_T("*Exit: addXData() - Khong chon duoc object!"));
return false;
}
//------------
// Require to enter the application name, then require to enter its string value.
ACHAR appName[133], resString[133];
appName[0] = resString[0] = L'\0';
acedGetString(NULL, ACRX_T("\nEnter application name: "), appName);
acedGetString(NULL, ACRX_T("\nEnter string to be added: "), resString);
CLogger::Print(_T("Inform: Found out application name '%s'!"), appName);
struct resbuf * pRb;
struct resbuf * pTemp;
pRb = pObj->xData(appName);
if (pRb) {
// If the appname is existing! Seek to the tail of resbuf link list.
CLogger::Print(_T("Inform: Found out application name '%s' - Seek to the end of resbuf link list."), appName);
for (pTemp = pRb; pTemp->rbnext; pTemp = pTemp->rbnext) {}
} else {
// If the appname is not existing! Register a new application name.
CLogger::Print(_T("Inform: The application name %s is not existing, register this application name!"), appName);
acdbRegApp(appName);
// Then create new resbuf to copy the application name into it.
pRb = acutNewRb(AcDb::kDxfRegAppName);
pTemp = pRb;
pTemp->resval.rstring = (ACHAR*) malloc((lstrlen(appName) + 1) * sizeof(ACHAR));
lstrcpy(pTemp->resval.rstring, appName);
}
//------------
// Create new resbuf at the tail of the link list, then copy the value string into it.
pTemp->rbnext = acutNewRb(AcDb::kDxfXdAsciiString);
pTemp = pTemp->rbnext;
pTemp->resval.rstring = (ACHAR*) malloc((lstrlen(resString) + 1) * sizeof(ACHAR));
lstrcpy(pTemp->resval.rstring, resString);
CLogger::Print(_T("Inform: Upgrade object opening!"));
if (Acad::eOk != (es = pObj->upgradeOpen())) {
CLogger::Print(_T("*Exit: addXData() - Fail to upgrade opening object!"));
pObj->close();
acutRelRb(pRb);
return false;
}
//------------
// Set object's xData.
pObj->setXData(pRb);
pObj->close();
acutRelRb(pRb); // remember to release resbuf after using
CLogger::Print(_T("*Exit: addXData()!"));
return true;
}