AutoCAD Map 3D Developer

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

trouble with C# and CAO GetLinks

269 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);

}

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community