<?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 Create  Entity Link to a Named Object Dictionary in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/create-entity-link-to-a-named-object-dictionary/m-p/2476088#M70837</link>
    <description>Sorry for my bad English.&lt;BR /&gt;
&lt;BR /&gt;
It is possible create a entity link to an Named Object Dictionary?&lt;BR /&gt;
I try this:&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
public void CreateLink(Database db, int number, CAO.KeyValues keyValues)&lt;BR /&gt;
        {           &lt;BR /&gt;
            using (Transaction tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;
            {                &lt;BR /&gt;
                DBDictionary dictNODKey;&lt;BR /&gt;
                try&lt;BR /&gt;
                {&lt;BR /&gt;
                    dictNODKey = (DBDictionary)tr.GetObject(_linkNodObjectId, OpenMode.ForWrite);&lt;BR /&gt;
                }&lt;BR /&gt;
                catch&lt;BR /&gt;
                {&lt;BR /&gt;
                    this.GetLinkNodObjectId(db);&lt;BR /&gt;
                    dictNODKey = (DBDictionary)tr.GetObject(_linkNodObjectId, OpenMode.ForWrite);&lt;BR /&gt;
                }&lt;BR /&gt;
                DBDictionary dictNumber;&lt;BR /&gt;
                try&lt;BR /&gt;
                {                                      &lt;BR /&gt;
                    dictNumber = (DBDictionary)tr.GetObject(dictNODKey.GetAt(Convert.ToString(number)), OpenMode.ForWrite);                   &lt;BR /&gt;
                }&lt;BR /&gt;
                catch&lt;BR /&gt;
                {&lt;BR /&gt;
                    dictNODKey.UpgradeOpen();&lt;BR /&gt;
                    dictNumber = new DBDictionary();&lt;BR /&gt;
                    dictNODKey.SetAt(Convert.ToString(number), dictNumber);&lt;BR /&gt;
                    tr.AddNewlyCreatedDBObject(dictNumber, true);                   &lt;BR /&gt;
                    try&lt;BR /&gt;
                    {&lt;BR /&gt;
                        ObjectId dictNumberId = dictNumber.ObjectId;       &lt;BR /&gt;
                         // the next line generate a error where dictNumberId is a ObjectId of an Named Object Dictionary&lt;BR /&gt;
                        CAO.Link link = _linkTemplate.CreateLink(dictNumberId.OldId, keyValues);                  &lt;BR /&gt;
                        ObjectId linkObjectId = new ObjectId(link.ObjectID);&lt;BR /&gt;
                        _lom.Add(number, linkObjectId); &lt;BR /&gt;
                    }&lt;BR /&gt;
                    catch (System.Exception ex)&lt;BR /&gt;
                    {&lt;BR /&gt;
                        MessageBox.Show(ex.ToString());&lt;BR /&gt;
                    }&lt;BR /&gt;
                }           &lt;BR /&gt;
                tr.Commit();&lt;BR /&gt;
            }           &lt;BR /&gt;
        }       &lt;BR /&gt;
{code} &lt;BR /&gt;
&lt;BR /&gt;
and give the folowing error:&lt;BR /&gt;
		"System.Runtime.InteropServices.COMException (0xC022001F): Failed to create link at CAO.LinkTemplateClass.CreateLink(Int32 ObjectID, KeyValues pKeyValues)"&lt;BR /&gt;
&lt;BR /&gt;
When I create a entity link attaching to an exist block in the drawing the above routine works fine!&lt;BR /&gt;
&lt;BR /&gt;
Why is not possible attach an entity link to an Named Object Dictionary ( DBDictionary)?&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance,&lt;BR /&gt;
&lt;BR /&gt;
Hanauer</description>
    <pubDate>Mon, 27 Apr 2009 13:39:05 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-04-27T13:39:05Z</dc:date>
    <item>
      <title>Create  Entity Link to a Named Object Dictionary</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-entity-link-to-a-named-object-dictionary/m-p/2476088#M70837</link>
      <description>Sorry for my bad English.&lt;BR /&gt;
&lt;BR /&gt;
It is possible create a entity link to an Named Object Dictionary?&lt;BR /&gt;
I try this:&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
public void CreateLink(Database db, int number, CAO.KeyValues keyValues)&lt;BR /&gt;
        {           &lt;BR /&gt;
            using (Transaction tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;
            {                &lt;BR /&gt;
                DBDictionary dictNODKey;&lt;BR /&gt;
                try&lt;BR /&gt;
                {&lt;BR /&gt;
                    dictNODKey = (DBDictionary)tr.GetObject(_linkNodObjectId, OpenMode.ForWrite);&lt;BR /&gt;
                }&lt;BR /&gt;
                catch&lt;BR /&gt;
                {&lt;BR /&gt;
                    this.GetLinkNodObjectId(db);&lt;BR /&gt;
                    dictNODKey = (DBDictionary)tr.GetObject(_linkNodObjectId, OpenMode.ForWrite);&lt;BR /&gt;
                }&lt;BR /&gt;
                DBDictionary dictNumber;&lt;BR /&gt;
                try&lt;BR /&gt;
                {                                      &lt;BR /&gt;
                    dictNumber = (DBDictionary)tr.GetObject(dictNODKey.GetAt(Convert.ToString(number)), OpenMode.ForWrite);                   &lt;BR /&gt;
                }&lt;BR /&gt;
                catch&lt;BR /&gt;
                {&lt;BR /&gt;
                    dictNODKey.UpgradeOpen();&lt;BR /&gt;
                    dictNumber = new DBDictionary();&lt;BR /&gt;
                    dictNODKey.SetAt(Convert.ToString(number), dictNumber);&lt;BR /&gt;
                    tr.AddNewlyCreatedDBObject(dictNumber, true);                   &lt;BR /&gt;
                    try&lt;BR /&gt;
                    {&lt;BR /&gt;
                        ObjectId dictNumberId = dictNumber.ObjectId;       &lt;BR /&gt;
                         // the next line generate a error where dictNumberId is a ObjectId of an Named Object Dictionary&lt;BR /&gt;
                        CAO.Link link = _linkTemplate.CreateLink(dictNumberId.OldId, keyValues);                  &lt;BR /&gt;
                        ObjectId linkObjectId = new ObjectId(link.ObjectID);&lt;BR /&gt;
                        _lom.Add(number, linkObjectId); &lt;BR /&gt;
                    }&lt;BR /&gt;
                    catch (System.Exception ex)&lt;BR /&gt;
                    {&lt;BR /&gt;
                        MessageBox.Show(ex.ToString());&lt;BR /&gt;
                    }&lt;BR /&gt;
                }           &lt;BR /&gt;
                tr.Commit();&lt;BR /&gt;
            }           &lt;BR /&gt;
        }       &lt;BR /&gt;
{code} &lt;BR /&gt;
&lt;BR /&gt;
and give the folowing error:&lt;BR /&gt;
		"System.Runtime.InteropServices.COMException (0xC022001F): Failed to create link at CAO.LinkTemplateClass.CreateLink(Int32 ObjectID, KeyValues pKeyValues)"&lt;BR /&gt;
&lt;BR /&gt;
When I create a entity link attaching to an exist block in the drawing the above routine works fine!&lt;BR /&gt;
&lt;BR /&gt;
Why is not possible attach an entity link to an Named Object Dictionary ( DBDictionary)?&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance,&lt;BR /&gt;
&lt;BR /&gt;
Hanauer</description>
      <pubDate>Mon, 27 Apr 2009 13:39:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-entity-link-to-a-named-object-dictionary/m-p/2476088#M70837</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-04-27T13:39:05Z</dc:date>
    </item>
  </channel>
</rss>

