Hi,
I am using below code in my application.
This works fine in 64-bit application, but when i am trying to use in 32-bit application i am receiving "Unhandled exception at 0x00000000 in acad.exe: 0xC0000005: Access violation reading location 0x00000000.", in
acdbOpenObject(pBlockDef, objBlock, AcDb::kForRead);
Can anyone help me in solving this issue.
*****************************************************Code Used*************************************************************
BOOL insertBlock(CString csBlockName, CString csLayerName, ads_point ptIns, double dScale, double dHeight, double dRotation, CString csTextStyle, AcDbObjectId& objInsert, BOOL bIsMSpace)
{
AcDbObjectId objBlock;
if (ensureSymbolAvailability(csBlockName, objBlock) == FALSE) { return FALSE; }
// Convert the insertion base point
AcGePoint3d geBasePoint(ptIns[X], ptIns[Y], ptIns[Z]);
// Create a new block reference object
AcDbBlockReference *pInsert = new AcDbBlockReference;
pInsert->setBlockTableRecord(objBlock);
pInsert->setPosition(geBasePoint);
pInsert->setNormal(AcGeVector3d(0, 0, 1));
pInsert->setRotation(dRotation);
pInsert->setScaleFactors(AcGeScale3d(dScale, dScale, dScale));
pInsert->setLayer(csLayerName);
// Add this entity to the current drawing
// NOTE: This will create the block reference without any attributes in it
objInsert = appendEntityToDatabase(pInsert, bIsMSpace);
// Open the block definition for read
AcDbBlockTableRecord *pBlockDef; acdbOpenObject(pBlockDef, objBlock, AcDb::kForRead);
AcDbBlockTableRecordIterator *pIterator; pBlockDef->newIterator(pIterator);
AcDbEntity *pEnt;
AcDbAttributeDefinition *pAttdef;
// For each entity in the block
for (pIterator->start(); !pIterator->done(); pIterator->step())
{
}
}
*********************************************************************************************************************************
Thanks,
Chockalingam
Solved! Go to Solution.
Solved by chockalingam. Go to Solution.
Maybe a guess.. (?) do you use AcDbObjectId::setFromOldId() somewhere?
Hi loic.jourdan,
Thanks for your reply
But i am not using setFromOldId() in my code
does your object id looks well formed? I mean can you call objBlock.database(), objBlock.objectClass().... I've seen some cases where the object id was corrupted, In my case, it was due to a call of setFromOldId but it may occurs in other cases (?)
Is ensureSymbolAvailability doing something special?
Sorry if it doesn' t help
loic
Hi,
After checking the error status for every line of the code, i found another issue
pInsert->setBlockTableRecord(objBlock);
results "enotimplemented" error.
Can anyone help me in solving this issue.
Thanks,
Chockalingam
It just looks to me that your objBlock object id is not valid, have you inspected your ensureSymbolAvailability function?
Are you sure, that you are linking the right librarys for the Acad funcitonalitys?
There is a set of librarys for the 64 bit Version and another set for the 32 bit version... seems to me, that you link your 32bit Version also with the 64bit librarys.
So it crashes on a 32bit system but works fine with a 64bit system.
Hi,
in my mind, this is not a library issue, the arx app wouldn't event build (if project target is x64 linked to 32 bits libraries: link error) nor load (if project target is x64 linked to 64 bits libraries: a 64b app cannot be loaded in acad 32)
Hi,
Thanks for all your efforts, finally i found the solution.
I just changed
AcDbBlockReference *pInsert = new AcDbBlockReference;
to
AcDbBlockReference *pInsert = new AcDbBlockReference(geBasePoint,objBlock);
this solves the error.
I don't know whats the reason for the error, but i get the error resolved and my code works fine now.
Ioic.jourdan and matti72, thanks for your efforts to solve my error
Thanks,
Chockalingam.