<?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 Re: wblockCloneObjects tablestyle in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/wblockcloneobjects-tablestyle/m-p/12901810#M566</link>
    <description>&lt;P&gt;Thanks for testing this, I think it’s a bug as well, or Autodesk didn’t want to nuke existing tables that have a tablestyleid assigned.&amp;nbsp; kDrcMangleName and swap id seems to work, and may be the safest approach&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;    static void AcRxPyApp_idoit(void)
    {
        AcDbDatabase* pDestDb = acdbHostApplicationServices()-&amp;gt;workingDatabase();

        std::unique_ptr&amp;lt;AcDbDatabase&amp;gt; pSrcDb(new AcDbDatabase(false, true));

        if (auto es = pSrcDb-&amp;gt;readDwgFile(_T("E://SrcTableStyle.dwg")); es != eOk)
            acutPrintf(_T("\nOops %ls"), acadErrorStatusText(es));

        if (auto es = pSrcDb-&amp;gt;closeInput(true); es != eOk)
            acutPrintf(_T("\nOops %ls"), acadErrorStatusText(es));

        AcDbIdMapping idmap;
        AcDbObjectIdArray srcids;
        srcids.append(pSrcDb-&amp;gt;tablestyle());
        AcDbObjectId ownerId = pDestDb-&amp;gt;tableStyleDictionaryId();

        if (auto es = pDestDb-&amp;gt;wblockCloneObjects(srcids, ownerId, idmap, AcDb::kDrcMangleName, false); es != eOk)
            acutPrintf(_T("\nOops %ls"), acadErrorStatusText(es));

        AcDbIdPair idPair;
        AcDbIdMappingIter iter(idmap);
        for (iter.start(); !iter.done(); iter.next())
        {
            if(!iter.getMap(idPair))
                continue;
            if (idPair.key() == pSrcDb-&amp;gt;tablestyle())
            {
                const auto sid = idPair.value();
                {
                    AcDbObjectPointer&amp;lt;AcDbObject&amp;gt; newStyle(sid, AcDb::kForWrite);
                    newStyle-&amp;gt;swapIdWith(pDestDb-&amp;gt;tablestyle(), true, true);
                }
                {
                    AcDbObjectPointer&amp;lt;AcDbObject&amp;gt; oldStyle(sid, AcDb::kForWrite);
                    oldStyle-&amp;gt;erase();
                }
                break;
            }
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jul 2024 23:40:06 GMT</pubDate>
    <dc:creator>daniel_cadext</dc:creator>
    <dc:date>2024-07-16T23:40:06Z</dc:date>
    <item>
      <title>wblockCloneObjects tablestyle</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/wblockcloneobjects-tablestyle/m-p/12889080#M564</link>
      <description>&lt;P&gt;Why doesn't this work? It does with other dictionaries.&lt;/P&gt;&lt;P&gt;There's no errors, nothing happens&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt; static void AcRxPyApp_idoit(void)
 {
     AcDbDatabase* pDestDb = acdbHostApplicationServices()-&amp;gt;workingDatabase();

     std::unique_ptr&amp;lt;AcDbDatabase&amp;gt; pSrcDb(new AcDbDatabase(false, true));

     if (auto es = pSrcDb-&amp;gt;readDwgFile(_T("E://SrcTableStyle.dwg")); es != eOk)
         acutPrintf(_T("\nOops %ls"), acadErrorStatusText(es));

     if (auto es = pSrcDb-&amp;gt;closeInput(true); es != eOk)
         acutPrintf(_T("\nOops %ls"), acadErrorStatusText(es));

     AcDbIdMapping idmap;
     AcDbObjectIdArray ids;
     ids.append(pSrcDb-&amp;gt;tablestyle());

     if (auto es = pDestDb-&amp;gt;wblockCloneObjects(ids, pDestDb-&amp;gt;tableStyleDictionaryId(), idmap, AcDb::kDrcReplace, false); es != eOk)
         acutPrintf(_T("\nOops %ls"), acadErrorStatusText(es));
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 13:34:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/wblockcloneobjects-tablestyle/m-p/12889080#M564</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2024-07-10T13:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: wblockCloneObjects tablestyle</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/wblockcloneobjects-tablestyle/m-p/12901014#M565</link>
      <description>&lt;P&gt;I tried your code. If the name of the the current tablestyle in the source DB&amp;nbsp; does &lt;EM&gt;not&lt;/EM&gt; exist in the target DB, it works fine. But if the tablestyle &lt;EM&gt;exists&lt;/EM&gt; in the destination DB, the style is not overwritten - even though you pass&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;AcDb::DuplicateRecordCloning drc =&lt;/STRONG&gt; &lt;STRONG&gt;AcDb::kDrcReplace&lt;/STRONG&gt;&lt;/FONT&gt;.&amp;nbsp;&lt;SPAN&gt;Seems to be a bug in the SDK.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Workaround: Check for existence and erase the style from the target DB if it exist.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For the sake of completeness: I replaced&amp;nbsp;&lt;FONT face="courier new,courier"&gt;std::unique_ptr&amp;lt;AcDbDatabase&amp;gt;&amp;nbsp;pSrcDb;&amp;nbsp;&lt;/FONT&gt; &lt;BR /&gt;by&amp;nbsp;&lt;FONT face="courier new,courier"&gt;AcDbDatabase *pSrcDb; / delete&amp;nbsp;pSrcDb&lt;/FONT&gt;. But this shouldn't make any difference.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2024 15:30:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/wblockcloneobjects-tablestyle/m-p/12901014#M565</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2024-07-16T15:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: wblockCloneObjects tablestyle</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/wblockcloneobjects-tablestyle/m-p/12901810#M566</link>
      <description>&lt;P&gt;Thanks for testing this, I think it’s a bug as well, or Autodesk didn’t want to nuke existing tables that have a tablestyleid assigned.&amp;nbsp; kDrcMangleName and swap id seems to work, and may be the safest approach&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;    static void AcRxPyApp_idoit(void)
    {
        AcDbDatabase* pDestDb = acdbHostApplicationServices()-&amp;gt;workingDatabase();

        std::unique_ptr&amp;lt;AcDbDatabase&amp;gt; pSrcDb(new AcDbDatabase(false, true));

        if (auto es = pSrcDb-&amp;gt;readDwgFile(_T("E://SrcTableStyle.dwg")); es != eOk)
            acutPrintf(_T("\nOops %ls"), acadErrorStatusText(es));

        if (auto es = pSrcDb-&amp;gt;closeInput(true); es != eOk)
            acutPrintf(_T("\nOops %ls"), acadErrorStatusText(es));

        AcDbIdMapping idmap;
        AcDbObjectIdArray srcids;
        srcids.append(pSrcDb-&amp;gt;tablestyle());
        AcDbObjectId ownerId = pDestDb-&amp;gt;tableStyleDictionaryId();

        if (auto es = pDestDb-&amp;gt;wblockCloneObjects(srcids, ownerId, idmap, AcDb::kDrcMangleName, false); es != eOk)
            acutPrintf(_T("\nOops %ls"), acadErrorStatusText(es));

        AcDbIdPair idPair;
        AcDbIdMappingIter iter(idmap);
        for (iter.start(); !iter.done(); iter.next())
        {
            if(!iter.getMap(idPair))
                continue;
            if (idPair.key() == pSrcDb-&amp;gt;tablestyle())
            {
                const auto sid = idPair.value();
                {
                    AcDbObjectPointer&amp;lt;AcDbObject&amp;gt; newStyle(sid, AcDb::kForWrite);
                    newStyle-&amp;gt;swapIdWith(pDestDb-&amp;gt;tablestyle(), true, true);
                }
                {
                    AcDbObjectPointer&amp;lt;AcDbObject&amp;gt; oldStyle(sid, AcDb::kForWrite);
                    oldStyle-&amp;gt;erase();
                }
                break;
            }
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2024 23:40:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/wblockcloneobjects-tablestyle/m-p/12901810#M566</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2024-07-16T23:40:06Z</dc:date>
    </item>
  </channel>
</rss>

