jpg2
Computer
- Oct 26, 2003
- 1
here is a small function to query the name of each block in the current drawing
void CDrvAcad::GetBlockList(CStringList *pList)
{
IAcadBlocksPtr pBlocksCollection = m_acadDoc->GetBlocks();
IAcadBlockPtr pBlock;
_variant_t index;
index.vt = VT_I4;
long count = pBlocksCollection->GetCount();
CString str;
for (int i = 0; i< count; i++)
{
index.lVal = i;
pBlock = pBlocksCollection->Item(index);
str = pBlock->GetName()
}
}
I know that the pBlock is valid, because i can access properties as blockID, blockHandle, ....
but pBlock->GetName() will stop the execution ("access violation". Another strange thing : if i have 2 Autocad applications running at the same time, it works !
void CDrvAcad::GetBlockList(CStringList *pList)
{
IAcadBlocksPtr pBlocksCollection = m_acadDoc->GetBlocks();
IAcadBlockPtr pBlock;
_variant_t index;
index.vt = VT_I4;
long count = pBlocksCollection->GetCount();
CString str;
for (int i = 0; i< count; i++)
{
index.lVal = i;
pBlock = pBlocksCollection->Item(index);
str = pBlock->GetName()
}
}
I know that the pBlock is valid, because i can access properties as blockID, blockHandle, ....
but pBlock->GetName() will stop the execution ("access violation". Another strange thing : if i have 2 Autocad applications running at the same time, it works !