aaApi_CreateReferenceInformation2, param UINT64 refElemId

Hello,

Trying to create references between a .DWG and other files i.e. xrefs, images etc.

I've read through the forum, but obtaining param UINT64  refElemId is still not clear.

I've seen mention of calling aaApi_CreateLSet first, but it's not clear how to get refElemId from SET_PROP_XXX

how do I get refElemId?

Thanks

Dan

Parents
  • I'm using the memberID from aaApi_CreateLSet as the refElemId argument

  • I don't know about DWG files, but for MicroStation files, "refElemId" refers to the Element ID in the design file for the reference attachment.  That Id isn't generated by ProjectWise.

    I haven't done any MicroStation programming for years, but I think the function mcmRef_getActiveReferenceList() found under MicroStation Integration API (MCM) -> MicroStation v8i Integration API would probably give you a list of reference files, and from that structure in the pRefInfoList buffer, you should be able to determine the refElemId value for each reference file.

  • Hi Dan,

    Then do I even need this function to create references between a .DWG and other files i.e. xrefs, images etc?

    I could not find any samples on this,or aaApi_CreateLSet , aaApi_CreateSet or aaApi_CreateReferenceInformation2, so I don't even know if I am on the correct path.

    Bentley has closed my support request as this being the answer, I find this quite annoying since we are paying for support, this section is critical to our application

  • Also, we can forget about the extension, I just need a sample creating references between two files, this is what I have.

    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.isValid())
        {
            pwApp.promptLastError(_T("Invalid parent document"));
            return false;
        }
        if (!child.isValid())
        {
            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 (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)
            {
                setID = aaApi_GetSetId(0);// always add to the first set??
                if (!aaApi_AddLSetMember(setID, child.projectId(), child.documentId(), lRelationType, lpctstrTransfer, &memberID))
                {
                    pwApp.promptLastError(_T("aaApi_AddLSetMember failed"));
                    return false;
                }
            }
        }
        else if (!aaApi_CreateLSet(&setID, parent.projectId(), parent.documentId(), child.projectId(), child.documentId(), lRelationType, lpctstrTransfer, &memberID))
        {
            pwApp.promptLastError(_T("aaApi_CreateLSet failed"));
            return false;
        }
    
        GUID parentGuid;
        GUID childGuid;
        LONG lFType = AADMS_FTYPE_DWG;
        LONG lFFlag = AAREFINFO_UNDERLAY_ATTACHMENT;
        const AADOC_ITEM parentItem = parent.getAADOC_ITEM();
        const AADOC_ITEM childItem = child.getAADOC_ITEM();
    
        if (!aaApi_GetDocumentGUIDsByIds(1, &parentItem, &parentGuid))
        {
            pwApp.promptLastError(_T("aaApi_GetDocumentGUIDsByIds for parent failed"));
            return false;
        }
    
        if (!aaApi_GetDocumentGUIDsByIds(1, &childItem, &childGuid))
        {
            pwApp.promptLastError(_T("aaApi_GetDocumentGUIDsByIds for child failed"));
            return false;
        }
    
        if (!aaApi_CreateReferenceInformation2(memberID, &parentGuid, 0, &childGuid, 0, lFType, 0, lFFlag))
        {
            pwApp.promptLastError(_T("aaApi_CreateReferenceInformation2 failed"));
            return false;
        }
        return true;
    }

  • Daniel,

    I'm not sure what your goal is from this and another post that is similar.  

    Typically, when a user imports a master file and its references into a ProjectWise datasource, it is expected that the user would then use the Scan References and Links Sets command to "educate" ProjectWise about the reference files.  Are you trying to automate this task so that the user doesn't have to run the "Scan Ref" tool?

    One way to automate the task of "educating" ProjectWise about the reference files attached to a design file is the approach discussed here.

    Another way is to do what the "Scan Reference" tool does in your application.

    So if you are trying to programatically "educate" ProjectWise about the reference files in your master file, then unfortunately there is no ProjectWise API function that performs this task. 

    Assuming that your code "knows" which document/file in the datasource is your master file, and which documents/files in the datasource correspond to each reference attachment in the master file, you would then need to open the master file with MicroStation and obtain some information about each reference attachment, i.e. the element id, etc. that you need when creating the master/reference associations. You could do this with the either the MCM functions I mentioned above (but the design file would need to be opened), or by using the MicroStation SDK. 

    I checked with a colleague and I now understand that MicroStation can read and write DWG files so the process should be the same for DGN or DWG files.  You would also need to change the reference attachment in the master file to be in a form that ProjectWise expects as well as create the master/reference file associations in the datasource via the ProjectWise APIs. 

  • Hi Dan,

    My task is to replicate the plug in for AutoCAD in BricsCAD. Our APIs are pretty much identical between ObjectARX and .BRX, I think we could have saved a bunch of time if Bentley would have just recompiled to link with BricsCAD libraries, but since that didn’t work out, here I am reinventing the wheel : )

    I’m not working in MicroStation and we don’t expect it to be installed on client machines, so I can’t use the API.  Base client install will be BricsCAD and Project wise explorer, clients of course will be required to obtain projectwise from Bentley

    Since BricsCAD is primarily a .DWG application, that’s my focus for now.  . DWG’s can have dependencies, of many file formats. I.E.  OLE, typically from office, other .DWGs as XREFs, .PDF, Datalink files (.XLSX , .CSV) , Images, Lidar data, etc.  Dependencies can be nested, I.e. if a XREF has one of the above attached.

    Surely, project wise is able to build and store parent <-> children relationships in file formats other than .DGN, the code I posted actually works as expected, but is it correct?   Do I even need to use aaApi_CreateReferenceInformation2 for non .DGN formats? And if so, what’s the parameter refElemId? Is it something I can makeup such as a dependency object id or reference handle?  I have a tool that scans the .DWG and builds a tree structure of parent <-> children, so I do have handles I can use.

    Best regards

    Daniel

Reply
  • Hi Dan,

    My task is to replicate the plug in for AutoCAD in BricsCAD. Our APIs are pretty much identical between ObjectARX and .BRX, I think we could have saved a bunch of time if Bentley would have just recompiled to link with BricsCAD libraries, but since that didn’t work out, here I am reinventing the wheel : )

    I’m not working in MicroStation and we don’t expect it to be installed on client machines, so I can’t use the API.  Base client install will be BricsCAD and Project wise explorer, clients of course will be required to obtain projectwise from Bentley

    Since BricsCAD is primarily a .DWG application, that’s my focus for now.  . DWG’s can have dependencies, of many file formats. I.E.  OLE, typically from office, other .DWGs as XREFs, .PDF, Datalink files (.XLSX , .CSV) , Images, Lidar data, etc.  Dependencies can be nested, I.e. if a XREF has one of the above attached.

    Surely, project wise is able to build and store parent <-> children relationships in file formats other than .DGN, the code I posted actually works as expected, but is it correct?   Do I even need to use aaApi_CreateReferenceInformation2 for non .DGN formats? And if so, what’s the parameter refElemId? Is it something I can makeup such as a dependency object id or reference handle?  I have a tool that scans the .DWG and builds a tree structure of parent <-> children, so I do have handles I can use.

    Best regards

    Daniel

Children
No Data