How to CreateLink with CAO in VC++ in Autodesk Map 5?

How to CreateLink with CAO in VC++ in Autodesk Map 5?

Anonymous
Not applicable
339 Views
0 Replies
Message 1 of 1

How to CreateLink with CAO in VC++ in Autodesk Map 5?

Anonymous
Not applicable
Hello. I have the code as follows:

------------------------
(*pAcadApp)->GetInterfaceObject(_bstr_t("CAO.KeyValues"),&pDisp);
pDisp->QueryInterface(&pKeyValues);
pDisp->Release();

//set the value
if (S_OK != pKeyValues->Add(_bstr_t(linkname), _variant_t(_bstr_t(LPCTSTR(strLink))), &pKeyValue))
{
acutPrintf("\nError: Can't add a value from KeyValues.");
return Acad::eInvalidInput;
}

//create a new link
if (S_OK != pLT->CreateLink (idEnt.asOldId(), pKeyValues, &pLink)) // HERE IS THE PROBLEM !!
{
acutPrintf("\nError: Unable to create the link from the LinkTemplate.");
return Acad::eInvalidInput;
}

-----------------------
I can't create a link to an entity because CreateLink instruction does not work correctly, it returns NULL the pointer to the link (pLink), and does not create the link.
Anybody kwnows why it fails?
Is correct the call to the KeyValues->Add function? Perhaps the second parameter (VARIANT Value) must to be different VARIANT type? I have proved all VARIANT types to the value, but nothing seems to be correct.
0 Likes
340 Views
0 Replies
Replies (0)