<?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 Loop/filter/query Map object data in AutoCAD Map 3D Developer Forum</title>
    <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/loop-filter-query-map-object-data/m-p/9920444#M303</link>
    <description>&lt;P&gt;It look's to me that there is no way to query the objects that have objectdata (OD).&lt;BR /&gt;That you have to loop trough all object and look if they have objectdata.&lt;BR /&gt;Is this correct or do I miss something?&lt;BR /&gt;A dxfcode or a method like PropertyDataServices.GetAllPropertySetsUsingDefinition for propertiesets?&lt;BR /&gt;Thanks&lt;BR /&gt;Pieter&lt;/P&gt;</description>
    <pubDate>Mon, 07 Dec 2020 10:59:57 GMT</pubDate>
    <dc:creator>pieter_souvereyns</dc:creator>
    <dc:date>2020-12-07T10:59:57Z</dc:date>
    <item>
      <title>Loop/filter/query Map object data</title>
      <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/loop-filter-query-map-object-data/m-p/9920444#M303</link>
      <description>&lt;P&gt;It look's to me that there is no way to query the objects that have objectdata (OD).&lt;BR /&gt;That you have to loop trough all object and look if they have objectdata.&lt;BR /&gt;Is this correct or do I miss something?&lt;BR /&gt;A dxfcode or a method like PropertyDataServices.GetAllPropertySetsUsingDefinition for propertiesets?&lt;BR /&gt;Thanks&lt;BR /&gt;Pieter&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2020 10:59:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/loop-filter-query-map-object-data/m-p/9920444#M303</guid>
      <dc:creator>pieter_souvereyns</dc:creator>
      <dc:date>2020-12-07T10:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Loop/filter/query Map object data</title>
      <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/loop-filter-query-map-object-data/m-p/9930233#M304</link>
      <description>&lt;P&gt;Hi, Pieter,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Which problem do you want to solve in the end?&lt;BR /&gt;I'm not a programmer, and I don't know how it works inside, but we did Search OD - group of commands for selecting graphical elements by OD criteria.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ODEDIT_menu_demo_eng_Search.png" style="width: 187px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/854740iF9E08FFDD1C7D2B4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ODEDIT_menu_demo_eng_Search.png" alt="ODEDIT_menu_demo_eng_Search.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Do you want to do this or solve other problems?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 16:50:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/loop-filter-query-map-object-data/m-p/9930233#M304</guid>
      <dc:creator>АлексЮстасу</dc:creator>
      <dc:date>2020-12-10T16:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Loop/filter/query Map object data</title>
      <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/loop-filter-query-map-object-data/m-p/9932518#M305</link>
      <description>&lt;P&gt;The last project I worked on was a data importer. Before the import occurs, the existing data in the dwg is checked for duplicates (don't import if that entity exists already). This is accomplished by checking a field in an object data table.&lt;/P&gt;&lt;P&gt;Using a documentlock and a transaction (tr) you can obtain a list of all entities that have object data from the modelspace blocktable record:&lt;/P&gt;&lt;P&gt;//&amp;nbsp;using acapp = Autodesk.AutoCAD.ApplicationServices;&lt;/P&gt;&lt;P&gt;//&amp;nbsp;using acdb = Autodesk.AutoCAD.DatabaseServices;&lt;/P&gt;&lt;P&gt;// reference managedmapapi.dll&lt;/P&gt;&lt;P&gt;// using acgis = Autodesk.Gis.Map;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;acapp.Document doc = acapp.Application.DocumentManager.MdiActiveDocument;
acdb.Database db = doc.Database;
using (acapp.DocumentLock docloc = doc.LockDocument())
{
	using (acdb.Transaction tr = db.TransactionManager.StartTransaction())
        {
        	acgis.MapApplication mapapp = acgis.HostMapApplicationServices.Application;
                acgis.Project.ProjectModel mapprj = mapapp.ActiveProject;
                Tables tbls = mapprj.ODTables;
                acdb.BlockTable bt = (acdb.BlockTable)tr.GetObject(db.BlockTableId, acdb.OpenMode.ForRead);
                acdb.BlockTableRecord mspace = (acdb.BlockTableRecord)tr.GetObject(bt[acdb.BlockTableRecord.ModelSpace], acdb.OpenMode.ForRead);
                acgis.ObjectData.Records recs = tbls.GetObjectRecords(0, mspace.ObjectId, acgis.Constants.OpenMode.OpenForRead, false);
                acdb.ObjectIdCollection recobjids = new acdb.ObjectIdCollection();
                recs.CountObjects(recobjids);	// CountObjects returns an objectidcollection
                recs.Dispose();
                foreach (acdb.ObjectId oid in recobjids)
                {
                	acdb.DBObject fobj = (acdb.DBObject)tr.GetObject(oid, acdb.OpenMode.ForRead);
                        acgis.ObjectData.Table t = null;
                        try
                        {
                            t = tbls["TABLE NAME"];
                            acgis.ObjectData.Records objrecs = t.GetObjectTableRecords(0, fobj, acgis.Constants.OpenMode.OpenForRead, false);
                            if (objrecs.Count &amp;gt; 0)
                            {
                                foreach (acgis.ObjectData.Record rec in objrecs)
                                {
                                    acgis.Utilities.MapValue myval = rec[0];  // the unique id is the first field in the definitions list
                                    flights.Add(myval.StrValue);   // add values to a list to be checked when importing
                                }// foreach record
                            }// if records are found
                            objrecs.Dispose();
                        }// try
                        catch { }   // table doesn't exist
                      
                    }// foreach object
                    tr.Commit();
                }// using tr
            }// using docloc&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Other notes:&lt;/P&gt;&lt;P&gt;StringCollection sc = tbls.GetTableNames();&amp;nbsp; &amp;nbsp;// a list of all object data tables&lt;/P&gt;&lt;P&gt;ADEDEFDATA (autocad command to see object data tables and definitions)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are other code samples available in this forum but you have to search.&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/568336"&gt;@АлексЮстасу&lt;/a&gt;&amp;nbsp;has a link to "odclass-odedit.com" which may do what you require.&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&amp;nbsp;has contributed lots of code (example&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/autocad-map-3d-developer/2013-map-get-objectdata-record-and-values-from-table-by-name-or/m-p/4760601#M4174" target="_blank" rel="noopener"&gt;&amp;gt;&amp;gt;here&amp;lt;&amp;lt;&lt;/A&gt;&amp;nbsp;).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IMHO - it's odd that Autodesk has never produced an FDO driver for their own data (DWG).&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 13:20:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/loop-filter-query-map-object-data/m-p/9932518#M305</guid>
      <dc:creator>fieldguy</dc:creator>
      <dc:date>2020-12-11T13:20:43Z</dc:date>
    </item>
  </channel>
</rss>

