Getting started with the SDK

Hi,

I need to create a PW API based application but I am struggling with the SDK documentation : from what I have seen it seems to be code generated document listing function and struct of PW module with a brief description of parameters...What I need to perform seems quite basic : connect to PW then fetch a document, modify it and then save it back to PW. I haven't found any project in the samples showing how to fetch a document for instance. I can't imagine Bentley sells the SDK leaving users without a "Getting started" document so I think I am surely missing something...

Do you know about an overview documentation ? What would you recommand to get quickly up and running with the SDK ?  

Thanks.

Parents
  • The ProjectWise SDK class would be one way to get up and running with the SDK, but I'm a bit bias since I'm the instructor for most of those classes.

    You should search through the various postings on this site for various questions about "how do I..." with the SDK.

    To get the SDK samples to compile and get them running, that will take a little bit of work on your part depending upon your development environment, version of Visual Studio, version of ProjectWise, skills and experience, etc.

    Not all the samples compile into .exe's, many are "custom modules" which are essentially DLLs that get loaded by ProjectWise Explorer at start up in a specific way.  The Custom Module Manager is the tool to use to configure your custom module for debugging and testing, check the documentation for details.

    If you start with a simple Windows console application, the basic flow is:

    • Initialize the SDK
    • Log into a datasource
    • Do something
    • Log out of the datasource
    • Uninitialize the SDK

    Here's some sample code that I provide in the class early on to show the flow:

    /****************************************************************************
    *
    *             ProjectWise(TM) CONNECT Edition Software Development Kit
    *             Sample Application
    *             Copyright (C) 2018 Bentley Systems, Incorporated
    *             All Rights Reserved
    *
    ****************************************************************************/
    // MyConsoleApp02.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include "MyConsoleApp02.h"
    
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif
    
    
    // The one and only application object
    
    CWinApp theApp;
    
    using namespace std;
    
    int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
    {
        int nRetCode = 0;
    
        HMODULE hModule = ::GetModuleHandle(NULL);
    
        if (hModule != NULL)
        {
            // initialize MFC and print and error on failure
            if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))
            {
                // TODO: change error code to suit your needs
                _tprintf(_T("Fatal Error: MFC initialization failed\n"));
                nRetCode = 1;
            }
            else
            {
                // TODO: code your application's behavior here.
                LONG        lV1, lV2, lV3, lV4;
                WCHAR       szVersion[100];
                BOOL        bRetCode = FALSE;
                HDSOURCE    hDs = NULL;
    
                aaApi_Initialize (AAMODULE_ALL);
                aaApi_GetAPIVersion (&lV1, &lV2, &lV3, &lV4);
                wsprintf (szVersion, L"%d.%d.%d.%d", lV1, lV2, lV3, lV4);
                aaApi_MessageBox (szVersion, MB_OK);
    
    			//bRetCode = aaApi_Login (AAAPIDB_UNKNOWN, 
    			//            L"win2k3pwv8isdk:PWDemo", 
    			//            L"admin", 
    			//            L"admin", 
    			//            NULL);
    			bRetCode = aaApi_Login (0, 
    			            L"pwcesdk:PWDemo", 
    			            L"pwadmin", 
    			            L"pwadmin", 
    			            NULL);
    			if (!bRetCode)
                {
                    aaApi_MessageBox (L"Could not login!", MB_OK);
                    aaApi_Uninitialize();
                    nRetCode = -1;
                }
                else
                {
                    aaApi_MessageBox (L"Login successful!", MB_OK);
                    hDs = aaApi_GetActiveDatasource();
                    aaApi_LogoutByHandle (hDs);
                    aaApi_Uninitialize();
                    nRetCode = 0;
                }
            }
        }
        else
        {
            // TODO: change error code to suit your needs
            _tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
            nRetCode = 1;
        }
    
        return nRetCode;
    }
    

    This is C++ and uses Microsoft's MFC classes, but you should get the general idea of the flow of the steps.  The login API is hardcoded, but you can change that to use a dialog.  Check out the documentation for the differences of loging in in as a user or as an administrator.

    As for "fetching" a document and modifying it, it "all depends" upon what you mean by "modify".  To modify a ProjectWise Document, you don't need to fetch, you need to use one of the many "aaapi_Select..." functions to fill a specific buffer, and then you can examine that buffer.  Then you can use various API functions to modify properties of the Document, but it gets a bit complicated quickly because "words get in the way", meaning you need to understand the various "parts" of a document as not everything a user sees in the GUI of ProjectWise Explorer is in "the document", it somewhere else, but tied to the document by IDs.  

    If you want to modify the file that is attached to a document, then you need to check out the document, which will put a copy of the file into your working directory, but in a controlled manner.  Start by looking at aaApi_CheckOutDocument() and go from there.

    Answer Verified By: Guillaume Charbonnier 

  • Thanks Dan for your reply which is exactly focusing on the kind of information I would have loved when starting the project.

    Attending a class would definetely be the way to go, unfortunately it won't be easy for me to set it up as I have started the project last month as a freelancer to address a temporary shortage of ressources from my customer to do the integration of PW into their software. Furthermore, I am only working part time on this project, roughly 10 days / month. I am experienced in C++ (including MFC I used to work with 10 years ago) but a complete beginner with PW. 

    Since I have starting the project last month, it took me 13 days so far only to set up PW on a virtual machine, play with PW explorer, compile and run the samples, read the documentation and prototype a basic Qt application with a C++ wrapper around PW...my velocity is so poor I was fearing to miss something obvious like a nice overview documentation or wiki entry...

    So far, my wrapper manage the login / logout (with or without ui) and partly documents fetching. What I would need is a generic function to fetch one or several documents, defining the fetch method and supporting a type extension filter (ex: *.dwg) but I can't get a suitable solution yet among these 3 candidates :

    1. aaApi_DocumentSelectDlg 
    2. aaApi_DocumentExtendedSelectDlg
    3. (aaApi_SelectDocumentDlg2 OR aaApi_SelectDocumentsDlg ) AND aaApi_FetchDocumentsaaApi_FetchDocuments2

    Candidate 1 : does not handle multiselection correctly (can only get the filePath of the 1st document) and I haven't seen how to use a different fetch method than CheckOut.

    Candidate 2 : don't know how to change the fetch method.

    Candidate 3 : works well but doesn't support extension filter.

    Would you recommand another aaApi method to achieve this or would you know a way to define the fetch method for  aaApi_DocumentSelectDlg / aaApi_DocumentExtendedSelectDlg ?

    Thank you very much once again for your help, it is good to have a community filling the gap with the sdk doc ( I am a quite puzzled with the quality of the sdk versus its fee).

Reply
  • Thanks Dan for your reply which is exactly focusing on the kind of information I would have loved when starting the project.

    Attending a class would definetely be the way to go, unfortunately it won't be easy for me to set it up as I have started the project last month as a freelancer to address a temporary shortage of ressources from my customer to do the integration of PW into their software. Furthermore, I am only working part time on this project, roughly 10 days / month. I am experienced in C++ (including MFC I used to work with 10 years ago) but a complete beginner with PW. 

    Since I have starting the project last month, it took me 13 days so far only to set up PW on a virtual machine, play with PW explorer, compile and run the samples, read the documentation and prototype a basic Qt application with a C++ wrapper around PW...my velocity is so poor I was fearing to miss something obvious like a nice overview documentation or wiki entry...

    So far, my wrapper manage the login / logout (with or without ui) and partly documents fetching. What I would need is a generic function to fetch one or several documents, defining the fetch method and supporting a type extension filter (ex: *.dwg) but I can't get a suitable solution yet among these 3 candidates :

    1. aaApi_DocumentSelectDlg 
    2. aaApi_DocumentExtendedSelectDlg
    3. (aaApi_SelectDocumentDlg2 OR aaApi_SelectDocumentsDlg ) AND aaApi_FetchDocumentsaaApi_FetchDocuments2

    Candidate 1 : does not handle multiselection correctly (can only get the filePath of the 1st document) and I haven't seen how to use a different fetch method than CheckOut.

    Candidate 2 : don't know how to change the fetch method.

    Candidate 3 : works well but doesn't support extension filter.

    Would you recommand another aaApi method to achieve this or would you know a way to define the fetch method for  aaApi_DocumentSelectDlg / aaApi_DocumentExtendedSelectDlg ?

    Thank you very much once again for your help, it is good to have a community filling the gap with the sdk doc ( I am a quite puzzled with the quality of the sdk versus its fee).

Children
No Data