clone tablestyle from different dwg

clone tablestyle from different dwg

Anonymous
Not applicable
318 Views
0 Replies
Message 1 of 1

clone tablestyle from different dwg

Anonymous
Not applicable
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;
}
0 Likes
319 Views
0 Replies
Replies (0)