AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

New Member
Posts: 2
Registered: ‎11-13-2006
Message 1 of 1 (287 Views)

trouble with C# and CAO GetLinks

287 Views, 0 Replies
03-15-2011 07:19 AM

Does anyone have any small snippets of code they can post as an example of how to use GetLinks or GetLinksBySQLCond? This seems to be a problem with many others too. I referred to the CAOText.dvb example from SDK but I can not get it to work when I write it in C#. Here is what I have and I can not get it to work. I am attempting to get the links from a user selected AutoCAD object, after the user selects the linktemplate from a list box. The problem is at the GetLinks method (last line of code). I have tried passing in different types of objIDs such as array of longs, array of ObjectIDs and still no luck. Ahy help would be appreciated, thanks.


CAO.DbConnect dbConnect = new CAO.DbConnect();
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

//linktemplate object retrieved from user selected menu
CAO.LinkTemplate objLinkTemplate = dbConnect.GetLinkTemplates(doc.AcadDocument).Item(this.lbLinkList.SelectedItem.ToString());

PromptSelectionResult acssPrompt = doc.Editor.GetSelection();

if (acssPrompt.Status == PromptStatus.OK)
 SelectionSet acSSet = acssPrompt.Value
 long[] objIDs = new long[acSSet.Count];
 int i = 0;

 foreach (SelectedObject acSSobj in acSSet)

  objIDs[i] = (long)acSSobj.ObjectId.OldIdPtr;
  i += 1;


 int linkTypes = (int)CAO.LinkType.kEntityLinkType;
 CAO.Links linkSel = dbConnect.GetLinks(objLinkTemplate, objIDs, linkTypes, doc.AcadDocument);


Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.