ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error while modify data of objects store in NOD

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
tuankm01
550 Views, 3 Replies

Error while modify data of objects store in NOD

Hello,

I make an object to store some general information in the NOD. Everything seem fine, object created, store in the NOD and I can get information store in that. The problem happen when I want to modify the data in the store object. Whenever I start to modify data it alway return error say that "INTERNAL ERROR: !dbobji.cpp@7171: eNotOpenForWrite"  when ever run to the redline.

Please help.

Thanks,

 

void DlgLandType::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if ((m_Name.GetLength()<1)) {
MessageBox(_T("Input Name of Land Type"),_T("Error"),0);
return;
}
AcDbObjectId objId = NULL;
AcDbDictionary *pNamedobj = NULL;
AcDbDictionary *pDict = NULL;
KMTLANDTYPE *pObj=NULL;
//KMTArxUtils_GetDictionaryObjectId(objId,m_Name.GetBuffer(),_T("KMT_LAND_TYPES")); //if exist open if not create, return objId
//m_Name.ReleaseBuffer();

acdbHostApplicationServices()->workingDatabase()->
getNamedObjectsDictionary(pNamedobj, AcDb::kForRead);
if (pNamedobj->getAt(_T("KMT_LAND_TYPES"), (AcDbObject*&) pDict, AcDb::kForWrite) == Acad::eKeyNotFound) {
pNamedobj->upgradeOpen();
pDict = new AcDbDictionary;
AcDbObjectId DictId;
pNamedobj->setAt(_T("KMT_LAND_TYPES"), pDict, DictId);
pNamedobj->close();
pDict->close();
}
else{
pNamedobj->close();
AcDbDictionaryIterator* pDictIter= pDict->newIterator();
CString val;
for (; !pDictIter->done(); pDictIter->next()) {
//pDictIter->getObject((AcDbObject*&)pObj,AcDb::kForRead);
acdbOpenObject((AcDbObject*&)pObj,pDictIter->objectId(),AcDb::kForRead);
if ((pObj!=NULL)&&(0==(pObj->getName().CompareNoCase(m_Name)))){
objId=pObj->objectId();
//pObj->close();
break;
}
else {
if (pObj!=NULL) {
pObj->close();
}
}
}
delete pDictIter;
}

if (pDict) {
pDict->setTreatElementsAsHard(true);

if (objId == NULL){
pObj = new KMTLANDTYPE();
}
else
pObj->upgradeOpen();          //acdbOpenObject((AcDbObject*&)pObj,objId,AcDb::kForWrite );
pObj->setName(m_Name);   <- Error happen here.  
pObj->setFunction(m_Function);
pObj->setObjectColor(m_Color);
pObj->setLayerIdByName(m_LayerName);
pObj->setHatchName(m_HatchName);
pObj->setHatchScale(m_HatchScale);
pObj->setHatchColor(m_HatchColor);
pObj->setHatchRotation(m_HatchRotation*PI/180);
pObj->setPowerConsumption(m_PowerConsumption);
pObj->setPowerConsumption2(m_PowerConsumption2);
pObj->setWaterConsumption(m_WaterConsumption);
pObj->setWaterConsumption2(m_WaterConsumption2);
pObj->setPowerSupplyByBuilding(m_PowerSupplyByBuilding==TRUE ? true : false);
pObj->setWaterSupplyByBuilding(m_WaterSupplyByBuilding==TRUE ? true : false);
pObj->setGroupId(m_GroupId);

AcDbObjectId rId;
if (objId == NULL){
pDict->setAt(m_Name, pObj, rId);
}
pObj->close();
pDict->close();
if (cb_Name.FindString(0,m_Name.MakeUpper().Trim())<0)
cb_Name.AddString(m_Name);
}
UpdateData(FALSE);
//OnOK();
}

Kieu Minh Tuan
------------------------------------
DCL & LSP Generator Tools
https://sites.google.com/site/dclgen/
dclgenerator@gmail.com
3 REPLIES 3
Message 2 of 4
owenwengerd
in reply to: tuankm01

It looks like you intended your "else" statement to have a longer scope than just one line. Or maybe you just need to check the return value of upgradeOpen()?

--
Owen Wengerd
ManuSoft
Message 3 of 4
tuankm01
in reply to: owenwengerd

Thanks Owen, I check the return value of UpgradeOpen() and get eHadMultipleReaders. Please help.

 

Kieu Minh Tuan
------------------------------------
DCL & LSP Generator Tools
https://sites.google.com/site/dclgen/
dclgenerator@gmail.com
Message 4 of 4
tuankm01
in reply to: tuankm01

Dear Owen,

Since the result from UpgradeOpen(), I have check all the code from other fuction and found in one place, my object was open but I forgotten to close.

Thank you very much of the sugeestion for the checking return value from the object function calling,

Regards,

Kieu Minh Tuan
------------------------------------
DCL & LSP Generator Tools
https://sites.google.com/site/dclgen/
dclgenerator@gmail.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost