[V8i MDL] How to Call ProjectWise API from native code MDL?

Hi experts,

I'm trying to call ProjectWise API from MDL like this

#include <MicroStationAPI.h>
#include "AADMSDEF.H"
#include "AADMSAPI.H"
#include "AAWINDMS.H"
#include "AAWDDEF.H"
#include "AAAPIVER.H"
#include "AAATYPES.H"
#include "AAWINAPI.H"
#include "..\TestPW.h"


extern "C" DLLEXPORT int MdlMain (int argc, char *argv[])
{
   if (aaApi_Initialize(AAMODULE_EXPLORER))
   {
	   if (aaApi_Login(AAAPIDB_ODBC,L"IDCPWIS01.corp.abcglobal.com:PW_OP_DATASOURCE",L"abcglobal\\pwbatch", L"password",NULL)}
           mdlDialog_dmsgsPrint ("log in Successfully!");;
    
   }
   return 0;
}

but VS2008 can't compile it, saying something like "Cannot open include file: 'AADMSDEF.H': No such file or directory", even though I've already added ProjectWise SDK include path. If I use similar VBA code, no problem at all.

I searched the forum, seem no examples about calling PW API from MDL, neither in PW SDK samples.

Thanks in advance. 

Parents
  • Just to back up here a bit... could you identify what it is you are trying to develop? IOW, what type of workflow or function are you looking to achieve? That might help provide some ideas and suggestions.

      

  • Thanks Jon, Jan and Phil for your quick response.

    1. I'm using VS2008, so I added the path by Tools/Options/Projects and Solutions/VC++ Directories, added "Include files" to PW SDK include folder. Also I added "Library files" to PW SDK's libwin32. So IntelliSense works file.

    2. But I'm using make file in VS2008, not VS build system. I followed Yongan's "Step by Step to learn MDL" to create external tool VS. This tool is actually using bmake..

    3. As you know, currently OpenPlant Modeler V8i and MS V8i can publish imodels. After checking out a file from ProjectWise, and publish imodel, this imodel is in the PW working directory. So what I want to do is to publish imodel and then send it back to designated folder in PW. In this way, we don't have to rely on PW automation service to create imodel at regular basis.

    Hope I provide enough info, looking forward to your help. thanks again.
  • Unknown said:
    This tool is actually using bmake

    Whatever you do in Viz Studio is not automatically updated in your make (*.mke) file.  You must edit your make file (it's plain text) and add include paths manually.  You need to specify the right switch to tell C++ to add the /I switch.  You can do that in your make file using the cincapnd.mki macro.

    See this article about C++ Projects, in particular the section about make include file cincapnd.mki.

     
    Regards, Jon Summers
    LA Solutions

  • #dirToSearch = $(MSMDE)/mdl/MicroStationAPI
    dirToSearch = $(PW)SDK/include
    %include cincapnd.mki

    Hi Jon,

    I followed the instructions in the article above, changed this line in the make file as this:

    but still can't compile it, got new error:

    fatal error C1189: #error :  UNICODE is not defined. UNICODE must be defined for correct API arguments.

    As you know, all PW APIs are Unicode.

    I can't afford too much time for doing this kind of pioneer testing, just wondering nobody has ever  done PW API calling?

Reply
  • #dirToSearch = $(MSMDE)/mdl/MicroStationAPI
    dirToSearch = $(PW)SDK/include
    %include cincapnd.mki

    Hi Jon,

    I followed the instructions in the article above, changed this line in the make file as this:

    but still can't compile it, got new error:

    fatal error C1189: #error :  UNICODE is not defined. UNICODE must be defined for correct API arguments.

    As you know, all PW APIs are Unicode.

    I can't afford too much time for doing this kind of pioneer testing, just wondering nobody has ever  done PW API calling?

Children
  • Unknown said:
    fatal error C1189

    Well, we answered your original question: the PW header file is now seen by the C++ compiler.

    Unknown said:
    UNICODE is not defined

    Presumably that PW file, or another file that it includes, expects macro UNICODE to be #defined.  In your Viz Studio that may or may not be the case (it's an option in your Project settings).  In your bmake settings, you should add that via another compiler switch:

    nameToDefine = UNICODE
    %include cdefapnd.mki

    Unknown said:
    I can't afford too much time for doing this kind of pioneer testing

    You're a developer. You do things that others haven't done. Otherwise, it would not be development; you would be a chef and follow a recipe.

     
    Regards, Jon Summers
    LA Solutions

  • Hi Wence,

    I have a couple of notes:

    Unknown said:
    I'm trying to call ProjectWise API from MDL like this

    In your original post you mentioned you use statements like #include "AADMSDEF.H". Why do you use this form (quotation marks)? In my opinion it's wrong (possibly also causing your current problem with 1189 error). If standard headers from SDKs, libraries etc. are included, <> form should be always used and a proper environment variable has to be defined to point to a correct folder.

    Unknown said:
    I followed the instructions in the article above, changed this line in the make file as this:

    I don't know your code, but I guess it should be:

    dirToSearch = $(MSMDE)/mdl/MicroStationAPI
    %include cincapnd.mki
    
    dirToSearch = $(PW)SDK/include
    %include cincapnd.mki

    Unknown said:
    but still can't compile it, got new error:

    Such information is pretty useless. For what file this error is reported? Did you use verbose mode (-v switch) with bmake tool to receive more detail information about make and compilation process? As noted earlier, if you use the quotation marks to include PW SDK header files, I am not surprised you received the error, because if the header you included includes another header, it cannot be found.

    BTW Because UNICODE macro is defined both in MicroStation SDK and ProjectWise SDK, you have to check where the error appears. I assume if you will correctly define include folders and correctly include the headers, the error will dissapear.

    Unknown said:
    I can't afford too much time for doing this kind of pioneer testing, just wondering nobody has ever  done PW API calling?

    I agree with Jon, to solve these problems is about to be a developer (and is pretty typical for C and C++). And it's absolutely not about pioneer testing, it's about your wrongly configured environment.

    With regards,

      Jan

  • While I was doing some ProjectWise programming, I found out this statement from a Bentley expert:

    "MicroStation integration with ProjectWise is implemented via an MDL application that calls the ProjectWise native API supplied in the client DLLs. The integration is hooked into the MS GUI via some of the dialog hooks and into certain commands via various MDL system function callbacks, but is not exposed from within the MDL or VBA APIs. "

    I think the MDL application she meant is "mcm.ma" which is located in the ProjectWise bin folder. So normally we don't need to call PW API directly in MDL. If MS starts up from PW, the mdl commands, like mdlDialog_fileCreate() will automatically call PW API aaApi_SelectProjectDlg() via mcm.ma.

    But if we do want to call PW API directly, as my question in this thread, in addition to do what Jon and Jan showed me above, one more step is to add relevant PW libs in the make file, like
    ......
    $(PW)SDK\libwin32\dmscli.lib\
    $(PW)SDK\libwin32\dmawin.lib
    .......

    Thanks Jon and Jan again, much appreciated as always.

    Answer Verified By: Wence