<?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 Betreff: Data shortcut to custom objects in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/data-shortcut-to-custom-objects/m-p/11736196#M1929</link>
    <description>&lt;P&gt;Thank you Jens for this very precise answer. You give great tips.&lt;BR /&gt;I get the overall point. I will try to implement it in the AcRx::kLoadDwgMsg :&lt;BR /&gt;- check if the current drawing contains references to another drawing.&lt;BR /&gt;- for each reference, create a custom object&lt;BR /&gt;- access to the custom object in the source drawing (as you described)&lt;BR /&gt;- copy the data from 'source object' to 'new object' (I think 'copyFrom' will do the job).&lt;BR /&gt;- add the new object to the current drawing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll let you know the results of that test.&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Feb 2023 13:34:23 GMT</pubDate>
    <dc:creator>olivier.berrier</dc:creator>
    <dc:date>2023-02-07T13:34:23Z</dc:date>
    <item>
      <title>Data shortcut to custom objects</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/data-shortcut-to-custom-objects/m-p/11733316#M1927</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;i created some custom objects (ARX &amp;amp; DBX). Some objects can use a large amount of memory.&lt;BR /&gt;I would like to create a simple "data shortcut" (like Civil 3D) :&lt;BR /&gt;1) so I create the object in one drawing,&lt;BR /&gt;2) and get a reference to that object in a second drawing (display, execute commands...)&lt;/P&gt;&lt;P&gt;I am familiar with wblockCloneObjects but I don't know if I can use it in the DBX.&lt;BR /&gt;Should I call it in dwgInFields to 'fill' the object in the second drawing ?&lt;BR /&gt;Any advice would be appreciated.&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2023 15:19:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/data-shortcut-to-custom-objects/m-p/11733316#M1927</guid>
      <dc:creator>olivier.berrier</dc:creator>
      <dc:date>2023-02-06T15:19:03Z</dc:date>
    </item>
    <item>
      <title>Betreff: Data shortcut to custom objects</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/data-shortcut-to-custom-objects/m-p/11733794#M1928</link>
      <description>&lt;P&gt;Hello Olivier,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would do it as follows, if I understood correctly what you want to try to accomplish.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Save in the second drawing only the filepath, filename and handle (AcDbHandle, not ObjectId!) of the object you want to reference from the first drawing. The filepath and filename can be optional, if you have this saved at some other place.&amp;nbsp; You can get the handle with&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;    AcDbObjectId oId = AcDbObjectId::kNull;
    AcDbHandle handle = oId.handle();&lt;/LI-CODE&gt;&lt;P&gt;You may save (infile, outfile) the handle as an AcString in your second drawing. Convert the handle to AcString with:&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;	AcDbHandle		thisHandle;
	pEnt-&amp;gt;getAcDbHandle(thisHandle);
	TCHAR  handbuffer[17];
	thisHandle.getIntoAsciiBuffer(handbuffer);
	AcString astrHandle = handbuffer;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) When you need to access the data of the first drawing from the second drawing, read the first dwg file with&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;AcString filePathAndName = T("some_path\drawing1.dwg");
AcDbDatabase *pDb = new AcDbDatabase(Adesk::kFalse, true);
pDb-&amp;gt;readDwgFile(filePathAndName.kACharPtr(), AcDbDatabase::OpenMode::kForReadAndAllShare)&lt;/LI-CODE&gt;&lt;P&gt;You can skip this if you have both databases already open.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) You may consider to close the input when reading the file:&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;	//If a drawing file is associated with this database, then this function forces an
	//immediate read of all necessary information from the file into the database object.
	//If bCloseFile is true, the drawing file will be closed when it has been fully read into the AcDbDatabase.
	if (Acad::eOk != (asErr = pDb-&amp;gt;closeInput(true)))
	{
		acutPrintf(LFF LIT("Failed to closeInput for %s!"), ASF, astrDbFileName-&amp;gt;kACharPtr());
	}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4) To get the ObjectId of the object you want to access in the opened database, use this:&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;Acad::ErrorStatus AuStUtilDb::handleStrToObjId(AcDbDatabase* db, LPCTSTR handleStr, AcDbObjectId&amp;amp; objId, bool speak)
{
    ASSERT(handleStr != nullptr);
	ASSERT(db != nullptr);

    AcDbHandle objHandle(handleStr);
    Acad::ErrorStatus es;

    es = db-&amp;gt;getAcDbObjectId(objId, false, objHandle);
    if (es != Acad::eOk) {
        if (speak) {
            acutPrintf(LIT("\nERROR: Could not translate handle to objectId (%s)"), AuStUtilUi::rxErrorStr(es));
        }
        return Acad::eInvalidInput;
    }
    else
        return Acad::eOk;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;5) Change the database context with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;acdbHostApplicationServices()-&amp;gt;setWorkingDatabase(pDb);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to access the first database (drawing) you read in 2).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;6) Get your object with a smart object pointer, you need to know only the ObjectId that we got in 4).&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;AcDbSmartObjectPointer&amp;lt;YouAcDbObjectDerivedClass&amp;gt; pObj(oId, AcDb::kForRead);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;7) Now you can access the data from your object from the drawing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; Remember to change the database context back to your first drawing when you are done!&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;acdbHostApplicationServices()-&amp;gt;setWorkingDatabase(pFirstDrawing);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;9) Do not forget to delete the memory allocated for the database in step 2) (if applicable).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Jens&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2023 17:50:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/data-shortcut-to-custom-objects/m-p/11733794#M1928</guid>
      <dc:creator>autostage</dc:creator>
      <dc:date>2023-02-06T17:50:47Z</dc:date>
    </item>
    <item>
      <title>Betreff: Data shortcut to custom objects</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/data-shortcut-to-custom-objects/m-p/11736196#M1929</link>
      <description>&lt;P&gt;Thank you Jens for this very precise answer. You give great tips.&lt;BR /&gt;I get the overall point. I will try to implement it in the AcRx::kLoadDwgMsg :&lt;BR /&gt;- check if the current drawing contains references to another drawing.&lt;BR /&gt;- for each reference, create a custom object&lt;BR /&gt;- access to the custom object in the source drawing (as you described)&lt;BR /&gt;- copy the data from 'source object' to 'new object' (I think 'copyFrom' will do the job).&lt;BR /&gt;- add the new object to the current drawing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll let you know the results of that test.&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 13:34:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/data-shortcut-to-custom-objects/m-p/11736196#M1929</guid>
      <dc:creator>olivier.berrier</dc:creator>
      <dc:date>2023-02-07T13:34:23Z</dc:date>
    </item>
  </channel>
</rss>

