<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic clone tablestyle from different dwg in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/clone-tablestyle-from-different-dwg/m-p/1667748#M23426</link>
    <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
I'm trying to copy a tablestyle from a existing dwg, no luck at all &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Could anyone give any comments on the code below?&lt;BR /&gt;
I'll post it at it's current attemt, you can see other attems (also without succes) in the comments....&lt;BR /&gt;
(And I know I should check for errors, just want to have working code at first.&lt;BR /&gt;
&lt;BR /&gt;
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...&lt;BR /&gt;
&lt;BR /&gt;
AcDbObjectId loadBOMFromOtherDrawing()&lt;BR /&gt;
{&lt;BR /&gt;
	AcDbDictionary *tableStyle;&lt;BR /&gt;
	AcDbObjectId bomId;&lt;BR /&gt;
	AcDbObjectId newBomId;&lt;BR /&gt;
	AcDbDatabase *orig = acdbHostApplicationServices()-&amp;gt;workingDatabase();&lt;BR /&gt;
	AcDbDatabase db(Adesk::kFalse);&lt;BR /&gt;
&lt;BR /&gt;
	db.readDwgFile("N:\\Acad\\BIB\\BOM1.dwg", _SH_DENYNO);&lt;BR /&gt;
	db.getTableStyleDictionary(tableStyle, AcDb::kForRead);&lt;BR /&gt;
	tableStyle-&amp;gt;getAt("BOM", bomId);&lt;BR /&gt;
	tableStyle-&amp;gt;close();&lt;BR /&gt;
	AcDbObjectIdArray cloneUs;&lt;BR /&gt;
	cloneUs.append(bomId);&lt;BR /&gt;
	AcDbIdMapping idMap;&lt;BR /&gt;
&lt;BR /&gt;
	db.deepCloneObjects(cloneUs, tableStyle-&amp;gt;objectId(), idMap);&lt;BR /&gt;
&lt;BR /&gt;
	AcDbIdPair pair;&lt;BR /&gt;
	pair.setKey(bomId);&lt;BR /&gt;
	idMap.compute(pair);&lt;BR /&gt;
	newBomId = pair.value();&lt;BR /&gt;
&lt;BR /&gt;
	AcDbTableStyle *myStyle;&lt;BR /&gt;
	acdbOpenObject(myStyle, newBomId, AcDb::kForWrite);&lt;BR /&gt;
&lt;BR /&gt;
	//AcDbDictionary *pTsTbl;&lt;BR /&gt;
	//acdbHostApplicationServices()-&amp;gt;workingDatabase()-&amp;gt;getTableStyleDictionary(pTsTbl, AcDb::kForWrite);&lt;BR /&gt;
	//myStyle-&amp;gt;setOwnerId(pTsTbl-&amp;gt;objectId());&lt;BR /&gt;
	Acad::ErrorStatus es = myStyle-&amp;gt;postTableStyleToDb(orig, "BOM", newBomId);&lt;BR /&gt;
	//Acad::ErrorStatus es = pTsTbl-&amp;gt;setAt("BOM", myStyle, newBomId);&lt;BR /&gt;
	char buf[16];&lt;BR /&gt;
	AfxMessageBox(itoa(es,buf,10));&lt;BR /&gt;
&lt;BR /&gt;
	//pTsTbl-&amp;gt;close();&lt;BR /&gt;
	myStyle-&amp;gt;close();&lt;BR /&gt;
&lt;BR /&gt;
	return newBomId;&lt;BR /&gt;
}</description>
    <pubDate>Wed, 07 Jun 2006 16:35:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2006-06-07T16:35:10Z</dc:date>
    <item>
      <title>clone tablestyle from different dwg</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/clone-tablestyle-from-different-dwg/m-p/1667748#M23426</link>
      <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
I'm trying to copy a tablestyle from a existing dwg, no luck at all &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Could anyone give any comments on the code below?&lt;BR /&gt;
I'll post it at it's current attemt, you can see other attems (also without succes) in the comments....&lt;BR /&gt;
(And I know I should check for errors, just want to have working code at first.&lt;BR /&gt;
&lt;BR /&gt;
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...&lt;BR /&gt;
&lt;BR /&gt;
AcDbObjectId loadBOMFromOtherDrawing()&lt;BR /&gt;
{&lt;BR /&gt;
	AcDbDictionary *tableStyle;&lt;BR /&gt;
	AcDbObjectId bomId;&lt;BR /&gt;
	AcDbObjectId newBomId;&lt;BR /&gt;
	AcDbDatabase *orig = acdbHostApplicationServices()-&amp;gt;workingDatabase();&lt;BR /&gt;
	AcDbDatabase db(Adesk::kFalse);&lt;BR /&gt;
&lt;BR /&gt;
	db.readDwgFile("N:\\Acad\\BIB\\BOM1.dwg", _SH_DENYNO);&lt;BR /&gt;
	db.getTableStyleDictionary(tableStyle, AcDb::kForRead);&lt;BR /&gt;
	tableStyle-&amp;gt;getAt("BOM", bomId);&lt;BR /&gt;
	tableStyle-&amp;gt;close();&lt;BR /&gt;
	AcDbObjectIdArray cloneUs;&lt;BR /&gt;
	cloneUs.append(bomId);&lt;BR /&gt;
	AcDbIdMapping idMap;&lt;BR /&gt;
&lt;BR /&gt;
	db.deepCloneObjects(cloneUs, tableStyle-&amp;gt;objectId(), idMap);&lt;BR /&gt;
&lt;BR /&gt;
	AcDbIdPair pair;&lt;BR /&gt;
	pair.setKey(bomId);&lt;BR /&gt;
	idMap.compute(pair);&lt;BR /&gt;
	newBomId = pair.value();&lt;BR /&gt;
&lt;BR /&gt;
	AcDbTableStyle *myStyle;&lt;BR /&gt;
	acdbOpenObject(myStyle, newBomId, AcDb::kForWrite);&lt;BR /&gt;
&lt;BR /&gt;
	//AcDbDictionary *pTsTbl;&lt;BR /&gt;
	//acdbHostApplicationServices()-&amp;gt;workingDatabase()-&amp;gt;getTableStyleDictionary(pTsTbl, AcDb::kForWrite);&lt;BR /&gt;
	//myStyle-&amp;gt;setOwnerId(pTsTbl-&amp;gt;objectId());&lt;BR /&gt;
	Acad::ErrorStatus es = myStyle-&amp;gt;postTableStyleToDb(orig, "BOM", newBomId);&lt;BR /&gt;
	//Acad::ErrorStatus es = pTsTbl-&amp;gt;setAt("BOM", myStyle, newBomId);&lt;BR /&gt;
	char buf[16];&lt;BR /&gt;
	AfxMessageBox(itoa(es,buf,10));&lt;BR /&gt;
&lt;BR /&gt;
	//pTsTbl-&amp;gt;close();&lt;BR /&gt;
	myStyle-&amp;gt;close();&lt;BR /&gt;
&lt;BR /&gt;
	return newBomId;&lt;BR /&gt;
}</description>
      <pubDate>Wed, 07 Jun 2006 16:35:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/clone-tablestyle-from-different-dwg/m-p/1667748#M23426</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-07T16:35:10Z</dc:date>
    </item>
  </channel>
</rss>

