Message 1 of 16
wblockCloneObjects
Not applicable
10-31-2005
01:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
In the following code I am trying to clone some objects, from current
database to a temporary one
the code is fails in IdMapping check for the cloned objects
What's is wrong?
void cloneMyObjects()
{
AcDbObjectIdArray ObjIdArr;
AcDbobjectId ObjId;
ads_name ent, ss;
long i, len;
// allocating memory
acedSSGet(NULL, NULL, NULL, NULL, ss);
ObjIdArr.setLogicalLength(0);
acedSSLength(ss, &len);
for (i = 0L; i < len; i++)
{
acedSSName(ss, i, ent);
acdbGetObjectId(ObjId, ent);
ObjIdArr.append(ObjId);
}
acedSSFree(ss); // dispose memory
AcDbDatabase *pTempDb;
AcDbBlockTable *pBlockTable;
AcDbObjectId BlkRecId;
AcDbIdmapping idMap;
// allocating memory, open new database
pTempDb = new AcDbDatabase(true);
// allocating memory, open block table for write
pTempDb->getBlockTable(pBlockTable, AcDb::kForWrite);
// get model space objectId
pBlockTable->getAt(ACDB_MODEL_SPACE, BlkRecId);
pBlockTable->close(); // dispose memory
acdbHostApplicationServices()->workingDatabase()
->wblockCloneObjects(ObjIdArr, BlkRecId, idMap, AcDb::kDrcIgnore);
AcDbIdMappingIter Iter(idMap); // initializing iterator
AcDbIdPair idPair;
for (Iter.start(); !Iter.done(); Iter.next())
{
Iter.getMap(idPair);
if (!idPair.isCloned()) // here it fails, object
is not cloned: Why???
{
acedAlert("Fail to clone object.");
break;
}
}
delete pTempDb; // dispose memory
}
Thanks for your time.
Moshe
In the following code I am trying to clone some objects, from current
database to a temporary one
the code is fails in IdMapping check for the cloned objects
What's is wrong?
void cloneMyObjects()
{
AcDbObjectIdArray ObjIdArr;
AcDbobjectId ObjId;
ads_name ent, ss;
long i, len;
// allocating memory
acedSSGet(NULL, NULL, NULL, NULL, ss);
ObjIdArr.setLogicalLength(0);
acedSSLength(ss, &len);
for (i = 0L; i < len; i++)
{
acedSSName(ss, i, ent);
acdbGetObjectId(ObjId, ent);
ObjIdArr.append(ObjId);
}
acedSSFree(ss); // dispose memory
AcDbDatabase *pTempDb;
AcDbBlockTable *pBlockTable;
AcDbObjectId BlkRecId;
AcDbIdmapping idMap;
// allocating memory, open new database
pTempDb = new AcDbDatabase(true);
// allocating memory, open block table for write
pTempDb->getBlockTable(pBlockTable, AcDb::kForWrite);
// get model space objectId
pBlockTable->getAt(ACDB_MODEL_SPACE, BlkRecId);
pBlockTable->close(); // dispose memory
acdbHostApplicationServices()->workingDatabase()
->wblockCloneObjects(ObjIdArr, BlkRecId, idMap, AcDb::kDrcIgnore);
AcDbIdMappingIter Iter(idMap); // initializing iterator
AcDbIdPair idPair;
for (Iter.start(); !Iter.done(); Iter.next())
{
Iter.getMap(idPair);
if (!idPair.isCloned()) // here it fails, object
is not cloned: Why???
{
acedAlert("Fail to clone object.");
break;
}
}
delete pTempDb; // dispose memory
}
Thanks for your time.
Moshe