Message 1 of 1
Create Entity Link to a Named Object Dictionary
Not applicable
04-27-2009
06:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Sorry for my bad English.
It is possible create a entity link to an Named Object Dictionary?
I try this:
{code}
public void CreateLink(Database db, int number, CAO.KeyValues keyValues)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
DBDictionary dictNODKey;
try
{
dictNODKey = (DBDictionary)tr.GetObject(_linkNodObjectId, OpenMode.ForWrite);
}
catch
{
this.GetLinkNodObjectId(db);
dictNODKey = (DBDictionary)tr.GetObject(_linkNodObjectId, OpenMode.ForWrite);
}
DBDictionary dictNumber;
try
{
dictNumber = (DBDictionary)tr.GetObject(dictNODKey.GetAt(Convert.ToString(number)), OpenMode.ForWrite);
}
catch
{
dictNODKey.UpgradeOpen();
dictNumber = new DBDictionary();
dictNODKey.SetAt(Convert.ToString(number), dictNumber);
tr.AddNewlyCreatedDBObject(dictNumber, true);
try
{
ObjectId dictNumberId = dictNumber.ObjectId;
// the next line generate a error where dictNumberId is a ObjectId of an Named Object Dictionary
CAO.Link link = _linkTemplate.CreateLink(dictNumberId.OldId, keyValues);
ObjectId linkObjectId = new ObjectId(link.ObjectID);
_lom.Add(number, linkObjectId);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
tr.Commit();
}
}
{code}
and give the folowing error:
"System.Runtime.InteropServices.COMException (0xC022001F): Failed to create link at CAO.LinkTemplateClass.CreateLink(Int32 ObjectID, KeyValues pKeyValues)"
When I create a entity link attaching to an exist block in the drawing the above routine works fine!
Why is not possible attach an entity link to an Named Object Dictionary ( DBDictionary)?
Thanks in advance,
Hanauer
It is possible create a entity link to an Named Object Dictionary?
I try this:
{code}
public void CreateLink(Database db, int number, CAO.KeyValues keyValues)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
DBDictionary dictNODKey;
try
{
dictNODKey = (DBDictionary)tr.GetObject(_linkNodObjectId, OpenMode.ForWrite);
}
catch
{
this.GetLinkNodObjectId(db);
dictNODKey = (DBDictionary)tr.GetObject(_linkNodObjectId, OpenMode.ForWrite);
}
DBDictionary dictNumber;
try
{
dictNumber = (DBDictionary)tr.GetObject(dictNODKey.GetAt(Convert.ToString(number)), OpenMode.ForWrite);
}
catch
{
dictNODKey.UpgradeOpen();
dictNumber = new DBDictionary();
dictNODKey.SetAt(Convert.ToString(number), dictNumber);
tr.AddNewlyCreatedDBObject(dictNumber, true);
try
{
ObjectId dictNumberId = dictNumber.ObjectId;
// the next line generate a error where dictNumberId is a ObjectId of an Named Object Dictionary
CAO.Link link = _linkTemplate.CreateLink(dictNumberId.OldId, keyValues);
ObjectId linkObjectId = new ObjectId(link.ObjectID);
_lom.Add(number, linkObjectId);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
tr.Commit();
}
}
{code}
and give the folowing error:
"System.Runtime.InteropServices.COMException (0xC022001F): Failed to create link at CAO.LinkTemplateClass.CreateLink(Int32 ObjectID, KeyValues pKeyValues)"
When I create a entity link attaching to an exist block in the drawing the above routine works fine!
Why is not possible attach an entity link to an Named Object Dictionary ( DBDictionary)?
Thanks in advance,
Hanauer