Trouble with sets

If I have two dwg documents checked in. I create a set parent-child, using aaApi_CreateLSet success.

aaApi_SelectNestedReferencesList returns null.

If I run scan references on the parent in explorer,  aaApi_SelectNestedReferencesList  sometimes works, but sometimes the set is deleted.

I must be missing a step, any tips on why?

Cheers:)

edit: aaApi_SelectNestedReferencesList last error is PW API error, code=50000, error=Not found.: 

void Tests::testcreatePwLSet(PwDocument& parent, PwDocument& child)
{
    LONG setID = -1;
    LONG memberID = -1;
    LONG lRelationType = AADMS_SETMEM_REF;
    LPCWSTR lpctstrTransfer = AADMS_SETMEM_COPY;
    if (FALSE == aaApi_CreateLSet(&setID, parent.projectId(), parent.documentId(), 
        child.projectId(), child.documentId(), lRelationType, lpctstrTransfer, &memberID))
    {
        pwApp.promptLastError(_T("aaApi_CreateLSet failed"));
        return;
    }

    std::array<TCHAR, MAX_PATH> pwpFullPath = { 0 };
    std::array<TCHAR, MAX_PATH> pwcFullPath = { 0 };
    for (int i = 0, cnt = aaApi_SelectSet(setID); i < cnt; i++)
    {
        LPCGUID pguid = aaApi_GetSetGuidProperty(SET_PROP_PDOCGUID, i);
        LPCGUID cguid = aaApi_GetSetGuidProperty(SET_PROP_CDOCGUID, i);
        aaApi_GUIDGetDocumentFileName(pguid, pwpFullPath.data(), pwpFullPath.size());
        aaApi_GUIDGetDocumentFileName(cguid, pwcFullPath.data(), pwcFullPath.size());
        acutPrintf(_T("\nparent=%ls, child = %ls"), pwpFullPath.data(), pwcFullPath.data());
        //OK
    }
    testPwSet(parent);
}

void Tests::testPwSet(PwDocument& parent)
{
    GuidListP pList = aaApi_SelectNestedReferencesList(parent.projectId(), parent.documentId(), 0, -1);
    if (pList != nullptr)
    {
        LPCGUID pGUID = aaApi_GuidListGetFirstGuid(pList);
        while (pGUID != nullptr)
        {
            for (int i = 0, cnt = aaApi_GUIDSelectDocument(pGUID); i < cnt; i++)
            {
                const auto id = aaApi_GetDocumentNumericProperty(DOC_PROP_ID, i);
                const auto name = aaApi_GetDocumentStringProperty(DOC_PROP_NAME, i);
                acutPrintf(_T("\n%ld %ls"), id, name);
            }
            pGUID = aaApi_GuidListGetNextGuid(pList);
        }
        aaApi_GuidListDestroy(pList);
    }
    else
    {
        pwApp.promptLastError();
    }
}

  • so it seems aaApi_CreateReferenceInformation2 is needed to generate this information. however its not clear how to use this function.

    since there's zero documentation on this. things start to break when I have a tree structure of files with links created by aaApi_CreateLSet and aaApi_AddLSetMember 

    so its not clear on how to append a child using aaApi_CreateReferenceInformation2.

    How do I run the scan tool that;s in explorer from API?

  • Sets and references are a major feature and should have sample code.

    I plan on releasing just using logical sets since the behavior works, in that PW copies out 1st generation children. Hopefully it works and our mutual customers are happy : )

  • Nested references are not being copied out, even though they show in the Dependency viewer, any ideas why?

  • bool PwFileDependencyManager::createPwFileReference(const PwDocument& parent, const PwDocument &child, ETransferMode mode)
    {
        LONG setID = -1;
        LONG memberID = -1;
        LONG lRelationType = AADMS_SETMEM_REF;
        LPCWSTR lpctstrTransfer = AADMS_SETMEM_COPY;
    
        if (!parent.isIDValid())
        {
            pwApp.promptLastError(_T("Invalid parent document"));
            return false;
        }
        if (!child.isIDValid())
        {
            pwApp.promptLastError(_T("Invalid child document"));
            return false;
        }
        switch (mode)
        {
            case PwFileDependencyManager::eNone:
                lpctstrTransfer = AADMS_SETMEM_TFRNOTDEF;
                break;
            case PwFileDependencyManager::eCopy:
                lpctstrTransfer = AADMS_SETMEM_COPY;
                break;
            case PwFileDependencyManager::eCheckout:
                lpctstrTransfer = AADMS_SETMEM_CHECKOUT;
                break;
        }
    
        if (PwFileDependencyManager::hasPwReference(parent, child))
        {
            return false;
        }
    
        if (const int nCnt = aaApi_GetSetCount(parent.projectId(), parent.documentId(), -1, -1); nCnt > 0)
        {
            if (const int nRefs = aaApi_SelectSetReferences(parent.projectId(), parent.documentId()); nRefs > 0)
            {
                if (setID = aaApi_GetSetId(0); setID > 0 &&
                    !aaApi_AddLSetMember(setID, child.projectId(), child.documentId(), lRelationType, lpctstrTransfer, &memberID))
                {
                    return false;
                }
    
            }
        }
        else if (!aaApi_CreateLSet(&setID, parent.projectId(), parent.documentId(), child.projectId(), child.documentId(), lRelationType, lpctstrTransfer, &memberID))
        {
            return false;
        }
        return true;
    }
    
    bool PwFileDependencyManager::hasPwReference(const PwDocument& parent, const PwDocument& child)
    {
        return aaApi_GetSetCount(parent.projectId(), parent.documentId(), child.projectId(), child.documentId()) > 0;
    }
    

    I add references starting with the children, working my way up to the parent. it show correctly in the Dependency viewer

    but nested children aren't copied out

  • I found a work around my iterating the set and copying out the files, immediately after calling aaApi_DocumentSelectDlg, seems like a hack though