本文整理汇总了C++中AcDbObject::xData方法的典型用法代码示例。如果您正苦于以下问题:C++ AcDbObject::xData方法的具体用法?C++ AcDbObject::xData怎么用?C++ AcDbObject::xData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AcDbObject
的用法示例。
在下文中一共展示了AcDbObject::xData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: printXData
void printXData()
{
// 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 the application name for the xdata.
//
TCHAR appname[133] = {0};
if (acedGetString(NULL, _T("\nEnter the Xdata application name: "), appname) != RTNORM)
{
return;
}
// Get the xdata for the application name.
//
resbuf *pRb = pObj->xData(appname);
if (pRb != NULL)
{
printXDList(pRb);
acutRelRb(pRb);
}
else
{
acutPrintf(_T("\nNo xdata for appname: %s."), appname);
}
pObj->close();
}
示例3: printXData
bool printXData()
{
CLogger::Print(_T("*Call: printxData()"));
AcDbObject* pObj;
//------------
// Require to select an entity
if (!(pObj = selectObject(AcDb::kForRead))) {
CLogger::Print(_T("*Exit: printxData() - Object have not selected."));
return false;
}
//------------
// Require to enter xData application name
ACHAR appname[133];
if (RTNORM != acedGetString(NULL, ACRX_T("\nEnter the desired Xdata application name: "), appname))
{
CLogger::Print(_T("*Exit: printxData() - Fail to enter the application name!"));
return false;
}
//------------
// Read the xData that contained in object.
// If application name is existing then print out its values.
struct resbuf* pRb;
pRb = pObj->xData(appname);
pObj->close();
if (pRb) {
acutPrintf(ACRX_T("Inform: Application name '%s' is existing - The values are: "), appname);
printList(pRb);
acutRelRb(pRb); // release xData after using!
} else {
acutPrintf(ACRX_T("\n*Exit: printxData() - Application name '%s' is not existing."), appname);
pObj->close();
return false;
}
pObj->close();
CLogger::Print(_T("*Exit: printxData()"));
return true;
}
示例4: printList
// This function calls the
// selectObject() function to allow the user to pick an
// object; then it accesses the xdata of the object and
// sends the list to the printList() function that lists the
// restype and resval values.
//
void
printXdata()
{
// Select and open an object.
//
AcDbObject *pObj;
if ((pObj = selectObject(AcDb::kForRead)) == NULL) {
return;
}
// Get the application name for the xdata.
//
TCHAR appname[133];
if (acedGetString(NULL,
_T("\nEnter the desired Xdata application name: "),
appname) != RTNORM)
{
return;
}
// Get the xdata for the application name.
//
struct resbuf *pRb;
pRb = pObj->xData(appname);
if (pRb != NULL) {
// Print the existing xdata if any is present.
// Notice that there is no -3 group, as there is in
// LISP. This is ONLY the xdata, so
// the -3 xdata-start marker isn't needed.
//
printList(pRb);
acutRelRb(pRb);
} else {
acutPrintf(_T("\nNo xdata for this appname"));
}
pObj->close();
}
示例5: 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);
}
示例6: 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;
}