ObjectARX

Reply
Active Member
Posts: 10
Registered: ‎09-05-2007
Message 1 of 4 (154 Views)
Accepted Solution

Error while modify data of objects store in NOD

154 Views, 3 Replies
08-15-2013 04:07 AM

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::smileysurprised:nBnClickedOk()
{
// 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
Valued Mentor
owenwengerd
Posts: 498
Registered: ‎08-06-2002
Message 2 of 4 (141 Views)

Re: Error while modify data of objects store in NOD

08-15-2013 07:57 AM 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
Active Member
Posts: 10
Registered: ‎09-05-2007
Message 3 of 4 (126 Views)

Re: Error while modify data of objects store in NOD

08-15-2013 06:34 PM 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
Active Member
Posts: 10
Registered: ‎09-05-2007
Message 4 of 4 (120 Views)

Re: Error while modify data of objects store in NOD

08-15-2013 07:35 PM 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community