Message 1 of 1
clone tablestyle from different dwg

Not applicable
06-07-2006
09:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I'm trying to copy a tablestyle from a existing dwg, no luck at all 😞
Could anyone give any comments on the code below?
I'll post it at it's current attemt, you can see other attems (also without succes) in the comments....
(And I know I should check for errors, just want to have working code at first.
My problem with the code now is that I recieve the error that the tableStyle is allready in the database (eAlreadyInDb), but If I look at the tablestyles I can't find anything...
AcDbObjectId loadBOMFromOtherDrawing()
{
AcDbDictionary *tableStyle;
AcDbObjectId bomId;
AcDbObjectId newBomId;
AcDbDatabase *orig = acdbHostApplicationServices()->workingDatabase();
AcDbDatabase db(Adesk::kFalse);
db.readDwgFile("N:\\Acad\\BIB\\BOM1.dwg", _SH_DENYNO);
db.getTableStyleDictionary(tableStyle, AcDb::kForRead);
tableStyle->getAt("BOM", bomId);
tableStyle->close();
AcDbObjectIdArray cloneUs;
cloneUs.append(bomId);
AcDbIdMapping idMap;
db.deepCloneObjects(cloneUs, tableStyle->objectId(), idMap);
AcDbIdPair pair;
pair.setKey(bomId);
idMap.compute(pair);
newBomId = pair.value();
AcDbTableStyle *myStyle;
acdbOpenObject(myStyle, newBomId, AcDb::kForWrite);
//AcDbDictionary *pTsTbl;
//acdbHostApplicationServices()->workingDatabase()->getTableStyleDictionary(pTsTbl, AcDb::kForWrite);
//myStyle->setOwnerId(pTsTbl->objectId());
Acad::ErrorStatus es = myStyle->postTableStyleToDb(orig, "BOM", newBomId);
//Acad::ErrorStatus es = pTsTbl->setAt("BOM", myStyle, newBomId);
char buf[16];
AfxMessageBox(itoa(es,buf,10));
//pTsTbl->close();
myStyle->close();
return newBomId;
}
I'm trying to copy a tablestyle from a existing dwg, no luck at all 😞
Could anyone give any comments on the code below?
I'll post it at it's current attemt, you can see other attems (also without succes) in the comments....
(And I know I should check for errors, just want to have working code at first.
My problem with the code now is that I recieve the error that the tableStyle is allready in the database (eAlreadyInDb), but If I look at the tablestyles I can't find anything...
AcDbObjectId loadBOMFromOtherDrawing()
{
AcDbDictionary *tableStyle;
AcDbObjectId bomId;
AcDbObjectId newBomId;
AcDbDatabase *orig = acdbHostApplicationServices()->workingDatabase();
AcDbDatabase db(Adesk::kFalse);
db.readDwgFile("N:\\Acad\\BIB\\BOM1.dwg", _SH_DENYNO);
db.getTableStyleDictionary(tableStyle, AcDb::kForRead);
tableStyle->getAt("BOM", bomId);
tableStyle->close();
AcDbObjectIdArray cloneUs;
cloneUs.append(bomId);
AcDbIdMapping idMap;
db.deepCloneObjects(cloneUs, tableStyle->objectId(), idMap);
AcDbIdPair pair;
pair.setKey(bomId);
idMap.compute(pair);
newBomId = pair.value();
AcDbTableStyle *myStyle;
acdbOpenObject(myStyle, newBomId, AcDb::kForWrite);
//AcDbDictionary *pTsTbl;
//acdbHostApplicationServices()->workingDatabase()->getTableStyleDictionary(pTsTbl, AcDb::kForWrite);
//myStyle->setOwnerId(pTsTbl->objectId());
Acad::ErrorStatus es = myStyle->postTableStyleToDb(orig, "BOM", newBomId);
//Acad::ErrorStatus es = pTsTbl->setAt("BOM", myStyle, newBomId);
char buf[16];
AfxMessageBox(itoa(es,buf,10));
//pTsTbl->close();
myStyle->close();
return newBomId;
}